mesa: move gl_texture_image::Width/Height/DepthScale fields to swrast
[mesa.git] / src / mesa / swrast / s_span.c
index 3240b1357743961443ebf8b96bab862c1f3d9ea4..4631ff3d5eea5bb88714c2205158b9d58e9970bd 100644 (file)
@@ -212,10 +212,10 @@ interpolate_active_attribs(struct gl_context *ctx, SWspan *span, GLbitfield attr
 static INLINE void
 interpolate_int_colors(struct gl_context *ctx, SWspan *span)
 {
+#if CHAN_BITS != 32
    const GLuint n = span->end;
    GLuint i;
 
-#if CHAN_BITS != 32
    ASSERT(!(span->arrayMask & SPAN_RGBA));
 #endif
 
@@ -299,7 +299,8 @@ interpolate_int_colors(struct gl_context *ctx, SWspan *span)
       interpolate_active_attribs(ctx, span, FRAG_BIT_COL0);
       break;
    default:
-      _mesa_problem(NULL, "bad datatype in interpolate_int_colors");
+      _mesa_problem(ctx, "bad datatype 0x%x in interpolate_int_colors",
+                    span->array->ChanType);
    }
    span->arrayMask |= SPAN_RGBA;
 }
@@ -489,10 +490,20 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span)
 
          if (obj) {
             const struct gl_texture_image *img = obj->Image[0][obj->BaseLevel];
-            needLambda = (obj->MinFilter != obj->MagFilter)
+            const struct swrast_texture_image *swImg =
+               swrast_texture_image_const(img);
+
+            needLambda = (obj->Sampler.MinFilter != obj->Sampler.MagFilter)
                || ctx->FragmentProgram._Current;
-            texW = img->WidthScale;
-            texH = img->HeightScale;
+            /* LOD is calculated directly in the ansiotropic filter, we can
+             * skip the normal lambda function as the result is ignored.
+             */
+            if (obj->Sampler.MaxAnisotropy > 1.0 &&
+                obj->Sampler.MinFilter == GL_LINEAR_MIPMAP_LINEAR) {
+               needLambda = GL_FALSE;
+            }
+            texW = swImg->WidthScale;
+            texH = swImg->HeightScale;
          }
          else {
             /* using a fragment program */
@@ -953,17 +964,6 @@ convert_color_type(SWspan *span, GLenum newType, GLuint output)
 static INLINE void
 shade_texture_span(struct gl_context *ctx, SWspan *span)
 {
-   GLbitfield inputsRead;
-
-   /* Determine which fragment attributes are actually needed */
-   if (ctx->FragmentProgram._Current) {
-      inputsRead = ctx->FragmentProgram._Current->Base.InputsRead;
-   }
-   else {
-      /* XXX we could be a bit smarter about this */
-      inputsRead = ~0;
-   }
-
    if (ctx->FragmentProgram._Current ||
        ctx->ATIFragmentShader._Enabled) {
       /* programmable shading */
@@ -1251,7 +1251,7 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span)
             ASSERT(rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB ||
                   rb->_BaseFormat == GL_ALPHA);
 
-            if (ctx->Color._LogicOpEnabled) {
+            if (ctx->Color.ColorLogicOpEnabled) {
                _swrast_logicop_rgba_span(ctx, rb, span);
             }
             else if ((ctx->Color.BlendEnabled >> buf) & 1) {
@@ -1347,7 +1347,13 @@ _swrast_read_rgba_span( struct gl_context *ctx, struct gl_renderbuffer *rb,
 
       ASSERT(rb);
       ASSERT(rb->GetRow);
-      ASSERT(rb->_BaseFormat == GL_RGB || rb->_BaseFormat == GL_RGBA ||
+      ASSERT(rb->_BaseFormat == GL_RGBA ||
+            rb->_BaseFormat == GL_RGB ||
+            rb->_BaseFormat == GL_RG ||
+            rb->_BaseFormat == GL_RED ||
+            rb->_BaseFormat == GL_LUMINANCE ||
+            rb->_BaseFormat == GL_INTENSITY ||
+            rb->_BaseFormat == GL_LUMINANCE_ALPHA ||
             rb->_BaseFormat == GL_ALPHA);
 
       if (rb->DataType == dstType) {