diff options
author | Jordan Justen <[email protected]> | 2015-08-17 12:30:25 -0700 |
---|---|---|
committer | Jordan Justen <[email protected]> | 2015-09-13 09:53:16 -0700 |
commit | 34e187ec38cee78fbc0e1d1a09a99160fbdf7a9f (patch) | |
tree | 3dcccb76e970a1eb1b9992c9b6460d17b38eaf30 /src | |
parent | c5743a5d7fa62a339222ceb96d568a525d77fe0c (diff) |
glsl/cs: Don't strip gl_GlobalInvocationID and dependencies
We lower gl_GlobalInvocationID based on the extension spec formula:
gl_GlobalInvocationID =
gl_WorkGroupID * gl_WorkGroupSize + gl_LocalInvocationID
https://www.opengl.org/registry/specs/ARB/compute_shader.txt
We need to set this variable in main(), even if gl_GlobalInvocationID
is not referenced by the shader. (It may be used by a linked shader.)
Therefore, we can't eliminate these as dead variables.
Signed-off-by: Jordan Justen <[email protected]>
Reviewed-by: Tapani Pälli <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/glsl/opt_dead_builtin_variables.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/glsl/opt_dead_builtin_variables.cpp b/src/glsl/opt_dead_builtin_variables.cpp index 0d4e3a8f00a..90b753e012c 100644 --- a/src/glsl/opt_dead_builtin_variables.cpp +++ b/src/glsl/opt_dead_builtin_variables.cpp @@ -62,6 +62,16 @@ optimize_dead_builtin_variables(exec_list *instructions, * information, so removing these variables from the user shader will * cause problems later. * + * For compute shaders, gl_GlobalInvocationID has some dependencies, so + * we avoid removing these dependencies. + * + * We also avoid removing gl_GlobalInvocationID at this stage because it + * might be used by a linked shader. In this case it still needs to be + * initialized by the main function. + * + * gl_GlobalInvocationID = + * gl_WorkGroupID * gl_WorkGroupSize + gl_LocalInvocationID + * * 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 @@ -73,6 +83,10 @@ optimize_dead_builtin_variables(exec_list *instructions, */ if (strcmp(var->name, "gl_ModelViewProjectionMatrix") == 0 || strcmp(var->name, "gl_Vertex") == 0 + || strcmp(var->name, "gl_WorkGroupID") == 0 + || strcmp(var->name, "gl_WorkGroupSize") == 0 + || strcmp(var->name, "gl_LocalInvocationID") == 0 + || strcmp(var->name, "gl_GlobalInvocationID") == 0 || strstr(var->name, "Transpose") != NULL) continue; |