fix typo
[mesa.git] / src / mesa / swrast / s_span.c
index 231e549c5aedbd82b91749267499ed59bcb2893f..ee46f323076e64964e54b481ce5e4db10be95472 100644 (file)
@@ -110,7 +110,7 @@ _swrast_span_default_color( GLcontext *ctx, struct sw_span *span )
       span->interpMask |= SPAN_RGBA;
    }
    else {
-      span->index = IntToFixed(ctx->Current.RasterIndex);
+      span->index = FloatToFixed(ctx->Current.RasterIndex);
       span->indexStep = 0;
       span->interpMask |= SPAN_INDEX;
    }
@@ -361,7 +361,7 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
             GLfloat texW, texH;
             GLboolean needLambda;
             if (obj) {
-               const struct gl_texture_image *img = obj->Image[obj->BaseLevel];
+               const struct gl_texture_image *img = obj->Image[0][obj->BaseLevel];
                needLambda = (obj->MinFilter != obj->MagFilter)
                   || ctx->FragmentProgram.Enabled;
                texW = img->WidthScale;
@@ -453,7 +453,7 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
       GLfloat texW, texH;
       GLboolean needLambda;
       if (obj) {
-         const struct gl_texture_image *img = obj->Image[obj->BaseLevel];
+         const struct gl_texture_image *img = obj->Image[0][obj->BaseLevel];
          needLambda = (obj->MinFilter != obj->MagFilter)
             || ctx->FragmentProgram.Enabled;
          texW = (GLfloat) img->WidthScale;
@@ -515,6 +515,7 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
                texcoord[i][0] = s * invQ;
                texcoord[i][1] = t * invQ;
                texcoord[i][2] = r * invQ;
+               texcoord[i][3] = q;
                s += dsdx;
                t += dtdx;
                r += drdx;
@@ -526,6 +527,7 @@ interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
                texcoord[i][0] = s * invQ;
                texcoord[i][1] = t * invQ;
                texcoord[i][2] = r * invQ;
+               texcoord[i][3] = q;
                s += dsdx;
                t += dtdx;
                r += drdx;
@@ -714,7 +716,7 @@ multi_write_rgba_span( GLcontext *ctx, struct sw_span *span )
          /* make copy of incoming colors */
          MEMCPY( rgbaTmp, span->array->rgba, 4 * span->end * sizeof(GLchan) );
 
-         if (ctx->Color.ColorLogicOpEnabled) {
+         if (ctx->Color._LogicOpEnabled) {
             _swrast_logicop_rgba_span(ctx, span, rgbaTmp);
          }
          else if (ctx->Color.BlendEnabled) {
@@ -792,6 +794,13 @@ _swrast_write_index_span( GLcontext *ctx, struct sw_span *span)
       }
    }
 
+   /* Depth bounds test */
+   if (ctx->Depth.BoundsTest && ctx->Visual.depthBits > 0) {
+      if (!_swrast_depth_bounds_test(ctx, span)) {
+         return;
+      }
+   }
+
 #ifdef DEBUG
    if (span->arrayMask & SPAN_XY) {
       GLuint i;
@@ -834,6 +843,14 @@ _swrast_write_index_span( GLcontext *ctx, struct sw_span *span)
    /* if we get here, something passed the depth test */
    ctx->OcclusionResult = GL_TRUE;
 
+#if FEATURE_ARB_occlusion_query
+   if (ctx->Occlusion.Active) {
+      GLuint i;
+      for (i = 0; i < span->end; i++)
+         ctx->Occlusion.PassedCounter += span->array->mask[i];
+   }
+#endif
+
    /* we have to wait until after occlusion to do this test */
    if (ctx->Color.DrawBuffer == GL_NONE || ctx->Color.IndexMask == 0) {
       /* write no pixels */
@@ -962,6 +979,13 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span)
       }
    }
 
+   /* Depth bounds test */
+   if (ctx->Depth.BoundsTest && ctx->Visual.depthBits > 0) {
+      if (!_swrast_depth_bounds_test(ctx, span)) {
+         return;
+      }
+   }
+
 #ifdef DEBUG
    if (span->arrayMask & SPAN_XY) {
       GLuint i;
@@ -1032,6 +1056,14 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span)
    /* if we get here, something passed the depth test */
    ctx->OcclusionResult = GL_TRUE;
 
+#if FEATURE_ARB_occlusion_query
+   if (ctx->Occlusion.Active) {
+      GLuint i;
+      for (i = 0; i < span->end; i++)
+         ctx->Occlusion.PassedCounter += span->array->mask[i];
+   }
+#endif
+
    /* can't abort span-writing until after occlusion testing */
    if (colorMask == 0x0) {
       span->interpMask = origInterpMask;
@@ -1068,7 +1100,7 @@ _swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span)
    }
    else {
       /* normal: write to exactly one buffer */
-      if (ctx->Color.ColorLogicOpEnabled) {
+      if (ctx->Color._LogicOpEnabled) {
          _swrast_logicop_rgba_span(ctx, span, span->array->rgba);
          monoColor = GL_FALSE;
       }
@@ -1168,13 +1200,14 @@ _swrast_write_texture_span( GLcontext *ctx, struct sw_span *span)
 {
    const GLuint colorMask = *((GLuint *) ctx->Color.ColorMask);
    SWcontext *swrast = SWRAST_CONTEXT(ctx);
+   const GLuint origInterpMask = span->interpMask;
    const GLuint origArrayMask = span->arrayMask;
 
    ASSERT(span->primitive == GL_POINT  ||  span->primitive == GL_LINE ||
          span->primitive == GL_POLYGON  ||  span->primitive == GL_BITMAP);
    ASSERT(span->end <= MAX_WIDTH);
    ASSERT((span->interpMask & span->arrayMask) == 0);
-   ASSERT(ctx->Texture._EnabledCoordUnits);
+   ASSERT(ctx->Texture._EnabledCoordUnits || ctx->FragmentProgram.Enabled);
 
    /*
    printf("%s()  interp 0x%x  array 0x%x\n", __FUNCTION__, span->interpMask, span->arrayMask);
@@ -1253,6 +1286,7 @@ _swrast_write_texture_span( GLcontext *ctx, struct sw_span *span)
 
       if (ctx->Stencil.Enabled) {
          if (!_swrast_stencil_and_ztest_span(ctx, span)) {
+            span->interpMask = origInterpMask;
             span->arrayMask = origArrayMask;
             return;
          }
@@ -1262,6 +1296,7 @@ _swrast_write_texture_span( GLcontext *ctx, struct sw_span *span)
          ASSERT(span->arrayMask & SPAN_Z);
          /* regular depth testing */
          if (!_swrast_depth_test_span(ctx, span)) {
+            span->interpMask = origInterpMask;
             span->arrayMask = origArrayMask;
             return;
          }
@@ -1271,10 +1306,19 @@ _swrast_write_texture_span( GLcontext *ctx, struct sw_span *span)
    /* if we get here, some fragments passed the depth test */
    ctx->OcclusionResult = GL_TRUE;
 
+#if FEATURE_ARB_occlusion_query
+   if (ctx->Occlusion.Active) {
+      GLuint i;
+      for (i = 0; i < span->end; i++)
+         ctx->Occlusion.PassedCounter += span->array->mask[i];
+   }
+#endif
+
    /* We had to wait until now to check for glColorMask(F,F,F,F) because of
     * the occlusion test.
     */
    if (colorMask == 0x0) {
+      span->interpMask = origInterpMask;
       span->arrayMask = origArrayMask;
       return;
    }
@@ -1329,18 +1373,19 @@ _swrast_write_texture_span( GLcontext *ctx, struct sw_span *span)
    }
    else {
       /* normal: write to exactly one buffer */
-      if (ctx->Color.ColorLogicOpEnabled) {
+      if (ctx->Color._LogicOpEnabled) {
          _swrast_logicop_rgba_span(ctx, span, span->array->rgba);
       }
       else if (ctx->Color.BlendEnabled) {
          _swrast_blend_span(ctx, span, span->array->rgba);
       }
 
+      /* Color component masking */
       if (colorMask != 0xffffffff) {
          _swrast_mask_rgba_span(ctx, span, span->array->rgba);
       }
 
+      /* write pixels */
       if (span->arrayMask & SPAN_XY) {
          /* array of pixel coords */
          (*swrast->Driver.WriteRGBAPixels)(ctx, span->end, span->array->x,
@@ -1365,6 +1410,7 @@ _swrast_write_texture_span( GLcontext *ctx, struct sw_span *span)
       }
    }
 
+   span->interpMask = origInterpMask;
    span->arrayMask = origArrayMask;
 }