diff options
author | Jordan Justen <[email protected]> | 2015-08-17 15:49:44 -0700 |
---|---|---|
committer | Jordan Justen <[email protected]> | 2015-09-13 09:53:16 -0700 |
commit | 6823e12d5aa4646fc8ef0e32455104ba47f80a38 (patch) | |
tree | 1a49041f7ab7e32a4a1884b762f92f8afb727fb4 /src/glsl | |
parent | 2b6cc0395be4c3eb1c60c0d7a413e368b5ae3dbf (diff) |
glsl/cs: Exclude gl_LocalInvocationIndex from builtin variable stripping
We lower gl_LocalInvocationIndex based on the extension spec formula:
gl_LocalInvocationIndex =
gl_LocalInvocationID.z * gl_WorkGroupSize.x * gl_WorkGroupSize.y +
gl_LocalInvocationID.y * gl_WorkGroupSize.x +
gl_LocalInvocationID.x;
https://www.opengl.org/registry/specs/ARB/compute_shader.txt
We need to set this variable in main(), even if gl_LocalInvocationIndex
is not referenced by the shader. (It may be used by a linked shader.)
Therefore, we can't eliminate it as a dead variable.
Signed-off-by: Jordan Justen <[email protected]>
Reviewed-by: Tapani Pälli <[email protected]>
Diffstat (limited to 'src/glsl')
-rw-r--r-- | src/glsl/opt_dead_builtin_variables.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/glsl/opt_dead_builtin_variables.cpp b/src/glsl/opt_dead_builtin_variables.cpp index 90b753e012c..03e578982b9 100644 --- a/src/glsl/opt_dead_builtin_variables.cpp +++ b/src/glsl/opt_dead_builtin_variables.cpp @@ -72,6 +72,13 @@ optimize_dead_builtin_variables(exec_list *instructions, * gl_GlobalInvocationID = * gl_WorkGroupID * gl_WorkGroupSize + gl_LocalInvocationID * + * Similarly, we initialize gl_LocalInvocationIndex in the main function: + * + * gl_LocalInvocationIndex = + * gl_LocalInvocationID.z * gl_WorkGroupSize.x * gl_WorkGroupSize.y + + * gl_LocalInvocationID.y * gl_WorkGroupSize.x + + * gl_LocalInvocationID.x; + * * Matrix uniforms with "Transpose" are not eliminated because there's * an optimization pass that can turn references to the regular matrix * into references to the transpose matrix. Eliminating the transpose @@ -87,6 +94,7 @@ optimize_dead_builtin_variables(exec_list *instructions, || strcmp(var->name, "gl_WorkGroupSize") == 0 || strcmp(var->name, "gl_LocalInvocationID") == 0 || strcmp(var->name, "gl_GlobalInvocationID") == 0 + || strcmp(var->name, "gl_LocalInvocationIndex") == 0 || strstr(var->name, "Transpose") != NULL) continue; |