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

Alejandro PiƱeiro apinheiro at igalia.com
Wed Mar 30 07:44:48 UTC 2016


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 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.

BR


More information about the mesa-dev mailing list