[Mesa-dev] [PATCH 5/7] mesa: restrict UseProgram env var to debug builds
Timothy Arceri
tarceri at itsqueeze.com
Thu May 4 01:19:52 UTC 2017
I can't think of any reason you would want this in a release
build.
---
src/mesa/main/shaderapi.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index c41f006..b764fee 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -78,22 +78,24 @@ _mesa_get_shader_flags(void)
if (strstr(env, "log"))
flags |= GLSL_LOG;
if (strstr(env, "cache_info"))
flags |= GLSL_CACHE_INFO;
if (strstr(env, "nopvert"))
flags |= GLSL_NOP_VERT;
if (strstr(env, "nopfrag"))
flags |= GLSL_NOP_FRAG;
if (strstr(env, "uniform"))
flags |= GLSL_UNIFORMS;
+#ifdef DEBUG
if (strstr(env, "useprog"))
flags |= GLSL_USE_PROG;
+#endif
if (strstr(env, "errors"))
flags |= GLSL_REPORT_ERRORS;
}
return flags;
}
/**
* Memoized version of getenv("MESA_SHADER_CAPTURE_PATH").
*/
@@ -1181,55 +1183,50 @@ _mesa_link_program(struct gl_context *ctx, struct gl_shader_program *shProg)
shProg->Shaders[i]->Name,
shProg->Shaders[i]->Stage);
}
}
}
/**
* Print basic shader info (for debug).
*/
+#ifdef DEBUG
static void
print_shader_info(const struct gl_shader_program *shProg)
{
GLuint i;
printf("Mesa: glUseProgram(%u)\n", shProg->Name);
for (i = 0; i < shProg->NumShaders; i++) {
-#ifdef DEBUG
printf(" %s shader %u, checksum %u\n",
_mesa_shader_stage_to_string(shProg->Shaders[i]->Stage),
shProg->Shaders[i]->Name,
shProg->Shaders[i]->SourceChecksum);
-#else
- printf(" %s shader %u\n",
- _mesa_shader_stage_to_string(shProg->Shaders[i]->Stage),
- shProg->Shaders[i]->Name);
-#endif
}
if (shProg->_LinkedShaders[MESA_SHADER_VERTEX])
printf(" vert prog %u\n",
shProg->_LinkedShaders[MESA_SHADER_VERTEX]->Program->Id);
if (shProg->_LinkedShaders[MESA_SHADER_FRAGMENT])
printf(" frag prog %u\n",
shProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program->Id);
if (shProg->_LinkedShaders[MESA_SHADER_GEOMETRY])
printf(" geom prog %u\n",
shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program->Id);
if (shProg->_LinkedShaders[MESA_SHADER_TESS_CTRL])
printf(" tesc prog %u\n",
shProg->_LinkedShaders[MESA_SHADER_TESS_CTRL]->Program->Id);
if (shProg->_LinkedShaders[MESA_SHADER_TESS_EVAL])
printf(" tese prog %u\n",
shProg->_LinkedShaders[MESA_SHADER_TESS_EVAL]->Program->Id);
}
-
+#endif
/**
* Use the named shader program for subsequent glUniform calls
*/
void
_mesa_active_program(struct gl_context *ctx, struct gl_shader_program *shProg,
const char *caller)
{
if ((shProg != NULL) && !shProg->data->LinkStatus) {
_mesa_error(ctx, GL_INVALID_OPERATION,
@@ -1871,24 +1868,25 @@ _mesa_UseProgram(GLuint program)
shProg = _mesa_lookup_shader_program_err(ctx, program, "glUseProgram");
if (!shProg) {
return;
}
if (!shProg->data->LinkStatus) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glUseProgram(program %u not linked)", program);
return;
}
- /* debug code */
+#ifdef DEBUG
if (ctx->_Shader->Flags & GLSL_USE_PROG) {
print_shader_info(shProg);
}
+#endif
}
else {
shProg = NULL;
}
/* The ARB_separate_shader_object spec says:
*
* "The executable code for an individual shader stage is taken from
* the current program for that stage. If there is a current program
* object established by UseProgram, that program is considered current
--
2.9.3
More information about the mesa-dev
mailing list