diff options
Diffstat (limited to 'src/mesa/swrast')
| -rw-r--r-- | src/mesa/swrast/s_context.c | 28 | ||||
| -rw-r--r-- | src/mesa/swrast/s_imaging.c | 10 | ||||
| -rw-r--r-- | src/mesa/swrast/s_span.c | 86 | ||||
| -rw-r--r-- | src/mesa/swrast/s_span.h | 9 | ||||
| -rw-r--r-- | src/mesa/swrast/s_texcombine.c | 10 | ||||
| -rw-r--r-- | src/mesa/swrast/s_texfilter.c | 25 | 
6 files changed, 86 insertions, 82 deletions
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index a7eaf76a0a..e7c2ace32c 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -264,13 +264,7 @@ _swrast_update_fragment_program(GLcontext *ctx, GLbitfield newState)  {     const struct gl_fragment_program *fp = ctx->FragmentProgram._Current;     if (fp) { -#if 0 -      /* XXX Need a way to trigger the initial loading of parameters -       * even when there's no recent state changes. -       */ -      if (fp->Base.Parameters->StateFlags & newState) -#endif -         _mesa_load_state_parameters(ctx, fp->Base.Parameters); +      _mesa_load_state_parameters(ctx, fp->Base.Parameters);     }  } @@ -295,6 +289,7 @@ _swrast_update_specular_vertex_add(GLcontext *ctx)  #define _SWRAST_NEW_DERIVED (_SWRAST_NEW_RASTERMASK |	\ +                             _NEW_PROGRAM_CONSTANTS |   \  			     _NEW_TEXTURE |		\  			     _NEW_HINT |		\  			     _NEW_POLYGON ) @@ -524,13 +519,6 @@ _swrast_invalidate_state( GLcontext *ctx, GLbitfield new_state )        new_state = ~0;     } -   { -      const struct gl_fragment_program *fp = ctx->FragmentProgram._Current; -      if (fp && (fp->Base.Parameters->StateFlags & new_state)) { -         _mesa_load_state_parameters(ctx, fp->Base.Parameters); -      } -   } -     if (new_state & swrast->InvalidateTriangleMask)        swrast->Triangle = _swrast_validate_triangle; @@ -647,17 +635,7 @@ _swrast_validate_derived( GLcontext *ctx )        if (swrast->NewState & (_NEW_FOG | _NEW_PROGRAM))           _swrast_update_fog_state( ctx ); -      if (swrast->NewState & (_NEW_MODELVIEW | -                              _NEW_PROJECTION | -                              _NEW_TEXTURE_MATRIX | -                              _NEW_FOG | -                              _NEW_LIGHT | -                              _NEW_LINE | -                              _NEW_TEXTURE | -                              _NEW_TRANSFORM | -                              _NEW_POINT | -                              _NEW_VIEWPORT | -                              _NEW_PROGRAM)) +      if (swrast->NewState & (_NEW_PROGRAM_CONSTANTS | _NEW_PROGRAM))  	 _swrast_update_fragment_program( ctx, swrast->NewState );        if (swrast->NewState & (_NEW_TEXTURE | _NEW_PROGRAM)) { diff --git a/src/mesa/swrast/s_imaging.c b/src/mesa/swrast/s_imaging.c index d6be3aa022..3578b713f6 100644 --- a/src/mesa/swrast/s_imaging.c +++ b/src/mesa/swrast/s_imaging.c @@ -60,7 +60,7 @@ _swrast_CopyColorTable( GLcontext *ctx,     /* save PBO binding */     bufferSave = ctx->Unpack.BufferObj; -   ctx->Unpack.BufferObj = ctx->Array.NullBufferObj; +   ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj;     _mesa_ColorTable(target, internalformat, width, GL_RGBA, CHAN_TYPE, data); @@ -94,7 +94,7 @@ _swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start,     /* save PBO binding */     bufferSave = ctx->Unpack.BufferObj; -   ctx->Unpack.BufferObj = ctx->Array.NullBufferObj; +   ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj;     _mesa_ColorSubTable(target, start, width, GL_RGBA, CHAN_TYPE, data); @@ -126,7 +126,7 @@ _swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target,     /* save PBO binding */     bufferSave = ctx->Unpack.BufferObj; -   ctx->Unpack.BufferObj = ctx->Array.NullBufferObj; +   ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj;     /* store as convolution filter */     _mesa_ConvolutionFilter1D(target, internalFormat, width, @@ -178,12 +178,12 @@ _swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target,     ctx->Unpack.SkipImages = 0;     ctx->Unpack.SwapBytes = GL_FALSE;     ctx->Unpack.LsbFirst = GL_FALSE; -   ctx->Unpack.BufferObj = ctx->Array.NullBufferObj; +   ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj;     ctx->NewState |= _NEW_PACKUNPACK;     /* save PBO binding */     bufferSave = ctx->Unpack.BufferObj; -   ctx->Unpack.BufferObj = ctx->Array.NullBufferObj; +   ctx->Unpack.BufferObj = ctx->Shared->NullBufferObj;     _mesa_ConvolutionFilter2D(target, internalFormat, width, height,                               GL_RGBA, CHAN_TYPE, rgba); diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c index cfff82b051..0e2793b474 100644 --- a/src/mesa/swrast/s_span.c +++ b/src/mesa/swrast/s_span.c @@ -1,8 +1,9 @@  /*   * Mesa 3-D graphics library - * Version:  7.1 + * Version:  7.5   * - * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved. + * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved. + * Copyright (C) 2009  VMware, Inc.  All Rights Reserved.   *   * Permission is hereby granted, free of charge, to any person obtaining a   * copy of this software and associated documentation files (the "Software"), @@ -188,10 +189,10 @@ interpolate_active_attribs(GLcontext *ctx, SWspan *span, GLbitfield attrMask)           const GLfloat dv1dx = span->attrStepX[attr][1];           const GLfloat dv2dx = span->attrStepX[attr][2];           const GLfloat dv3dx = span->attrStepX[attr][3]; -         GLfloat v0 = span->attrStart[attr][0]; -         GLfloat v1 = span->attrStart[attr][1]; -         GLfloat v2 = span->attrStart[attr][2]; -         GLfloat v3 = span->attrStart[attr][3]; +         GLfloat v0 = span->attrStart[attr][0] + span->leftClip * dv0dx; +         GLfloat v1 = span->attrStart[attr][1] + span->leftClip * dv1dx; +         GLfloat v2 = span->attrStart[attr][2] + span->leftClip * dv2dx; +         GLfloat v3 = span->attrStart[attr][3] + span->leftClip * dv3dx;           GLuint k;           for (k = 0; k < span->end; k++) {              const GLfloat invW = 1.0f / w; @@ -521,10 +522,10 @@ interpolate_texcoords(GLcontext *ctx, SWspan *span)           const GLfloat drdx = span->attrStepX[attr][2];           const GLfloat dqdx = span->attrStepX[attr][3];           const GLfloat dqdy = span->attrStepY[attr][3]; -         GLfloat s = span->attrStart[attr][0]; -         GLfloat t = span->attrStart[attr][1]; -         GLfloat r = span->attrStart[attr][2]; -         GLfloat q = span->attrStart[attr][3]; +         GLfloat s = span->attrStart[attr][0] + span->leftClip * dsdx; +         GLfloat t = span->attrStart[attr][1] + span->leftClip * dtdx; +         GLfloat r = span->attrStart[attr][2] + span->leftClip * drdx; +         GLfloat q = span->attrStart[attr][3] + span->leftClip * dqdx;           if (obj) {              const struct gl_texture_image *img = obj->Image[0][obj->BaseLevel]; @@ -546,7 +547,7 @@ interpolate_texcoords(GLcontext *ctx, SWspan *span)                  || ctx->ATIFragmentShader._Enabled) {                 /* do perspective correction but don't divide s, t, r by q */                 const GLfloat dwdx = span->attrStepX[FRAG_ATTRIB_WPOS][3]; -               GLfloat w = span->attrStart[FRAG_ATTRIB_WPOS][3]; +               GLfloat w = span->attrStart[FRAG_ATTRIB_WPOS][3] + span->leftClip * dwdx;                 for (i = 0; i < span->end; i++) {                    const GLfloat invW = 1.0F / w;                    texcoord[i][0] = s * invW; @@ -587,7 +588,7 @@ interpolate_texcoords(GLcontext *ctx, SWspan *span)                  ctx->ATIFragmentShader._Enabled) {                 /* do perspective correction but don't divide s, t, r by q */                 const GLfloat dwdx = span->attrStepX[FRAG_ATTRIB_WPOS][3]; -               GLfloat w = span->attrStart[FRAG_ATTRIB_WPOS][3]; +               GLfloat w = span->attrStart[FRAG_ATTRIB_WPOS][3] + span->leftClip * dwdx;                 for (i = 0; i < span->end; i++) {                    const GLfloat invW = 1.0F / w;                    texcoord[i][0] = s * invW; @@ -660,8 +661,8 @@ interpolate_wpos(GLcontext *ctx, SWspan *span)        }     } -   w = span->attrStart[FRAG_ATTRIB_WPOS][3];     dw = span->attrStepX[FRAG_ATTRIB_WPOS][3]; +   w = span->attrStart[FRAG_ATTRIB_WPOS][3] + span->leftClip * dw;     for (i = 0; i < span->end; i++) {        wpos[i][2] = (GLfloat) span->array->z[i] * zScale;        wpos[i][3] = w; @@ -726,6 +727,8 @@ clip_span( GLcontext *ctx, SWspan *span )     const GLint ymin = ctx->DrawBuffer->_Ymin;     const GLint ymax = ctx->DrawBuffer->_Ymax; +   span->leftClip = 0; +     if (span->arrayMask & SPAN_XY) {        /* arrays of x/y pixel coords */        const GLint *x = span->array->x; @@ -753,7 +756,7 @@ clip_span( GLcontext *ctx, SWspan *span )        /* horizontal span of pixels */        const GLint x = span->x;        const GLint y = span->y; -      const GLint n = span->end; +      GLint n = span->end;        /* Trivial rejection tests */        if (y < ymin || y >= ymax || x + n <= xmin || x >= xmax) { @@ -761,18 +764,44 @@ clip_span( GLcontext *ctx, SWspan *span )           return GL_FALSE;  /* all pixels clipped */        } +      /* Clip to right */ +      if (x + n > xmax) { +         ASSERT(x < xmax); +         n = span->end = xmax - x; +      } +        /* Clip to the left */        if (x < xmin) { +         const GLint leftClip = xmin - x; +         GLuint i; + +         ASSERT(leftClip > 0);           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. +          */ +         for (i = 0; i < FRAG_ATTRIB_MAX; i++) { +            if (span->arrayAttribs & (1 << i)) { +               /* shift array elements left by 'leftClip' */ +               _mesa_memcpy(span->array->attribs[i], +                            span->array->attribs[i] + leftClip, +                            (n - leftClip) * 4 * sizeof(GLfloat)); +            } +         } + +         span->leftClip = leftClip; +         span->x = xmin; +         span->end -= leftClip;           span->writeAll = GL_FALSE; -         _mesa_bzero(span->array->mask, (xmin - x) * sizeof(GLubyte));        } -      /* Clip to right */ -      if (x + n > xmax) { -         ASSERT(x < xmax); -         span->end = xmax - x; -      } +      ASSERT(span->x >= xmin); +      ASSERT(span->x + span->end <= xmax); +      ASSERT(span->y >= ymin); +      ASSERT(span->y < ymax);        return GL_TRUE;  /* some pixels visible */     } @@ -818,6 +847,12 @@ _swrast_write_index_span( GLcontext *ctx, SWspan *span)        }     } +   if (!(span->arrayMask & SPAN_MASK)) { +      /* post-clip sanity check */ +      assert(span->x >= 0); +      assert(span->y >= 0); +   } +     /* Depth bounds test */     if (ctx->Depth.BoundsTest && fb->Visual.depthBits > 0) {        if (!_swrast_depth_bounds_test(ctx, span)) { @@ -1262,7 +1297,6 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)            span->primitive == GL_LINE ||  	  span->primitive == GL_POLYGON ||            span->primitive == GL_BITMAP); -   ASSERT(span->end <= MAX_WIDTH);     /* Fragment write masks */     if (span->arrayMask & SPAN_MASK) { @@ -1275,15 +1309,16 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)     }     /* Clip to window/scissor box */ -   if ((swrast->_RasterMask & CLIP_BIT) || (span->primitive != GL_POLYGON)) { -      if (!clip_span(ctx, span)) { -	 return; -      } +   if (!clip_span(ctx, span)) { +      return;     } +   ASSERT(span->end <= MAX_WIDTH); +  #ifdef DEBUG     /* Make sure all fragments are within window bounds */     if (span->arrayMask & SPAN_XY) { +      /* array of pixel locations */        GLuint i;        for (i = 0; i < span->end; i++) {           if (span->array->mask[i]) { @@ -1320,7 +1355,6 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)     if (ctx->Stencil._Enabled || ctx->Depth.Test) {        if (!(span->arrayMask & SPAN_Z))           _swrast_span_interpolate_z(ctx, span); -        if (ctx->Stencil._Enabled) {           /* Combined Z/stencil tests */           if (!_swrast_stencil_and_ztest_span(ctx, span)) { diff --git a/src/mesa/swrast/s_span.h b/src/mesa/swrast/s_span.h index c4b47df58f..0eabae20e0 100644 --- a/src/mesa/swrast/s_span.h +++ b/src/mesa/swrast/s_span.h @@ -1,8 +1,9 @@  /*   * Mesa 3-D graphics library - * Version:  6.5 + * Version:  7.5   * - * Copyright (C) 1999-2005  Brian Paul   All Rights Reserved. + * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved. + * Copyright (C) 2009  VMware, Inc.  All Rights Reserved.   *   * Permission is hereby granted, free of charge, to any person obtaining a   * copy of this software and associated documentation files (the "Software"), @@ -106,6 +107,9 @@ typedef struct sw_span     /** Number of fragments in the span */     GLuint end; +   /** for clipping left edge of spans */ +   GLuint leftClip; +     /** This flag indicates that mask[] array is effectively filled with ones */     GLboolean writeAll; @@ -165,6 +169,7 @@ do {						\     (S).arrayMask = 0x0;				\     (S).arrayAttribs = 0x0;			\     (S).end = 0;					\ +   (S).leftClip = 0;				\     (S).facing = 0;				\     (S).array = SWRAST_CONTEXT(ctx)->SpanArrays;	\  } while (0) diff --git a/src/mesa/swrast/s_texcombine.c b/src/mesa/swrast/s_texcombine.c index fae7280efb..889164b986 100644 --- a/src/mesa/swrast/s_texcombine.c +++ b/src/mesa/swrast/s_texcombine.c @@ -49,8 +49,7 @@ typedef float (*float4_array)[4];  static INLINE float4_array  get_texel_array(SWcontext *swrast, GLuint unit)  { -   return (float4_array) -      (swrast->TexelBuffer + unit * MAX_WIDTH * 4 * sizeof(GLfloat)); +   return (float4_array) (swrast->TexelBuffer + unit * MAX_WIDTH * 4);  } @@ -408,17 +407,10 @@ texture_combine( GLcontext *ctx, GLuint unit, GLuint n,           /* this produces a fixed rgba color, and the coord calc is done elsewhere */           for (i = 0; i < n; i++) {              /* rgba result is 0,0,0,1 */ -#if CHAN_TYPE == GL_FLOAT              rgba[i][RCOMP] = 0.0;              rgba[i][GCOMP] = 0.0;              rgba[i][BCOMP] = 0.0;              rgba[i][ACOMP] = 1.0; -#else -            rgba[i][RCOMP] = 0; -            rgba[i][GCOMP] = 0; -            rgba[i][BCOMP] = 0; -            rgba[i][ACOMP] = CHAN_MAX; -#endif  	 }           return; /* no alpha processing */        default: diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index a483023a50..0067d3eeb7 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -462,6 +462,7 @@ clamp_rect_coord_linear(GLenum wrapMode, GLfloat coord, GLint max,        fcol -= 0.5F;        i0 = IFLOOR(fcol);        i1 = i0 + 1; +      break;     default:        _mesa_problem(NULL, "bad wrapMode in clamp_rect_coord_linear");        i0 = i1 = 0; @@ -1328,7 +1329,7 @@ static void  opt_sample_rgb_2d(GLcontext *ctx,                    const struct gl_texture_object *tObj,                    GLuint n, const GLfloat texcoords[][4], -                  const GLfloat lambda[], GLchan rgba[][4]) +                  const GLfloat lambda[], GLfloat rgba[][4])  {     const struct gl_texture_image *img = tObj->Image[0][tObj->BaseLevel];     const GLfloat width = (GLfloat) img->Width; @@ -1350,9 +1351,9 @@ opt_sample_rgb_2d(GLcontext *ctx,        GLint j = IFLOOR(texcoords[k][1] * height) & rowMask;        GLint pos = (j << shift) | i;        GLchan *texel = ((GLchan *) img->Data) + 3*pos; -      rgba[k][RCOMP] = texel[0]; -      rgba[k][GCOMP] = texel[1]; -      rgba[k][BCOMP] = texel[2]; +      rgba[k][RCOMP] = CHAN_TO_FLOAT(texel[0]); +      rgba[k][GCOMP] = CHAN_TO_FLOAT(texel[1]); +      rgba[k][BCOMP] = CHAN_TO_FLOAT(texel[2]);     }  } @@ -1369,7 +1370,7 @@ static void  opt_sample_rgba_2d(GLcontext *ctx,                     const struct gl_texture_object *tObj,                     GLuint n, const GLfloat texcoords[][4], -                   const GLfloat lambda[], GLchan rgba[][4]) +                   const GLfloat lambda[], GLfloat rgba[][4])  {     const struct gl_texture_image *img = tObj->Image[0][tObj->BaseLevel];     const GLfloat width = (GLfloat) img->Width; @@ -1391,7 +1392,10 @@ opt_sample_rgba_2d(GLcontext *ctx,        const GLint row = IFLOOR(texcoords[i][1] * height) & rowMask;        const GLint pos = (row << shift) | col;        const GLchan *texel = ((GLchan *) img->Data) + (pos << 2);    /* pos*4 */ -      COPY_4V(rgba[i], texel); +      rgba[i][RCOMP] = CHAN_TO_FLOAT(texel[0]); +      rgba[i][GCOMP] = CHAN_TO_FLOAT(texel[1]); +      rgba[i][BCOMP] = CHAN_TO_FLOAT(texel[2]); +      rgba[i][ACOMP] = CHAN_TO_FLOAT(texel[3]);     }  } @@ -1424,7 +1428,6 @@ sample_lambda_2d(GLcontext *ctx,        case GL_NEAREST:           if (repeatNoBorderPOT) {              switch (tImg->TexFormat->MesaFormat) { -#if 0              case MESA_FORMAT_RGB:                 opt_sample_rgb_2d(ctx, tObj, m, texcoords + minStart,                                   NULL, rgba + minStart); @@ -1433,7 +1436,6 @@ sample_lambda_2d(GLcontext *ctx,  	       opt_sample_rgba_2d(ctx, tObj, m, texcoords + minStart,                                    NULL, rgba + minStart);                 break; -#endif              default:                 sample_nearest_2d(ctx, tObj, m, texcoords + minStart,                                   NULL, rgba + minStart ); @@ -1483,7 +1485,6 @@ sample_lambda_2d(GLcontext *ctx,        case GL_NEAREST:           if (repeatNoBorderPOT) {              switch (tImg->TexFormat->MesaFormat) { -#if 0              case MESA_FORMAT_RGB:                 opt_sample_rgb_2d(ctx, tObj, m, texcoords + magStart,                                   NULL, rgba + magStart); @@ -1492,7 +1493,6 @@ sample_lambda_2d(GLcontext *ctx,  	       opt_sample_rgba_2d(ctx, tObj, m, texcoords + magStart,                                    NULL, rgba + magStart);                 break; -#endif              default:                 sample_nearest_2d(ctx, tObj, m, texcoords + magStart,                                   NULL, rgba + magStart ); @@ -3179,7 +3179,6 @@ _swrast_choose_texture_sample_func( GLcontext *ctx,           }           else {              /* check for a few optimized cases */ -#if 0              const struct gl_texture_image *img = t->Image[0][t->BaseLevel];              ASSERT(t->MinFilter == GL_NEAREST);              if (t->WrapS == GL_REPEAT && @@ -3196,10 +3195,6 @@ _swrast_choose_texture_sample_func( GLcontext *ctx,                       img->TexFormat->MesaFormat == MESA_FORMAT_RGBA) {                 return &opt_sample_rgba_2d;              } -#else -            if (0) -               ; -#endif              else {                 return &sample_nearest_2d;              }  | 
