Mesa (master): mesa: save/restore texture matrix in meta code

Brian Paul brianp at kemper.freedesktop.org
Mon Aug 10 21:48:59 UTC 2009


Module: Mesa
Branch: master
Commit: edb991b7bcb1ed6c3ad352750c6613672039a901
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=edb991b7bcb1ed6c3ad352750c6613672039a901

Author: Brian Paul <brianp at vmware.com>
Date:   Mon Aug 10 15:44:05 2009 -0600

mesa: save/restore texture matrix in meta code

Also, save/restore viewport and texture state in _mesa_meta_copy_pixels()

---

 src/mesa/drivers/common/meta.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index a7eba2e..56ad8f8 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -105,6 +105,7 @@ struct save_state
    GLenum MatrixMode;
    GLfloat ModelviewMatrix[16];
    GLfloat ProjectionMatrix[16];
+   GLfloat TextureMatrix[16];
    GLbitfield ClipPlanesEnabled;
 
    /** META_TEXTURE */
@@ -363,12 +364,19 @@ _mesa_meta_begin(GLcontext *ctx, GLbitfield state)
    }
 
    if (state & META_TRANSFORM) {
+      GLuint activeTexture = ctx->Texture.CurrentUnit;
       _mesa_memcpy(save->ModelviewMatrix, ctx->ModelviewMatrixStack.Top->m,
                    16 * sizeof(GLfloat));
       _mesa_memcpy(save->ProjectionMatrix, ctx->ProjectionMatrixStack.Top->m,
                    16 * sizeof(GLfloat));
+      _mesa_memcpy(save->TextureMatrix, ctx->TextureMatrixStack[0].Top->m,
+                   16 * sizeof(GLfloat));
       save->MatrixMode = ctx->Transform.MatrixMode;
       /* set 1:1 vertex:pixel coordinate transform */
+      _mesa_ActiveTextureARB(GL_TEXTURE0);
+      _mesa_MatrixMode(GL_TEXTURE);
+      _mesa_LoadIdentity();
+      _mesa_ActiveTextureARB(GL_TEXTURE0 + activeTexture);
       _mesa_MatrixMode(GL_MODELVIEW);
       _mesa_LoadIdentity();
       _mesa_MatrixMode(GL_PROJECTION);
@@ -569,11 +577,20 @@ _mesa_meta_end(GLcontext *ctx)
    }
 
    if (state & META_TRANSFORM) {
+      GLuint activeTexture = ctx->Texture.CurrentUnit;
+      _mesa_ActiveTextureARB(GL_TEXTURE0);
+      _mesa_MatrixMode(GL_TEXTURE);
+      _mesa_LoadMatrixf(save->TextureMatrix);
+      _mesa_ActiveTextureARB(GL_TEXTURE0 + activeTexture);
+
       _mesa_MatrixMode(GL_MODELVIEW);
       _mesa_LoadMatrixf(save->ModelviewMatrix);
+
       _mesa_MatrixMode(GL_PROJECTION);
       _mesa_LoadMatrixf(save->ProjectionMatrix);
+
       _mesa_MatrixMode(save->MatrixMode);
+
       save->ClipPlanesEnabled = ctx->Transform.ClipPlanesEnabled;
       if (save->ClipPlanesEnabled) {
          GLuint i;
@@ -890,8 +907,10 @@ _mesa_meta_copy_pixels(GLcontext *ctx, GLint srcX, GLint srcY,
     */
    _mesa_meta_begin(ctx, (META_RASTERIZATION |
                           META_SHADER |
+                          META_TEXTURE |
                           META_TRANSFORM |
-                          META_VERTEX));
+                          META_VERTEX |
+                          META_VIEWPORT));
 
    if (copypix->TexObj == 0) {
       /* one-time setup */




More information about the mesa-commit mailing list