intel: Fix some state leakage of {Client,}ActiveTexture in metaops.
authorEric Anholt <eric@anholt.net>
Mon, 9 Feb 2009 14:25:30 +0000 (15:25 +0100)
committerEric Anholt <eric@anholt.net>
Wed, 11 Feb 2009 02:45:17 +0000 (18:45 -0800)
Found while debugging cairo-gl.

src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
src/mesa/drivers/dri/intel/intel_pixel_draw.c

index 3a01f63dc72e7054bc086262fbde87987f9a7165..1db7f5594e9dd3849c242621071cce19692d748b 100644 (file)
@@ -495,6 +495,7 @@ intel_texture_bitmap(GLcontext * ctx,
    texcoords[3][1] = 1.0;
 
    _mesa_VertexPointer(4, GL_FLOAT, 4 * sizeof(GLfloat), &vertices);
+   _mesa_ClientActiveTextureARB(GL_TEXTURE0);
    _mesa_TexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), &texcoords);
    _mesa_Enable(GL_VERTEX_ARRAY);
    _mesa_Enable(GL_TEXTURE_COORD_ARRAY);
index bb36649dacde68690f06814c4a4ced704bbc9df5..0c9cf08ab9ce6465372bf3d42841cfaf8d17d59d 100644 (file)
@@ -72,6 +72,7 @@ intel_texture_drawpixels(GLcontext * ctx,
    GLfloat vertices[4][4];
    GLfloat texcoords[4][2];
    GLfloat z;
+   GLint old_active_texture;
 
    /* We're going to mess with texturing with no regard to existing texture
     * state, so if there is some set up we have to bail.
@@ -125,6 +126,7 @@ intel_texture_drawpixels(GLcontext * ctx,
    /* XXX: pixel store stuff */
    _mesa_Disable(GL_POLYGON_STIPPLE);
 
+   old_active_texture = ctx->Texture.CurrentUnit;
    _mesa_ActiveTextureARB(GL_TEXTURE0_ARB);
    _mesa_Enable(GL_TEXTURE_2D);
    _mesa_GenTextures(1, &texname);
@@ -176,12 +178,15 @@ intel_texture_drawpixels(GLcontext * ctx,
    texcoords[3][1] = 1.0;
 
    _mesa_VertexPointer(4, GL_FLOAT, 4 * sizeof(GLfloat), &vertices);
+   _mesa_ClientActiveTextureARB(GL_TEXTURE0);
    _mesa_TexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), &texcoords);
    _mesa_Enable(GL_VERTEX_ARRAY);
    _mesa_Enable(GL_TEXTURE_COORD_ARRAY);
    CALL_DrawArrays(ctx->Exec, (GL_TRIANGLE_FAN, 0, 4));
 
    intel_meta_restore_transform(intel);
+
+   _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + old_active_texture);
    _mesa_PopClientAttrib();
    _mesa_PopAttrib();
 
@@ -209,6 +214,7 @@ intel_stencil_drawpixels(GLcontext * ctx,
    struct gl_pixelstore_attrib old_unpack;
    GLstencil *stencil_pixels;
    int row;
+   GLint old_active_texture;
 
    if (format != GL_STENCIL_INDEX)
       return GL_FALSE;
@@ -270,6 +276,7 @@ intel_stencil_drawpixels(GLcontext * ctx,
                    GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    _mesa_PushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
    old_fb_name = ctx->DrawBuffer->Name;
+   old_active_texture = ctx->Texture.CurrentUnit;
 
    _mesa_Disable(GL_POLYGON_STIPPLE);
    _mesa_Disable(GL_DEPTH_TEST);
@@ -355,6 +362,7 @@ intel_stencil_drawpixels(GLcontext * ctx,
    texcoords[3][1] = 1.0;
 
    _mesa_VertexPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), &vertices);
+   _mesa_ClientActiveTextureARB(GL_TEXTURE0);
    _mesa_TexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), &texcoords);
    _mesa_Enable(GL_VERTEX_ARRAY);
    _mesa_Enable(GL_TEXTURE_COORD_ARRAY);
@@ -362,6 +370,7 @@ intel_stencil_drawpixels(GLcontext * ctx,
 
    intel_meta_restore_transform(intel);
 
+   _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + old_active_texture);
    _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, old_fb_name);
 
    _mesa_PopClientAttrib();