[Mesa-dev] [PATCH 16/26] glsl: Add context-level controls for whether temporaries have real names

Ian Romanick idr at freedesktop.org
Mon Jul 14 15:48:48 PDT 2014


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

No change Valgrind massif results for a trimmed apitrace of dota2.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/glsl/main.cpp         |  1 +
 src/mesa/main/context.c   |  6 ++++++
 src/mesa/main/mtypes.h    | 13 +++++++++++++
 src/mesa/main/shaderapi.c |  3 +++
 4 files changed, 23 insertions(+)

diff --git a/src/glsl/main.cpp b/src/glsl/main.cpp
index a4452e0..feed100 100644
--- a/src/glsl/main.cpp
+++ b/src/glsl/main.cpp
@@ -210,6 +210,7 @@ initialize_context(struct gl_context *ctx, gl_api api)
       break;
    }
 
+   ctx->Const.GenerateTemporaryNames = true;
    ctx->Driver.NewShader = _mesa_new_shader;
 }
 
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 50aae8b..562abf7 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -650,6 +650,12 @@ _mesa_init_constants(struct gl_context *ctx)
       ctx->Const.GLSLVersion = 0; /* GLSL not supported */
    }
 
+#ifdef DEBUG
+   ctx->Const.GenerateTemporaryNames = true;
+#else
+   ctx->Const.GenerateTemporaryNames = false;
+#endif
+
    /* GL_ARB_framebuffer_object */
    ctx->Const.MaxSamples = 0;
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index b699021..2025fd0 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3455,6 +3455,19 @@ struct gl_constants
     */
    GLboolean DisableVaryingPacking;
 
+   /**
+    * Should meaningful names be generated for compiler temporary variables?
+    *
+    * Generally, it is not useful to have the compiler generate "meaningful"
+    * names for temporary variables that it creates.  This can, however, be a
+    * useful debugging aid.  In Mesa debug builds or release builds when
+    * MESA_GLSL is set at run-time, meaningful names will be generated.
+    * Drivers can also force names to be generated by setting this field.
+    * For example, the i965 driver may set it when INTEL_DEBUG=vs (to dump
+    * vertex shader assembly) is set at run-time.
+    */
+   bool GenerateTemporaryNames;
+
    /*
     * Maximum value supported for an index in DrawElements and friends.
     *
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 2bbef35..6c74583 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -123,6 +123,9 @@ _mesa_init_shader_state(struct gl_context *ctx)
 
    ctx->Shader.Flags = _mesa_get_shader_flags();
 
+   if (ctx->Shader.Flags != 0)
+      ctx->Const.GenerateTemporaryNames = true;
+
    /* Extended for ARB_separate_shader_objects */
    ctx->Shader.RefCount = 1;
    mtx_init(&ctx->Shader.Mutex, mtx_plain);
-- 
1.8.1.4



More information about the mesa-dev mailing list