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)
& 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);
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;
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";
/**
* 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;
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;
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;
/* 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;
}
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);
* by the following stage.
*/
if (var->location == -1) {
- var->shader_out = false;
var->mode = ir_var_auto;
}
}
/* 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;
}
}