From 980384e00a7649b9fbc18f9b6af21e423b9b1bcd Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 10 Dec 2014 09:45:00 -0700 Subject: [PATCH] swrast: fix a few attribute loop issues in clip_span() The loop over the sw_span::interpMask attributes was incorrect. We only need to process the attributes which correspond to the SPAN_x flags. Also, a bit test for span->arrayAttribs was using a 32-bit mask instead of a 64-bit mask. Bugzilla: http://bugs.freedesktop.org/show_bug.cgi?id=87136 --- src/mesa/swrast/s_span.c | 13 ++++++++----- src/mesa/swrast/s_span.h | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index 10aa33c..b946838 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -760,11 +760,12 @@ clip_span( struct gl_context *ctx, SWspan *span ) ASSERT(x + n > xmin); /* Clip 'leftClip' pixels from the left side. - * The span->leftClip field will be applied when we interpolate - * fragment attributes. - * For arrays of values, shift them left. + * Loop over the fixed-function, SPAN_x attributes and adjust + * the attrStart values. Note that we don't need to do this + * for the generic attributes since the leftClip factor is + * applied in interpolate_active_attribs(). */ - for (i = 0; i < VARYING_SLOT_MAX; i++) { + for (i = 0; i < SPAN_NUM_ATTRIBS; i++) { if (span->interpMask & (1 << i)) { GLuint j; for (j = 0; j < 4; j++) { @@ -773,6 +774,7 @@ clip_span( struct gl_context *ctx, SWspan *span ) } } + /* adjust the fixed-point attributes */ span->red += leftClip * span->redStep; span->green += leftClip * span->greenStep; span->blue += leftClip * span->blueStep; @@ -782,11 +784,12 @@ clip_span( struct gl_context *ctx, SWspan *span ) span->intTex[0] += leftClip * span->intTexStep[0]; span->intTex[1] += leftClip * span->intTexStep[1]; + /* left-shift values in attribute arrays */ #define SHIFT_ARRAY(ARRAY, SHIFT, LEN) \ memmove(ARRAY, ARRAY + (SHIFT), (LEN) * sizeof(ARRAY[0])) for (i = 0; i < VARYING_SLOT_MAX; i++) { - if (span->arrayAttribs & (1 << i)) { + if (span->arrayAttribs & BITFIELD64_BIT(i)) { /* shift array elements left by 'leftClip' */ SHIFT_ARRAY(span->array->attribs[i], leftClip, n - leftClip); } diff --git a/src/mesa/swrast/s_span.h b/src/mesa/swrast/s_span.h index 794f671..6d96684 100644 --- a/src/mesa/swrast/s_span.h +++ b/src/mesa/swrast/s_span.h @@ -55,6 +55,7 @@ struct gl_renderbuffer; #define SPAN_MASK 0x10 /**< was array.mask[] filled in by caller? */ #define SPAN_LAMBDA 0x20 /**< array.lambda[] valid? */ #define SPAN_COVERAGE 0x40 /**< array.coverage[] valid? */ +#define SPAN_NUM_ATTRIBS 7 /*@}*/ -- 1.9.1