summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorJordan Justen <jordan.l.justen@intel.com>2016-05-21 14:21:32 -0700
committerJordan Justen <jordan.l.justen@intel.com>2016-06-01 19:29:02 -0700
commit7b9def35835232a10010f256b9c108219f97f752 (patch)
tree1bbad9392a897a4e09c10cb38e835f0a7ba98ff4 /src/compiler
parent1205999c229b8e67af39fb9875bd87bc0a1404eb (diff)
downloadexternal_mesa3d-7b9def35835232a10010f256b9c108219f97f752.zip
external_mesa3d-7b9def35835232a10010f256b9c108219f97f752.tar.gz
external_mesa3d-7b9def35835232a10010f256b9c108219f97f752.tar.bz2
glsl: Add glsl LowerCsDerivedVariables option
v2: * Move lower flag to context constants. (Ken) Cc: "12.0" <mesa-stable@lists.freedesktop.org> Signed-off-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> (v1) Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/glsl/builtin_variables.cpp29
-rw-r--r--src/compiler/glsl/glsl_parser_extras.cpp2
-rw-r--r--src/compiler/glsl/ir.h3
3 files changed, 21 insertions, 13 deletions
diff --git a/src/compiler/glsl/builtin_variables.cpp b/src/compiler/glsl/builtin_variables.cpp
index 401c713..05b3b0b 100644
--- a/src/compiler/glsl/builtin_variables.cpp
+++ b/src/compiler/glsl/builtin_variables.cpp
@@ -1201,8 +1201,15 @@ builtin_variable_generator::generate_cs_special_vars()
"gl_LocalInvocationID");
add_system_value(SYSTEM_VALUE_WORK_GROUP_ID, uvec3_t, "gl_WorkGroupID");
add_system_value(SYSTEM_VALUE_NUM_WORK_GROUPS, uvec3_t, "gl_NumWorkGroups");
- add_variable("gl_GlobalInvocationID", uvec3_t, ir_var_auto, 0);
- add_variable("gl_LocalInvocationIndex", uint_t, ir_var_auto, 0);
+ if (state->ctx->Const.LowerCsDerivedVariables) {
+ add_variable("gl_GlobalInvocationID", uvec3_t, ir_var_auto, 0);
+ add_variable("gl_LocalInvocationIndex", uint_t, ir_var_auto, 0);
+ } else {
+ add_system_value(SYSTEM_VALUE_GLOBAL_INVOCATION_ID,
+ uvec3_t, "gl_GlobalInvocationID");
+ add_system_value(SYSTEM_VALUE_LOCAL_INVOCATION_INDEX,
+ uint_t, "gl_LocalInvocationIndex");
+ }
}
@@ -1431,16 +1438,16 @@ initialize_cs_derived_variables(gl_shader *shader,
* These are initialized in the main function.
*/
void
-_mesa_glsl_initialize_derived_variables(gl_shader *shader)
+_mesa_glsl_initialize_derived_variables(struct gl_context *ctx,
+ gl_shader *shader)
{
/* We only need to set CS variables currently. */
- if (shader->Stage != MESA_SHADER_COMPUTE)
- return;
+ if (shader->Stage == MESA_SHADER_COMPUTE &&
+ ctx->Const.LowerCsDerivedVariables) {
+ ir_function_signature *const main_sig =
+ _mesa_get_main_function_signature(shader);
- ir_function_signature *const main_sig =
- _mesa_get_main_function_signature(shader);
- if (main_sig == NULL)
- return;
-
- initialize_cs_derived_variables(shader, main_sig);
+ if (main_sig != NULL)
+ initialize_cs_derived_variables(shader, main_sig);
+ }
}
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index 2e3395e..c9654ac 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -1907,7 +1907,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
}
}
- _mesa_glsl_initialize_derived_variables(shader);
+ _mesa_glsl_initialize_derived_variables(ctx, shader);
delete state->symbols;
ralloc_free(state);
diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
index e8efd27..93716c4 100644
--- a/src/compiler/glsl/ir.h
+++ b/src/compiler/glsl/ir.h
@@ -2562,7 +2562,8 @@ _mesa_glsl_initialize_variables(exec_list *instructions,
struct _mesa_glsl_parse_state *state);
extern void
-_mesa_glsl_initialize_derived_variables(gl_shader *shader);
+_mesa_glsl_initialize_derived_variables(struct gl_context *ctx,
+ gl_shader *shader);
extern void
_mesa_glsl_initialize_functions(_mesa_glsl_parse_state *state);