[Mesa-dev] [PATCH] glsl: do not raise uninitialized variable warning with gl_GlobalInvocationID/gl_LocalInvocationIndex

Timothy Arceri t_arceri at yahoo.com.au
Tue Apr 19 00:41:21 UTC 2016


On Mon, 2016-04-18 at 17:12 -0700, Ian Romanick wrote:
> Since the whole gl_* namespace is reserved, it might be better /
> easier
> to strncmp(var->name, "gl_", 3) instead.

We even have a helper is_gl_identifier()


> 
> 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);
> >           }
> > 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list