Merge branch 'mesa_7_5_branch' into mesa_7_6_branch
[mesa.git] / src / mesa / drivers / common / meta.c
index ec0da71fb9568e2b81352b2ab359a6f5760ff45f..28e49b68983c92381a714056e1df40279a82c866 100644 (file)
@@ -1429,6 +1429,7 @@ _mesa_meta_draw_pixels(GLcontext *ctx,
    struct drawpix_state *drawpix = &ctx->Meta->DrawPix;
    struct temp_texture *tex = get_temp_texture(ctx);
    const struct gl_pixelstore_attrib unpackSave = ctx->Unpack;
+   const GLuint origStencilMask = ctx->Stencil.WriteMask[0];
    GLfloat verts[4][5]; /* four verts of X,Y,Z,S,T */
    GLenum texIntFormat;
    GLboolean fallback, newTex;
@@ -1445,7 +1446,10 @@ _mesa_meta_draw_pixels(GLcontext *ctx,
 
    if (_mesa_is_color_format(format)) {
       /* use more compact format when possible */
-      if (format == GL_LUMINANCE || format == GL_LUMINANCE_ALPHA)
+      /* XXX disable special case for GL_LUMINANCE for now to work around
+       * apparent i965 driver bug (see bug #23670).
+       */
+      if (/*format == GL_LUMINANCE ||*/ format == GL_LUMINANCE_ALPHA)
          texIntFormat = format;
       else
          texIntFormat = GL_RGBA;
@@ -1593,14 +1597,15 @@ _mesa_meta_draw_pixels(GLcontext *ctx,
 
       for (bit = 0; bit < ctx->Visual.stencilBits; bit++) {
          const GLuint mask = 1 << bit;
+         if (mask & origStencilMask) {
+            _mesa_StencilFunc(GL_ALWAYS, mask, mask);
+            _mesa_StencilMask(mask);
 
-         _mesa_StencilFunc(GL_ALWAYS, mask, mask);
-         _mesa_StencilMask(mask);
-
-         _mesa_ProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0,
-                                          255.0 / mask, 0.5, 0.0, 0.0);
+            _mesa_ProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0,
+                                             255.0 / mask, 0.5, 0.0, 0.0);
 
-         _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
+            _mesa_DrawArrays(GL_TRIANGLE_FAN, 0, 4);
+         }
       }
    }
    else if (_mesa_is_depth_format(format)) {