glsl: fix derived cs variables
authorIlia Mirkin <imirkin@alum.mit.edu>
Sat, 21 Oct 2017 19:15:41 +0000 (15:15 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Mon, 23 Oct 2017 12:34:56 +0000 (08:34 -0400)
commit4d24a7cb97641cacecd371d1968f6964785822e4
tree271c13e055c4b08ef7d068b9e4a32d33e8d8ee11
parent4302df8c8e60b79cfba0d16781393041cf79aa43
glsl: fix derived cs variables

There are two issues with the current implementation. First, it relies
on the layout(local_size_*) happening in the same shader as the main
function, and secondly it doesn't work for variable group sizes.

In both cases, the simplest fix is to move the setup of these derived
values to a later time, similar to how the gl_VertexID workarounds are
done. There already exist system values defined for both of the derived
values, so we use them unconditionally, and lower them after linking is
performed.

While we're at it, we move to using gl_LocalGroupSizeARB instead of
gl_WorkGroupSize for variable group sizes.

Also the dead code elimination avoidance can be removed, since there
can be situations where gl_LocalGroupSizeARB is needed but has not been
inserted for the shader with main function. As a result, the lowering
code has to insert its own copies of the system values if needed.

Reported-by: Stephane Chevigny <stephane.chevigny@polymtl.ca>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103393
Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/compiler/Makefile.sources
src/compiler/glsl/builtin_variables.cpp
src/compiler/glsl/glsl_parser_extras.cpp
src/compiler/glsl/ir.h
src/compiler/glsl/ir_optimization.h
src/compiler/glsl/linker.cpp
src/compiler/glsl/lower_cs_derived.cpp [new file with mode: 0644]
src/compiler/glsl/meson.build
src/compiler/glsl/opt_dead_builtin_variables.cpp