Mesa (master): intel: Fix some state leakage of {Client, }ActiveTexture in metaops.
Eric Anholt
anholt at kemper.freedesktop.org
Wed Feb 11 02:45:36 UTC 2009
Module: Mesa
Branch: master
Commit: d11981e0d722282894b5012d37b2960ee3fbfac2
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d11981e0d722282894b5012d37b2960ee3fbfac2
Author: Eric Anholt <eric at anholt.net>
Date: Mon Feb 9 15:25:30 2009 +0100
intel: Fix some state leakage of {Client,}ActiveTexture in metaops.
Found while debugging cairo-gl.
---
src/mesa/drivers/dri/intel/intel_pixel_bitmap.c | 1 +
src/mesa/drivers/dri/intel/intel_pixel_draw.c | 9 +++++++++
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
index 3a01f63..1db7f55 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
+++ b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
@@ -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);
diff --git a/src/mesa/drivers/dri/intel/intel_pixel_draw.c b/src/mesa/drivers/dri/intel/intel_pixel_draw.c
index bb36649..0c9cf08 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel_draw.c
+++ b/src/mesa/drivers/dri/intel/intel_pixel_draw.c
@@ -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();
More information about the mesa-commit
mailing list