[Mesa-dev] [PATCH 1/2] glsl/cs: Exclude gl_LocalInvocationIndex from builtin variable stripping
Tapani Pälli
tapani.palli at intel.com
Tue Sep 8 22:20:37 PDT 2015
These 2 patches are
Reviewed-by: Tapani Pälli <tapani.palli at intel.com>
On 08/23/2015 11:50 AM, Jordan Justen wrote:
> 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 <jordan.l.justen at intel.com>
> ---
> git://people.freedesktop.org/~jljusten/mesa cs-local-index-v1
> http://patchwork.freedesktop.org/bundle/jljusten/cs-local-index-v1
>
> src/glsl/opt_dead_builtin_variables.cpp | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/src/glsl/opt_dead_builtin_variables.cpp b/src/glsl/opt_dead_builtin_variables.cpp
> index 90b753e..03e5789 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;
>
More information about the mesa-dev
mailing list