Mark some variables as having usage beyond the shader's scope.
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.
This commit is contained in:
parent
484606610e
commit
71df19f5ef
|
@ -1446,6 +1446,15 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
|
|||
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)
|
||||
|
|
6
ir.h
6
ir.h
|
@ -151,6 +151,12 @@ public:
|
|||
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;
|
||||
|
|
|
@ -38,9 +38,25 @@ add_variable(const char *name, enum ir_variable_mode mode,
|
|||
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.
|
||||
|
|
Loading…
Reference in New Issue