[Mesa-dev] [PATCH] glsl: do not raise uninitialized variable warning with gl_GlobalInvocationID/gl_LocalInvocationIndex
Ian Romanick
idr at freedesktop.org
Tue Apr 19 00:12:37 UTC 2016
Since the whole gl_* namespace is reserved, it might be better / easier
to strncmp(var->name, "gl_", 3) instead.
On 03/31/2016 02:48 AM, Alejandro PiƱeiro wrote:
> Most GLSL built-ins variables are filtered out because they have
> the mode ir_var_system_value, but those two not. Those two are
> specially handled as they can be infered from other system values,
> and were represented as a variable initialized with a value
> based of those system values, instead of a lowering.
> ---
>
> As a reference, this would be the patch I'm proposing.
>
> src/compiler/glsl/ast_to_hir.cpp | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/src/compiler/glsl/ast_to_hir.cpp b/src/compiler/glsl/ast_to_hir.cpp
> index a031231..aec8e6f 100644
> --- a/src/compiler/glsl/ast_to_hir.cpp
> +++ b/src/compiler/glsl/ast_to_hir.cpp
> @@ -1905,7 +1905,9 @@ ast_expression::do_hir(exec_list *instructions,
>
> if ((var->data.mode == ir_var_auto || var->data.mode == ir_var_shader_out)
> && !this->is_lhs
> - && result->variable_referenced()->data.assigned != true) {
> + && result->variable_referenced()->data.assigned != true
> + && strcmp(var->name, "gl_GlobalInvocationID") != 0
> + && strcmp(var->name, "gl_LocalInvocationIndex") != 0) {
> _mesa_glsl_warning(&loc, state, "`%s' used uninitialized",
> this->primary_expression.identifier);
> }
>
More information about the mesa-dev
mailing list