[Mesa-dev] [PATCH] glsl: fix derived cs variables for variable group sizes
Ilia Mirkin
imirkin at alum.mit.edu
Sat Oct 21 20:17:17 UTC 2017
On Sat, Oct 21, 2017 at 3:18 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> Both gl_GlobalInvocationID and gl_LocalInvocationIndex depend on the
> gl_WorkGroupSize. However with variable group sizes, this value is not
> available. Use the gl_LocalGroupSizeARB instead, which contains the
> relevant value.
>
> There should not be any situation where at least one of those is not
> defined.
Actually ... there is. When there are multiple compute shaders, linked
together, some may not have a work group size declaration.
So this needs a more subtle solution. Could be that the shader with
main() does not have either declaration. Seems like this should be
moved to link-time, at which point all this stuff is groupped
together. There could be other difficulties with that of course...
>
> Reported-by: Stephane Chevigny <stephane.chevigny at polymtl.ca>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103393
> Cc: mesa-stable at lists.freedesktop.org
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
> src/compiler/glsl/builtin_variables.cpp | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/src/compiler/glsl/builtin_variables.cpp b/src/compiler/glsl/builtin_variables.cpp
> index ea2d897cc8e..85ac0de848b 100644
> --- a/src/compiler/glsl/builtin_variables.cpp
> +++ b/src/compiler/glsl/builtin_variables.cpp
> @@ -1494,15 +1494,9 @@ initialize_cs_derived_variables(gl_shader *shader,
> assert(gl_WorkGroupID);
> ir_variable *gl_WorkGroupSize =
> shader->symbols->get_variable("gl_WorkGroupSize");
> - if (gl_WorkGroupSize == NULL) {
> - void *const mem_ctx = ralloc_parent(shader->ir);
> - gl_WorkGroupSize = new(mem_ctx) ir_variable(glsl_type::uvec3_type,
> - "gl_WorkGroupSize",
> - ir_var_auto);
> - gl_WorkGroupSize->data.how_declared = ir_var_declared_implicitly;
> - gl_WorkGroupSize->data.read_only = true;
> - shader->ir->push_head(gl_WorkGroupSize);
> - }
> + if (gl_WorkGroupSize == NULL)
> + gl_WorkGroupSize = shader->symbols->get_variable("gl_LocalGroupSizeARB");
> + assert(gl_WorkGroupSize);
> ir_variable *gl_LocalInvocationID =
> shader->symbols->get_variable("gl_LocalInvocationID");
> assert(gl_LocalInvocationID);
> --
> 2.13.6
>
More information about the mesa-dev
mailing list