mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 04:48:08 +02:00
glsl2: Remove the shader_in/shader_out tracking separate from var->mode.
I introduced this for ir_dead_code to distinguish function parameter outvals from varying outputs. Only, since ast_to_hir's current_function is unset when setting up function parameters (they're needed for making the function signature in the first place), all function parameter outvals were marked as shader outputs anyway. This meant that an inlined function's cloned outval was marked as a shader output and couldn't be dead-code eliminated. Instead, since ir_dead_code doesn't even look at function parameters, just use var->mode. The longest Mesa IR coming out of ir_to_mesa for Yo Frankie drops from 725 instructions to 636.
This commit is contained in:
parent
a08f27940a
commit
046bef2357
7 changed files with 17 additions and 57 deletions
|
|
@ -1510,31 +1510,6 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
|
|||
else if (qual->uniform)
|
||||
var->mode = ir_var_uniform;
|
||||
|
||||
if (qual->uniform)
|
||||
var->shader_in = true;
|
||||
|
||||
/* Any 'in' or 'inout' variables at global scope must be marked as being
|
||||
* shader inputs. Likewise, any 'out' or 'inout' variables at global scope
|
||||
* must be marked as being shader outputs.
|
||||
*/
|
||||
if (state->current_function == NULL) {
|
||||
switch (var->mode) {
|
||||
case ir_var_in:
|
||||
case ir_var_uniform:
|
||||
var->shader_in = true;
|
||||
break;
|
||||
case ir_var_out:
|
||||
var->shader_out = true;
|
||||
break;
|
||||
case ir_var_inout:
|
||||
var->shader_in = true;
|
||||
var->shader_out = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (qual->flat)
|
||||
var->interpolation = ir_var_flat;
|
||||
else if (qual->noperspective)
|
||||
|
|
@ -1702,11 +1677,19 @@ ast_declarator_list::hir(exec_list *instructions,
|
|||
& loc);
|
||||
|
||||
if (this->type->qualifier.invariant) {
|
||||
if ((state->target == vertex_shader) && !var->shader_out) {
|
||||
if ((state->target == vertex_shader) && !(var->mode == ir_var_out ||
|
||||
var->mode == ir_var_inout)) {
|
||||
/* FINISHME: Note that this doesn't work for invariant on
|
||||
* a function signature outval
|
||||
*/
|
||||
_mesa_glsl_error(& loc, state,
|
||||
"`%s' cannot be marked invariant, vertex shader "
|
||||
"outputs only\n", var->name);
|
||||
} else if ((state->target == fragment_shader) && !var->shader_in) {
|
||||
} else if ((state->target == fragment_shader) &&
|
||||
!(var->mode == ir_var_in || var->mode == ir_var_inout)) {
|
||||
/* FINISHME: Note that this doesn't work for invariant on
|
||||
* a function signature inval
|
||||
*/
|
||||
_mesa_glsl_error(& loc, state,
|
||||
"`%s' cannot be marked invariant, fragment shader "
|
||||
"inputs only\n", var->name);
|
||||
|
|
|
|||
|
|
@ -902,7 +902,6 @@ ir_swizzle::variable_referenced()
|
|||
ir_variable::ir_variable(const struct glsl_type *type, const char *name,
|
||||
ir_variable_mode mode)
|
||||
: max_array_access(0), read_only(false), centroid(false), invariant(false),
|
||||
shader_in(false), shader_out(false),
|
||||
mode(mode), interpolation(ir_var_smooth), array_lvalue(false)
|
||||
{
|
||||
this->ir_type = ir_type_variable;
|
||||
|
|
@ -922,9 +921,6 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name,
|
|||
const char *
|
||||
ir_variable::interpolation_string() const
|
||||
{
|
||||
if (!this->shader_in && !this->shader_out)
|
||||
return "";
|
||||
|
||||
switch (this->interpolation) {
|
||||
case ir_var_smooth: return "smooth";
|
||||
case ir_var_flat: return "flat";
|
||||
|
|
|
|||
|
|
@ -194,10 +194,10 @@ public:
|
|||
/**
|
||||
* Get the string value for the interpolation qualifier
|
||||
*
|
||||
* \return
|
||||
* If none of \c shader_in or \c shader_out is set, an empty string will
|
||||
* be returned. Otherwise the string that would be used in a shader to
|
||||
* specify \c mode will be returned.
|
||||
* \return The string that would be used in a shader to specify \c
|
||||
* mode will be returned.
|
||||
*
|
||||
* This function should only be used on a shader input or output variable.
|
||||
*/
|
||||
const char *interpolation_string() const;
|
||||
|
||||
|
|
@ -221,12 +221,6 @@ 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;
|
||||
|
|
|
|||
|
|
@ -45,8 +45,6 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const
|
|||
var->read_only = this->read_only;
|
||||
var->centroid = this->centroid;
|
||||
var->invariant = this->invariant;
|
||||
var->shader_in = this->shader_in;
|
||||
var->shader_out = this->shader_out;
|
||||
var->interpolation = this->interpolation;
|
||||
var->array_lvalue = this->array_lvalue;
|
||||
var->location = this->location;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,8 @@ do_dead_code(exec_list *instructions)
|
|||
/* Remove a single dead assignment to the variable we found.
|
||||
* Don't do so if it's a shader output, though.
|
||||
*/
|
||||
if (!entry->var->shader_out) {
|
||||
if (entry->var->mode != ir_var_out &&
|
||||
entry->var->mode != ir_var_inout) {
|
||||
entry->assign->remove();
|
||||
progress = true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,22 +43,12 @@ add_variable(const char *name, enum ir_variable_mode mode, int slot,
|
|||
|
||||
switch (var->mode) {
|
||||
case ir_var_auto:
|
||||
var->read_only = true;
|
||||
break;
|
||||
case ir_var_in:
|
||||
var->shader_in = true;
|
||||
case ir_var_uniform:
|
||||
var->read_only = true;
|
||||
break;
|
||||
case ir_var_inout:
|
||||
var->shader_in = true;
|
||||
var->shader_out = true;
|
||||
break;
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -1124,7 +1124,6 @@ assign_varying_locations(struct gl_shader_program *prog,
|
|||
* by the following stage.
|
||||
*/
|
||||
if (var->location == -1) {
|
||||
var->shader_out = false;
|
||||
var->mode = ir_var_auto;
|
||||
}
|
||||
}
|
||||
|
|
@ -1158,7 +1157,6 @@ assign_varying_locations(struct gl_shader_program *prog,
|
|||
/* An 'in' variable is only really a shader input if its
|
||||
* value is written by the previous stage.
|
||||
*/
|
||||
var->shader_in = false;
|
||||
var->mode = ir_var_auto;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue