This will be important to optimization passes. We don't want to
dead-code eliminate writes to out varyings, or propagate uninitialized
values of uniforms.
else
var->mode = ir_var_auto;
+ if (qual->uniform)
+ var->shader_in = true;
+ if (qual->varying) {
+ if (qual->in)
+ var->shader_in = true;
+ if (qual->out)
+ var->shader_out = true;
+ }
+
if (qual->flat)
var->interpolation = ir_var_flat;
else if (qual->noperspective)
unsigned read_only:1;
unsigned centroid:1;
unsigned invariant:1;
+ /** If the variable is initialized outside of the scope of the shader */
+ unsigned shader_in:1;
+ /**
+ * If the variable value is later used outside of the scope of the shader.
+ */
+ unsigned shader_out:1;
unsigned mode:3;
unsigned interpolation:2;
ir_variable *var = new ir_variable(type, name);
var->mode = mode;
- if (var->mode != ir_var_out)
+ switch (var->mode) {
+ case ir_var_in:
+ var->shader_in = true;
var->read_only = true;
-
+ break;
+ case ir_var_inout:
+ var->shader_in = true;
+ var->shader_out = true;
+ case ir_var_out:
+ var->shader_out = true;
+ break;
+ case ir_var_uniform:
+ var->shader_in = true;
+ var->read_only = true;
+ break;
+ default:
+ assert(0);
+ break;
+ }
/* Once the variable is created an initialized, add it to the symbol table
* and add the declaration to the IR stream.