[Mesa-dev] [PATCH v2 2/2] glsl: raise warning when using uninitialized variables

Alejandro Piñeiro apinheiro at igalia.com
Wed Mar 30 09:03:29 UTC 2016



On 30/03/16 09:44, Alejandro Piñeiro wrote:
> On 30/03/16 06:16, Kenneth Graunke wrote:
>> On Tuesday, March 29, 2016 5:09:37 PM PDT Ilia Mirkin wrote:
>>> This is triggering for gl_GlobalInvocationID :(
> :(
>
>>>  I think it's because
>>> of how the variable is computed -- a lowering pass after compilation
>>> is added to initialize it IIRC. Perhaps this should try to ignore
>>> global variables?
> Well, right now the warning is only triggered with var_auto and
> var_shader_out. And the issue is that local and global variables are
> (AFAIU) included under the same mode. From ir.h:
> enum ir_variable_mode {
>    ir_var_auto = 0,             /**< Function local variables and
> globals. */
>
>
> So right now there isn't any easy way to differentiate local from globals.
>
> One option could be filtering it by name. Although this sounds a little
> like a hack, ast_to_hir includes several of name-checking for built-ins.
> Some examples:
> https://cgit.freedesktop.org/mesa/mesa/tree/src/compiler/glsl/ast_to_hir.cpp#n827
> https://cgit.freedesktop.org/mesa/mesa/tree/src/compiler/glsl/ast_to_hir.cpp#n1188
> https://cgit.freedesktop.org/mesa/mesa/tree/src/compiler/glsl/ast_to_hir.cpp#n3107
> https://cgit.freedesktop.org/mesa/mesa/tree/src/compiler/glsl/ast_to_hir.cpp#n3629
> etc.

I have a local patch that solves the problem doing a by-name filtering.
But just in case it can be set the proper ir_variable_mode (see below) I
will hold on a little.

>> I was just looking at that today...adding an ordinary global variable
>> in builtin_variables.cpp seems really wrong.
> I think that I don't follow.  Why gl_GlobalInvocationID is an ordinary
> global variable? It is a built-in variable, and I assumed that all
> built-ins would be using the ir_var_system_value ir_variable_mode. As
> far as I understand this is not happening here due the lowering.

Ah ok, I think that I understand what you mean, now that I took a look
to builtin_variables.cpp::1171. Yes gl_GlobalInvocationID and
gl_LocalInvocationIndex are not added with add_system_value. As far as I
see, it is because they are not included as system values at
shader_enums.h:gl_system_value. I guess that because it is lowered as
Illia mentioned. Jordan could you confirm the reason of adding those
built-ins as regular variables?

BR



More information about the mesa-dev mailing list