diff options
Diffstat (limited to 'src/glsl')
-rw-r--r-- | src/glsl/glsl_parser_extras.cpp | 3 | ||||
-rw-r--r-- | src/glsl/ir.cpp | 5 | ||||
-rw-r--r-- | src/glsl/ir.h | 19 | ||||
-rw-r--r-- | src/glsl/test_optpass.cpp | 1 |
4 files changed, 28 insertions, 0 deletions
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 5005cff9d67..cc7d2d746ff 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -1440,6 +1440,9 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader, new(shader) _mesa_glsl_parse_state(ctx, shader->Stage, shader); const char *source = shader->Source; + if (ctx->Const.GenerateTemporaryNames) + ir_variable::temporaries_allocate_names = true; + state->error = glcpp_preprocess(state, &source, &state->info_log, &ctx->Extensions, ctx); diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp index 9c58f869dc4..c712c6a7bd9 100644 --- a/src/glsl/ir.cpp +++ b/src/glsl/ir.cpp @@ -1543,6 +1543,8 @@ ir_swizzle::variable_referenced() const } +bool ir_variable::temporaries_allocate_names = false; + const char ir_variable::tmp_name[] = "compiler_temp"; ir_variable::ir_variable(const struct glsl_type *type, const char *name, @@ -1551,6 +1553,9 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name, { this->type = type; + if (mode == ir_var_temporary && !ir_variable::temporaries_allocate_names) + name = NULL; + /* The ir_variable clone method may call this constructor with name set to * tmp_name. */ diff --git a/src/glsl/ir.h b/src/glsl/ir.h index 3c947412f40..90c443c3d45 100644 --- a/src/glsl/ir.h +++ b/src/glsl/ir.h @@ -896,6 +896,25 @@ private: * Name used for anonymous compiler temporaries */ static const char tmp_name[]; + +public: + /** + * Should the construct keep names for ir_var_temporary variables? + * + * When this global is false, names passed to the constructor for + * \c ir_var_temporary variables will be dropped. Instead, the variable will + * be named "compiler_temp". This name will be in static storage. + * + * \warning + * \b NEVER change the mode of an \c ir_var_temporary. + * + * \warning + * This variable is \b not thread-safe. It is global, \b not + * per-context. It begins life false. A context can, at some point, make + * it true. From that point on, it will be true forever. This should be + * okay since it will only be set true while debugging. + */ + static bool temporaries_allocate_names; }; /** diff --git a/src/glsl/test_optpass.cpp b/src/glsl/test_optpass.cpp index 24c06f11b14..ac3e3f48c51 100644 --- a/src/glsl/test_optpass.cpp +++ b/src/glsl/test_optpass.cpp @@ -200,6 +200,7 @@ int test_optpass(int argc, char **argv) initialize_context_to_defaults(ctx, API_OPENGL_COMPAT); ctx->Driver.NewShader = _mesa_new_shader; + ir_variable::temporaries_allocate_names = true; struct gl_shader *shader = rzalloc(NULL, struct gl_shader); shader->Type = shader_type; |