[Mesa-stable] [PATCH] glsl: fix derived cs variables for variable group sizes

Ilia Mirkin imirkin at alum.mit.edu
Sat Oct 21 19:18:54 UTC 2017


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.

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-stable mailing list