[Mesa-dev] [PATCH 06/12] meta: Stop frobbing MatrixMode

Ian Romanick idr at freedesktop.org
Mon Jun 26 23:22:39 UTC 2017


From: Ian Romanick <ian.d.romanick at intel.com>

   text	   data	    bss	    dec	    hex	filename
7155246	 256860	  37332	7449438	 71ab5e	32-bit i965_dri.so before
7155058	 256860	  37332	7449250	 71aaa2	32-bit i965_dri.so after
6788683	 328056	  50704	7167443	 6d5dd3	64-bit i965_dri.so before
6788611	 328056	  50704	7167371	 6d5d8b	64-bit i965_dri.so after

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/mesa/drivers/common/meta.c | 47 ++++++++++++++++--------------------------
 src/mesa/drivers/common/meta.h |  1 -
 2 files changed, 18 insertions(+), 30 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 58e28bd..9095caf 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -655,31 +655,31 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
    }
 
    if (state & MESA_META_TRANSFORM) {
-      GLuint activeTexture = ctx->Texture.CurrentUnit;
       memcpy(save->ModelviewMatrix, ctx->ModelviewMatrixStack.Top->m,
              16 * sizeof(GLfloat));
       memcpy(save->ProjectionMatrix, ctx->ProjectionMatrixStack.Top->m,
              16 * sizeof(GLfloat));
       memcpy(save->TextureMatrix, ctx->TextureMatrixStack[0].Top->m,
              16 * sizeof(GLfloat));
-      save->MatrixMode = ctx->Transform.MatrixMode;
+
       /* set 1:1 vertex:pixel coordinate transform */
-      _mesa_ActiveTexture(GL_TEXTURE0);
-      _mesa_MatrixMode(GL_TEXTURE);
-      _mesa_LoadIdentity();
-      _mesa_ActiveTexture(GL_TEXTURE0 + activeTexture);
-      _mesa_MatrixMode(GL_MODELVIEW);
-      _mesa_LoadIdentity();
-      _mesa_MatrixMode(GL_PROJECTION);
-      _mesa_LoadIdentity();
+      _mesa_load_identity_matrix(ctx, &ctx->ModelviewMatrixStack);
+      _mesa_load_identity_matrix(ctx, &ctx->ProjectionMatrixStack);
+      _mesa_load_identity_matrix(ctx, &ctx->TextureMatrixStack[0]);
 
       /* glOrtho with width = 0 or height = 0 generates GL_INVALID_VALUE.
        * This can occur when there is no draw buffer.
        */
-      if (ctx->DrawBuffer->Width != 0 && ctx->DrawBuffer->Height != 0)
-         _mesa_Ortho(0.0, ctx->DrawBuffer->Width,
-                     0.0, ctx->DrawBuffer->Height,
-                     -1.0, 1.0);
+      if (ctx->DrawBuffer->Width != 0 && ctx->DrawBuffer->Height != 0) {
+         /* Don't FLUSH_VERTICES here because _mesa_load_identity_matrix will
+          * have already done it.
+          */
+         _math_matrix_ortho(ctx->ProjectionMatrixStack.Top,
+                            0.0f, (GLfloat) ctx->DrawBuffer->Width,
+                            0.0f, (GLfloat) ctx->DrawBuffer->Height,
+                            -1.0f, 1.0f);
+         ctx->NewState |= ctx->ProjectionMatrixStack.DirtyFlag;
+      }
 
       if (ctx->Extensions.ARB_clip_control) {
          save->ClipOrigin = ctx->Transform.ClipOrigin;
@@ -1066,19 +1066,9 @@ _mesa_meta_end(struct gl_context *ctx)
    }
 
    if (state & MESA_META_TRANSFORM) {
-      GLuint activeTexture = ctx->Texture.CurrentUnit;
-      _mesa_ActiveTexture(GL_TEXTURE0);
-      _mesa_MatrixMode(GL_TEXTURE);
-      _mesa_LoadMatrixf(save->TextureMatrix);
-      _mesa_ActiveTexture(GL_TEXTURE0 + activeTexture);
-
-      _mesa_MatrixMode(GL_MODELVIEW);
-      _mesa_LoadMatrixf(save->ModelviewMatrix);
-
-      _mesa_MatrixMode(GL_PROJECTION);
-      _mesa_LoadMatrixf(save->ProjectionMatrix);
-
-      _mesa_MatrixMode(save->MatrixMode);
+      _mesa_load_matrix(ctx, &ctx->ModelviewMatrixStack, save->ModelviewMatrix);
+      _mesa_load_matrix(ctx, &ctx->ProjectionMatrixStack, save->ProjectionMatrix);
+      _mesa_load_matrix(ctx, &ctx->TextureMatrixStack[0], save->TextureMatrix);
 
       if (ctx->Extensions.ARB_clip_control)
          _mesa_ClipControl(save->ClipOrigin, save->ClipDepthMode);
@@ -1455,8 +1445,7 @@ _mesa_meta_setup_ff_tnl_for_blit(struct gl_context *ctx,
                                    0);
 
    /* setup projection matrix */
-   _mesa_MatrixMode(GL_PROJECTION);
-   _mesa_LoadIdentity();
+   _mesa_load_identity_matrix(ctx, &ctx->ProjectionMatrixStack);
 }
 
 /**
diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h
index c09cb3e..fa84995 100644
--- a/src/mesa/drivers/common/meta.h
+++ b/src/mesa/drivers/common/meta.h
@@ -133,7 +133,6 @@ struct save_state
    struct gl_stencil_attrib Stencil;
 
    /** MESA_META_TRANSFORM */
-   GLenum MatrixMode;
    GLfloat ModelviewMatrix[16];
    GLfloat ProjectionMatrix[16];
    GLfloat TextureMatrix[16];
-- 
2.9.4



More information about the mesa-dev mailing list