Mesa (master): glsl: Add context-level controls for whether temporaries have real names

Ian Romanick idr at kemper.freedesktop.org
Tue Sep 30 20:35:11 UTC 2014


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

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Tue Jul  8 18:55:27 2014 -0700

glsl: Add context-level controls for whether temporaries have real names

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

v2: Minor rebase on _mesa_init_constants changes.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Matt Turner <mattst88 at gmail.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 b7e8728..0edd66d 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -645,6 +645,12 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api)
    consts->GLSLVersion = 120;
    _mesa_override_glsl_version(consts);
 
+#ifdef DEBUG
+   consts->GenerateTemporaryNames = true;
+#else
+   consts->GenerateTemporaryNames = false;
+#endif
+
    /* GL_ARB_framebuffer_object */
    consts->MaxSamples = 0;
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index b66b1a8..dd330ea 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3571,6 +3571,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 30a7519..3e6f610 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);




More information about the mesa-commit mailing list