if (array->type->is_unsized_array()) {
_mesa_glsl_error(&loc, state, "unsized array index must be constant");
} else if (array->type->fields.array->is_interface()
- && array->variable_referenced()->mode == ir_var_uniform) {
+ && array->variable_referenced()->data.mode == ir_var_uniform) {
/* Page 46 in section 4.3.7 of the OpenGL ES 3.00 spec says:
*
* "All indexes used to index a uniform block array must be
YYLTYPE loc = actual_ast->get_location();
/* Verify that 'const_in' parameters are ir_constants. */
- if (formal->mode == ir_var_const_in &&
+ if (formal->data.mode == ir_var_const_in &&
actual->ir_type != ir_type_constant) {
_mesa_glsl_error(&loc, state,
"parameter `in %s' must be a constant expression",
}
/* Verify that 'out' and 'inout' actual parameters are lvalues. */
- if (formal->mode == ir_var_function_out
- || formal->mode == ir_var_function_inout) {
+ if (formal->data.mode == ir_var_function_out
+ || formal->data.mode == ir_var_function_inout) {
const char *mode = NULL;
- switch (formal->mode) {
+ switch (formal->data.mode) {
case ir_var_function_out: mode = "out"; break;
case ir_var_function_inout: mode = "inout"; break;
default: assert(false); break;
ir_variable *var = actual->variable_referenced();
if (var)
- var->assigned = true;
+ var->data.assigned = true;
if (var && var->data.read_only) {
_mesa_glsl_error(&loc, state,
assert(formal != NULL);
if (formal->type->is_numeric() || formal->type->is_boolean()) {
- switch (formal->mode) {
+ switch (formal->data.mode) {
case ir_var_const_in:
case ir_var_function_in: {
ir_rvalue *converted
case ir_var_function_inout:
fix_parameter(ctx, actual, formal->type,
instructions, &post_call_conversions,
- formal->mode == ir_var_function_inout);
+ formal->data.mode == ir_var_function_inout);
break;
default:
assert (!"Illegal formal parameter mode");
ir_variable *lhs_var = lhs->variable_referenced();
if (lhs_var)
- lhs_var->assigned = true;
+ lhs_var->data.assigned = true;
if (!error_emitted) {
if (non_lvalue_description != NULL) {
var = new(ctx) ir_variable(lvalue->type, "_post_incdec_tmp",
ir_var_temporary);
instructions->push_tail(var);
- var->mode = ir_var_auto;
+ var->data.mode = ir_var_auto;
instructions->push_tail(new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var),
lvalue));
state->symbols->get_variable(this->primary_expression.identifier);
if (var != NULL) {
- var->used = true;
+ var->data.used = true;
result = new(ctx) ir_dereference_variable(var);
} else {
_mesa_glsl_error(& loc, state, "`%s' undeclared",
{
switch (target) {
case vertex_shader:
- return var->mode == ir_var_shader_out;
+ return var->data.mode == ir_var_shader_out;
case fragment_shader:
- return var->mode == ir_var_shader_in;
+ return var->data.mode == ir_var_shader_in;
default:
- return var->mode == ir_var_shader_out || var->mode == ir_var_shader_in;
+ return var->data.mode == ir_var_shader_out || var->data.mode == ir_var_shader_in;
}
}
ir_variable *var,
const ast_type_qualifier *qual)
{
- if (var->mode != ir_var_uniform) {
+ if (var->data.mode != ir_var_uniform) {
_mesa_glsl_error(loc, state,
"the \"binding\" qualifier only applies to uniforms");
return false;
*/
switch (state->target) {
case vertex_shader:
- if (var->mode == ir_var_shader_in) {
+ if (var->data.mode == ir_var_shader_in) {
if (!state->check_explicit_attrib_location_allowed(loc, var))
return;
return;
case fragment_shader:
- if (var->mode == ir_var_shader_out) {
+ if (var->data.mode == ir_var_shader_out) {
if (!state->check_explicit_attrib_location_allowed(loc, var))
return;
STATIC_ASSERT(sizeof(qual->flags.q) <= sizeof(qual->flags.i));
if (qual->flags.q.invariant) {
- if (var->used) {
+ if (var->data.used) {
_mesa_glsl_error(loc, state,
"variable `%s' may not be redeclared "
"`invariant' after being used",
* the setting alone.
*/
if (qual->flags.q.in && qual->flags.q.out)
- var->mode = ir_var_function_inout;
+ var->data.mode = ir_var_function_inout;
else if (qual->flags.q.in)
- var->mode = is_parameter ? ir_var_function_in : ir_var_shader_in;
+ var->data.mode = is_parameter ? ir_var_function_in : ir_var_shader_in;
else if (qual->flags.q.attribute
|| (qual->flags.q.varying && (state->target == fragment_shader)))
- var->mode = ir_var_shader_in;
+ var->data.mode = ir_var_shader_in;
else if (qual->flags.q.out)
- var->mode = is_parameter ? ir_var_function_out : ir_var_shader_out;
+ var->data.mode = is_parameter ? ir_var_function_out : ir_var_shader_out;
else if (qual->flags.q.varying && (state->target == vertex_shader))
- var->mode = ir_var_shader_out;
+ var->data.mode = ir_var_shader_out;
else if (qual->flags.q.uniform)
- var->mode = ir_var_uniform;
+ var->data.mode = ir_var_uniform;
if (!is_parameter && is_varying_var(var, state->target)) {
/* This variable is being used to link data between shader stages (in
if (state->all_invariant && (state->current_function == NULL)) {
switch (state->target) {
case vertex_shader:
- if (var->mode == ir_var_shader_out)
+ if (var->data.mode == ir_var_shader_out)
var->data.invariant = true;
break;
case geometry_shader:
- if ((var->mode == ir_var_shader_in)
- || (var->mode == ir_var_shader_out))
+ if ((var->data.mode == ir_var_shader_in)
+ || (var->data.mode == ir_var_shader_out))
var->data.invariant = true;
break;
case fragment_shader:
- if (var->mode == ir_var_shader_in)
+ if (var->data.mode == ir_var_shader_in)
var->data.invariant = true;
break;
}
}
- var->interpolation =
- interpret_interpolation_qualifier(qual, (ir_variable_mode) var->mode,
+ var->data.interpolation =
+ interpret_interpolation_qualifier(qual, (ir_variable_mode) var->data.mode,
state, loc);
- var->pixel_center_integer = qual->flags.q.pixel_center_integer;
- var->origin_upper_left = qual->flags.q.origin_upper_left;
+ var->data.pixel_center_integer = qual->flags.q.pixel_center_integer;
+ var->data.origin_upper_left = qual->flags.q.origin_upper_left;
if ((qual->flags.q.origin_upper_left || qual->flags.q.pixel_center_integer)
&& (strcmp(var->name, "gl_FragCoord") != 0)) {
const char *const qual_string = (qual->flags.q.origin_upper_left)
}
if (var->type->contains_atomic()) {
- if (var->mode == ir_var_uniform) {
+ if (var->data.mode == ir_var_uniform) {
if (var->explicit_binding) {
unsigned *offset = &state->atomic_counter_offsets[var->binding];
_mesa_glsl_error(loc, state,
"atomic counters require explicit binding point");
}
- } else if (var->mode != ir_var_function_in) {
+ } else if (var->data.mode != ir_var_function_in) {
_mesa_glsl_error(loc, state, "atomic counters may only be declared as "
"function parameters or uniform-qualified "
"global variables");
state->is_version(150, 0))
&& strcmp(var->name, "gl_FragCoord") == 0
&& earlier->type == var->type
- && earlier->mode == var->mode) {
+ && earlier->data.mode == var->data.mode) {
/* Allow redeclaration of gl_FragCoord for ARB_fcc layout
* qualifiers.
*/
- earlier->origin_upper_left = var->origin_upper_left;
- earlier->pixel_center_integer = var->pixel_center_integer;
+ earlier->data.origin_upper_left = var->data.origin_upper_left;
+ earlier->data.pixel_center_integer = var->data.pixel_center_integer;
/* According to section 4.3.7 of the GLSL 1.30 spec,
* the following built-in varaibles can be redeclared with an
|| strcmp(var->name, "gl_Color") == 0
|| strcmp(var->name, "gl_SecondaryColor") == 0)
&& earlier->type == var->type
- && earlier->mode == var->mode) {
- earlier->interpolation = var->interpolation;
+ && earlier->data.mode == var->data.mode) {
+ earlier->data.interpolation = var->data.interpolation;
/* Layout qualifiers for gl_FragDepth. */
} else if ((state->AMD_conservative_depth_enable ||
state->ARB_conservative_depth_enable)
&& strcmp(var->name, "gl_FragDepth") == 0
&& earlier->type == var->type
- && earlier->mode == var->mode) {
+ && earlier->data.mode == var->data.mode) {
/** From the AMD_conservative_depth spec:
* Within any shader, the first redeclarations of gl_FragDepth
* must appear before any use of gl_FragDepth.
*/
- if (earlier->used) {
+ if (earlier->data.used) {
_mesa_glsl_error(&loc, state,
"the first redeclaration of gl_FragDepth "
"must appear before any use of gl_FragDepth");
earlier->depth_layout = var->depth_layout;
} else if (allow_all_redeclarations) {
- if (earlier->mode != var->mode) {
+ if (earlier->data.mode != var->data.mode) {
_mesa_glsl_error(&loc, state,
"redeclaration of `%s' with incorrect qualifiers",
var->name);
* directly by an application via API commands, or indirectly by
* OpenGL."
*/
- if (var->mode == ir_var_uniform) {
+ if (var->data.mode == ir_var_uniform) {
state->check_version(120, 0, &initializer_loc,
"cannot initialize uniforms");
}
"cannot initialize samplers");
}
- if ((var->mode == ir_var_shader_in) && (state->current_function == NULL)) {
+ if ((var->data.mode == ir_var_shader_in) && (state->current_function == NULL)) {
_mesa_glsl_error(& initializer_loc, state,
"cannot initialize %s shader input / %s",
_mesa_glsl_shader_target_name(state->target),
"undeclared variable `%s' cannot be marked "
"invariant", decl->identifier);
} else if ((state->target == vertex_shader)
- && (earlier->mode != ir_var_shader_out)) {
+ && (earlier->data.mode != ir_var_shader_out)) {
_mesa_glsl_error(& loc, state,
"`%s' cannot be marked invariant, vertex shader "
"outputs only", decl->identifier);
} else if ((state->target == fragment_shader)
- && (earlier->mode != ir_var_shader_in)) {
+ && (earlier->data.mode != ir_var_shader_in)) {
_mesa_glsl_error(& loc, state,
"`%s' cannot be marked invariant, fragment shader "
"inputs only", decl->identifier);
- } else if (earlier->used) {
+ } else if (earlier->data.used) {
_mesa_glsl_error(& loc, state,
"variable `%s' may not be redeclared "
"`invariant' after being used",
if (this->type->qualifier.flags.q.invariant) {
if ((state->target == vertex_shader) &&
- var->mode != ir_var_shader_out) {
+ var->data.mode != ir_var_shader_out) {
_mesa_glsl_error(& loc, state,
"`%s' cannot be marked invariant, vertex shader "
"outputs only", var->name);
} else if ((state->target == fragment_shader) &&
- var->mode != ir_var_shader_in) {
+ var->data.mode != ir_var_shader_in) {
/* FINISHME: Note that this doesn't work for invariant on
* a function signature inval
*/
"global scope%s",
mode, var->name, extra);
}
- } else if (var->mode == ir_var_shader_in) {
+ } else if (var->data.mode == ir_var_shader_in) {
var->data.read_only = true;
if (state->target == vertex_shader) {
*/
if (state->is_version(130, 300) &&
var->type->contains_integer() &&
- var->interpolation != INTERP_QUALIFIER_FLAT &&
- ((state->target == fragment_shader && var->mode == ir_var_shader_in)
- || (state->target == vertex_shader && var->mode == ir_var_shader_out
+ var->data.interpolation != INTERP_QUALIFIER_FLAT &&
+ ((state->target == fragment_shader && var->data.mode == ir_var_shader_in)
+ || (state->target == vertex_shader && var->data.mode == ir_var_shader_out
&& state->es_shader))) {
const char *var_type = (state->target == vertex_shader) ?
"vertex output" : "fragment input";
false /* allow_all_redeclarations */);
if (earlier != NULL) {
if (strncmp(var->name, "gl_", 3) == 0 &&
- earlier->how_declared == ir_var_declared_in_block) {
+ earlier->data.how_declared == ir_var_declared_in_block) {
_mesa_glsl_error(&loc, state,
"`%s' has already been redeclared using "
"gl_PerVertex", var->name);
}
- earlier->how_declared = ir_var_declared_normally;
+ earlier->data.how_declared = ir_var_declared_normally;
}
if (decl->initializer != NULL) {
* as out or inout function parameters, nor can they be assigned
* into."
*/
- if ((var->mode == ir_var_function_inout || var->mode == ir_var_function_out)
+ if ((var->data.mode == ir_var_function_inout || var->data.mode == ir_var_function_out)
&& type->contains_sampler()) {
_mesa_glsl_error(&loc, state, "out and inout parameters cannot contain samplers");
type = glsl_type::error_type;
* So for GLSL 1.10, passing an array as an out or inout parameter is not
* allowed. This restriction is removed in GLSL 1.20, and in GLSL ES.
*/
- if ((var->mode == ir_var_function_inout || var->mode == ir_var_function_out)
+ if ((var->data.mode == ir_var_function_inout || var->data.mode == ir_var_function_out)
&& type->is_array()
&& !state->check_version(120, 100, &loc,
"arrays cannot be out or inout parameters")) {
virtual ir_visitor_status visit(ir_dereference_variable *ir)
{
- if (ir->var->mode == mode && ir->var->get_interface_type() == block) {
+ if (ir->var->data.mode == mode && ir->var->get_interface_type() == block) {
found = true;
return visit_stop;
}
_mesa_glsl_error(&loc, state, "`%s' redeclared",
this->instance_name);
}
- earlier->how_declared = ir_var_declared_normally;
+ earlier->data.how_declared = ir_var_declared_normally;
earlier->type = var->type;
earlier->reinit_interface_type(block_type);
delete var;
new(state) ir_variable(fields[i].type,
ralloc_strdup(state, fields[i].name),
var_mode);
- var->interpolation = fields[i].interpolation;
+ var->data.interpolation = fields[i].interpolation;
var->data.centroid = fields[i].centroid;
var->data.sample = fields[i].sample;
var->init_interface_type(block_type);
_mesa_glsl_error(&loc, state,
"redeclaration of gl_PerVertex can only "
"include built-in variables");
- } else if (earlier->how_declared == ir_var_declared_normally) {
+ } else if (earlier->data.how_declared == ir_var_declared_normally) {
_mesa_glsl_error(&loc, state,
"`%s' has already been redeclared", var->name);
} else {
- earlier->how_declared = ir_var_declared_in_block;
+ earlier->data.how_declared = ir_var_declared_in_block;
earlier->reinit_interface_type(block_type);
}
continue;
ir_variable *const var = ((ir_instruction *) node)->as_variable();
if (var != NULL &&
var->get_interface_type() == earlier_per_vertex &&
- var->mode == var_mode) {
- if (var->how_declared == ir_var_declared_normally) {
+ var->data.mode == var_mode) {
+ if (var->data.how_declared == ir_var_declared_normally) {
_mesa_glsl_error(&loc, state,
"redeclaration of gl_PerVertex cannot "
"follow a redeclaration of `%s'",
*/
foreach_list (node, instructions) {
ir_variable *var = ((ir_instruction *) node)->as_variable();
- if (var == NULL || var->mode != ir_var_shader_in)
+ if (var == NULL || var->data.mode != ir_var_shader_in)
continue;
/* Note: gl_PrimitiveIDIn has mode ir_var_shader_in, but it's not an
foreach_list(node, instructions) {
ir_variable *var = ((ir_instruction *)node)->as_variable();
- if (!var || !var->assigned)
+ if (!var || !var->data.assigned)
continue;
if (strcmp(var->name, "gl_FragColor") == 0)
gl_FragData_assigned = true;
else if (strncmp(var->name, "gl_", 3) != 0) {
if (state->target == fragment_shader &&
- var->mode == ir_var_shader_out) {
+ var->data.mode == ir_var_shader_out) {
user_defined_fs_output_assigned = true;
user_defined_fs_output = var;
}
foreach_list_safe(node, instructions) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
if (var != NULL && var->get_interface_type() == per_vertex &&
- var->mode == mode) {
+ var->data.mode == mode) {
state->symbols->disable_variable(var->name);
var->remove();
}
enum ir_variable_mode mode, int slot)
{
ir_variable *var = new(symtab) ir_variable(type, name, mode);
- var->how_declared = ir_var_declared_implicitly;
+ var->data.how_declared = ir_var_declared_implicitly;
- switch (var->mode) {
+ switch (var->data.mode) {
case ir_var_auto:
case ir_var_shader_in:
case ir_var_uniform:
*/
ir_variable *var;
var = add_input(VARYING_SLOT_PRIMITIVE_ID, int_t, "gl_PrimitiveIDIn");
- var->interpolation = INTERP_QUALIFIER_FLAT;
+ var->data.interpolation = INTERP_QUALIFIER_FLAT;
var = add_output(VARYING_SLOT_PRIMITIVE_ID, int_t, "gl_PrimitiveID");
- var->interpolation = INTERP_QUALIFIER_FLAT;
+ var->data.interpolation = INTERP_QUALIFIER_FLAT;
}
if (state->is_version(150, 0)) {
ir_variable *var =
add_input(VARYING_SLOT_PRIMITIVE_ID, int_t, "gl_PrimitiveID");
- var->interpolation = INTERP_QUALIFIER_FLAT;
+ var->data.interpolation = INTERP_QUALIFIER_FLAT;
}
/* gl_FragColor and gl_FragData were deprecated starting in desktop GLSL
ir_variable *var =
add_variable(fields[i].name, fields[i].type, ir_var_shader_out,
fields[i].location);
- var->interpolation = fields[i].interpolation;
+ var->data.interpolation = fields[i].interpolation;
var->data.centroid = fields[i].centroid;
var->data.sample = fields[i].sample;
var->init_interface_type(per_vertex_out_type);
ir_variable::ir_variable(const struct glsl_type *type, const char *name,
ir_variable_mode mode)
- : max_array_access(0), max_ifc_array_access(NULL),
- how_declared(ir_var_declared_normally), mode(mode),
- interpolation(INTERP_QUALIFIER_NONE), atomic()
+ : max_array_access(0), max_ifc_array_access(NULL), atomic()
{
this->ir_type = ir_type_variable;
this->type = type;
this->warn_extension = NULL;
this->constant_value = NULL;
this->constant_initializer = NULL;
- this->origin_upper_left = false;
- this->pixel_center_integer = false;
+ this->data.origin_upper_left = false;
+ this->data.pixel_center_integer = false;
this->depth_layout = ir_depth_layout_none;
- this->used = false;
+ this->data.used = false;
this->data.read_only = false;
this->data.centroid = false;
this->data.sample = false;
this->data.invariant = false;
+ this->data.how_declared = ir_var_declared_normally;
+ this->data.mode = mode;
+ this->data.interpolation = INTERP_QUALIFIER_NONE;
if (type != NULL) {
if (type->base_type == GLSL_TYPE_SAMPLER)
glsl_interp_qualifier
ir_variable::determine_interpolation_mode(bool flat_shade)
{
- if (this->interpolation != INTERP_QUALIFIER_NONE)
- return (glsl_interp_qualifier) this->interpolation;
+ if (this->data.interpolation != INTERP_QUALIFIER_NONE)
+ return (glsl_interp_qualifier) this->data.interpolation;
int location = this->location;
bool is_gl_Color =
location == VARYING_SLOT_COL0 || location == VARYING_SLOT_COL1;
ir_variable *b = (ir_variable *)iter_b.get();
if (a->data.read_only != b->data.read_only ||
- !modes_match(a->mode, b->mode) ||
- a->interpolation != b->interpolation ||
+ !modes_match(a->data.mode, b->data.mode) ||
+ a->data.interpolation != b->data.interpolation ||
a->data.centroid != b->data.centroid ||
a->data.sample != b->data.sample) {
const char *
mode_string(const ir_variable *var)
{
- switch (var->mode) {
+ switch (var->data.mode) {
case ir_var_auto:
return (var->data.read_only) ? "global constant" : "global variable";
*/
inline bool is_in_uniform_block() const
{
- return this->mode == ir_var_uniform && this->interface_type != NULL;
+ return this->data.mode == ir_var_uniform && this->interface_type != NULL;
}
/**
unsigned sample:1;
unsigned invariant:1;
- } data;
+ /**
+ * Has this variable been used for reading or writing?
+ *
+ * Several GLSL semantic checks require knowledge of whether or not a
+ * variable has been used. For example, it is an error to redeclare a
+ * variable as invariant after it has been used.
+ *
+ * This is only maintained in the ast_to_hir.cpp path, not in
+ * Mesa's fixed function or ARB program paths.
+ */
+ unsigned used:1;
- /**
- * Has this variable been used for reading or writing?
- *
- * Several GLSL semantic checks require knowledge of whether or not a
- * variable has been used. For example, it is an error to redeclare a
- * variable as invariant after it has been used.
- *
- * This is only maintained in the ast_to_hir.cpp path, not in
- * Mesa's fixed function or ARB program paths.
- */
- unsigned used:1;
+ /**
+ * Has this variable been statically assigned?
+ *
+ * This answers whether the variable was assigned in any path of
+ * the shader during ast_to_hir. This doesn't answer whether it is
+ * still written after dead code removal, nor is it maintained in
+ * non-ast_to_hir.cpp (GLSL parsing) paths.
+ */
+ unsigned assigned:1;
- /**
- * Has this variable been statically assigned?
- *
- * This answers whether the variable was assigned in any path of
- * the shader during ast_to_hir. This doesn't answer whether it is
- * still written after dead code removal, nor is it maintained in
- * non-ast_to_hir.cpp (GLSL parsing) paths.
- */
- unsigned assigned:1;
+ /**
+ * Enum indicating how the variable was declared. See
+ * ir_var_declaration_type.
+ *
+ * This is used to detect certain kinds of illegal variable redeclarations.
+ */
+ unsigned how_declared:2;
- /**
- * Enum indicating how the variable was declared. See
- * ir_var_declaration_type.
- *
- * This is used to detect certain kinds of illegal variable redeclarations.
- */
- unsigned how_declared:2;
+ /**
+ * Storage class of the variable.
+ *
+ * \sa ir_variable_mode
+ */
+ unsigned mode:4;
- /**
- * Storage class of the variable.
- *
- * \sa ir_variable_mode
- */
- unsigned mode:4;
+ /**
+ * Interpolation mode for shader inputs / outputs
+ *
+ * \sa ir_variable_interpolation
+ */
+ unsigned interpolation:2;
- /**
- * Interpolation mode for shader inputs / outputs
- *
- * \sa ir_variable_interpolation
- */
- unsigned interpolation:2;
+ /**
+ * \name ARB_fragment_coord_conventions
+ * @{
+ */
+ unsigned origin_upper_left:1;
+ unsigned pixel_center_integer:1;
+ /*@}*/
- /**
- * \name ARB_fragment_coord_conventions
- * @{
- */
- unsigned origin_upper_left:1;
- unsigned pixel_center_integer:1;
- /*@}*/
+ } data;
/**
* Was the location explicitly set in the shader?
ir_variable::clone(void *mem_ctx, struct hash_table *ht) const
{
ir_variable *var = new(mem_ctx) ir_variable(this->type, this->name,
- (ir_variable_mode) this->mode);
+ (ir_variable_mode) this->data.mode);
var->max_array_access = this->max_array_access;
if (this->is_interface_instance()) {
var->data.centroid = this->data.centroid;
var->data.sample = this->data.sample;
var->data.invariant = this->data.invariant;
- var->interpolation = this->interpolation;
+ var->data.interpolation = this->data.interpolation;
var->location = this->location;
var->index = this->index;
var->binding = this->binding;
var->atomic.buffer_index = this->atomic.buffer_index;
var->atomic.offset = this->atomic.offset;
var->warn_extension = this->warn_extension;
- var->origin_upper_left = this->origin_upper_left;
- var->pixel_center_integer = this->pixel_center_integer;
+ var->data.origin_upper_left = this->data.origin_upper_left;
+ var->data.pixel_center_integer = this->data.pixel_center_integer;
var->explicit_location = this->explicit_location;
var->explicit_index = this->explicit_index;
var->explicit_binding = this->explicit_binding;
var->has_initializer = this->has_initializer;
var->depth_layout = this->depth_layout;
- var->assigned = this->assigned;
- var->how_declared = this->how_declared;
- var->used = this->used;
+ var->data.assigned = this->data.assigned;
+ var->data.how_declared = this->data.how_declared;
+ var->data.used = this->data.used;
var->num_state_slots = this->num_state_slots;
if (this->state_slots) {
/* The constant_value of a uniform variable is its initializer,
* not the lifetime constant value of the uniform.
*/
- if (var->mode == ir_var_uniform)
+ if (var->data.mode == ir_var_uniform)
return NULL;
if (!var->constant_value)
/* Try to find an implicit conversion from actual to param. */
inexact_match = true;
- switch ((enum ir_variable_mode)(param->mode)) {
+ switch ((enum ir_variable_mode)(param->data.mode)) {
case ir_var_auto:
case ir_var_uniform:
case ir_var_temporary:
STATIC_ASSERT(ARRAY_SIZE(interp) == INTERP_QUALIFIER_COUNT);
printf("(%s%s%s%s%s) ",
- cent, samp, inv, mode[ir->mode], interp[ir->interpolation]);
+ cent, samp, inv, mode[ir->data.mode], interp[ir->data.interpolation]);
print_type(ir->type);
printf(" %s)", unique_name(ir));
} else if (strcmp(qualifier->value(), "invariant") == 0) {
var->data.invariant = 1;
} else if (strcmp(qualifier->value(), "uniform") == 0) {
- var->mode = ir_var_uniform;
+ var->data.mode = ir_var_uniform;
} else if (strcmp(qualifier->value(), "auto") == 0) {
- var->mode = ir_var_auto;
+ var->data.mode = ir_var_auto;
} else if (strcmp(qualifier->value(), "in") == 0) {
- var->mode = ir_var_function_in;
+ var->data.mode = ir_var_function_in;
} else if (strcmp(qualifier->value(), "shader_in") == 0) {
- var->mode = ir_var_shader_in;
+ var->data.mode = ir_var_shader_in;
} else if (strcmp(qualifier->value(), "const_in") == 0) {
- var->mode = ir_var_const_in;
+ var->data.mode = ir_var_const_in;
} else if (strcmp(qualifier->value(), "out") == 0) {
- var->mode = ir_var_function_out;
+ var->data.mode = ir_var_function_out;
} else if (strcmp(qualifier->value(), "shader_out") == 0) {
- var->mode = ir_var_shader_out;
+ var->data.mode = ir_var_shader_out;
} else if (strcmp(qualifier->value(), "inout") == 0) {
- var->mode = ir_var_function_inout;
+ var->data.mode = ir_var_function_inout;
} else if (strcmp(qualifier->value(), "temporary") == 0) {
- var->mode = ir_var_temporary;
+ var->data.mode = ir_var_temporary;
} else if (strcmp(qualifier->value(), "smooth") == 0) {
- var->interpolation = INTERP_QUALIFIER_SMOOTH;
+ var->data.interpolation = INTERP_QUALIFIER_SMOOTH;
} else if (strcmp(qualifier->value(), "flat") == 0) {
- var->interpolation = INTERP_QUALIFIER_FLAT;
+ var->data.interpolation = INTERP_QUALIFIER_FLAT;
} else if (strcmp(qualifier->value(), "noperspective") == 0) {
- var->interpolation = INTERP_QUALIFIER_NOPERSPECTIVE;
+ var->data.interpolation = INTERP_QUALIFIER_NOPERSPECTIVE;
} else {
ir_read_error(expr, "unknown qualifier: %s", qualifier->value());
return NULL;
static inline bool
is_shader_inout(ir_variable *var)
{
- return var->mode == ir_var_shader_in ||
- var->mode == ir_var_shader_out ||
- var->mode == ir_var_system_value;
+ return var->data.mode == ir_var_shader_in ||
+ var->data.mode == ir_var_shader_out ||
+ var->data.mode == ir_var_system_value;
}
static void
for (int i = 0; i < len; i++) {
GLbitfield64 bitfield = BITFIELD64_BIT(var->location + var->index + offset + i);
- if (var->mode == ir_var_shader_in) {
+ if (var->data.mode == ir_var_shader_in) {
prog->InputsRead |= bitfield;
if (is_fragment_shader) {
gl_fragment_program *fprog = (gl_fragment_program *) prog;
fprog->InterpQualifier[var->location + var->index + offset + i] =
- (glsl_interp_qualifier) var->interpolation;
+ (glsl_interp_qualifier) var->data.interpolation;
if (var->data.centroid)
fprog->IsCentroid |= bitfield;
if (var->data.sample)
fprog->IsSample |= bitfield;
}
- } else if (var->mode == ir_var_system_value) {
+ } else if (var->data.mode == ir_var_system_value) {
prog->SystemValuesRead |= bitfield;
} else {
- assert(var->mode == ir_var_shader_out);
+ assert(var->data.mode == ir_var_shader_out);
prog->OutputsWritten |= bitfield;
}
}
{
const glsl_type *type = var->type;
if (this->shader_type == GL_GEOMETRY_SHADER &&
- var->mode == ir_var_shader_in && type->is_array()) {
+ var->data.mode == ir_var_shader_in && type->is_array()) {
type = type->fields.array;
}
const glsl_type *type = var->type;
if (this->shader_type == GL_GEOMETRY_SHADER &&
- var->mode == ir_var_shader_in) {
+ var->data.mode == ir_var_shader_in) {
/* The only geometry shader input that is not an array is
* gl_PrimitiveIDIn, and in that case, this code will never be reached,
* because gl_PrimitiveIDIn can't be indexed into in array fashion.
if (ir_dereference_variable * const deref_var =
inner_array->array->as_dereference_variable()) {
if (this->shader_type == GL_GEOMETRY_SHADER &&
- deref_var->var->mode == ir_var_shader_in) {
+ deref_var->var->data.mode == ir_var_shader_in) {
/* foo is a geometry shader input, so i is the vertex, and j the
* part of the input we're accessing.
*/
ir->array->as_dereference_variable()) {
/* ir => foo[i], where foo is a variable. */
if (this->shader_type == GL_GEOMETRY_SHADER &&
- deref_var->var->mode == ir_var_shader_in) {
+ deref_var->var->data.mode == ir_var_shader_in) {
/* foo is a geometry shader input, so i is the vertex, and we're
* accessing the entire input.
*/
printf("ir_call parameter type mismatch:\n");
goto dump_ir;
}
- if (formal_param->mode == ir_var_function_out
- || formal_param->mode == ir_var_function_inout) {
+ if (formal_param->data.mode == ir_var_function_out
+ || formal_param->data.mode == ir_var_function_inout) {
if (!actual_param->is_lvalue()) {
printf("ir_call out/inout parameters must be lvalues:\n");
goto dump_ir;
if (var->type->is_array())
array_size = var->type->length;
}
- explicitly_declared = (var->how_declared != ir_var_declared_implicitly);
+ explicitly_declared = (var->data.how_declared != ir_var_declared_implicitly);
}
/**
continue;
interface_block_definitions *definitions;
- switch (var->mode) {
+ switch (var->data.mode) {
case ir_var_shader_in:
definitions = &in_interfaces;
break;
*/
definitions->store(def);
} else if (!intrastage_match(prev_def, &def,
- (ir_variable_mode) var->mode)) {
+ (ir_variable_mode) var->data.mode)) {
linker_error(prog, "definitions of interface block `%s' do not"
" match\n", iface_type->name);
return;
/* Add input interfaces from the consumer to the symbol table. */
foreach_list(node, consumer->ir) {
ir_variable *var = ((ir_instruction *) node)->as_variable();
- if (!var || !var->get_interface_type() || var->mode != ir_var_shader_in)
+ if (!var || !var->get_interface_type() || var->data.mode != ir_var_shader_in)
continue;
definitions.store(interface_block_definition(var));
/* Verify that the producer's output interfaces match. */
foreach_list(node, producer->ir) {
ir_variable *var = ((ir_instruction *) node)->as_variable();
- if (!var || !var->get_interface_type() || var->mode != ir_var_shader_out)
+ if (!var || !var->get_interface_type() || var->data.mode != ir_var_shader_out)
continue;
interface_block_definition *consumer_def =
const gl_shader *stage = stages[i];
foreach_list(node, stage->ir) {
ir_variable *var = ((ir_instruction *) node)->as_variable();
- if (!var || !var->get_interface_type() || var->mode != ir_var_uniform)
+ if (!var || !var->get_interface_type() || var->data.mode != ir_var_uniform)
continue;
interface_block_definition *old_def =
foreach_list(node, shader->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
- if (!var || var->mode != ir_var_uniform)
+ if (!var || var->data.mode != ir_var_uniform)
continue;
if (!mem_ctx)
if ((var == NULL) || !var->is_in_uniform_block())
continue;
- assert(var->mode == ir_var_uniform);
+ assert(var->data.mode == ir_var_uniform);
if (var->is_interface_instance()) {
var->location = 0;
foreach_list(node, sh->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
- if ((var == NULL) || (var->mode != ir_var_uniform))
+ if ((var == NULL) || (var->data.mode != ir_var_uniform))
continue;
/* FINISHME: Update code to process built-in uniforms!
foreach_list(node, prog->_LinkedShaders[i]->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
- if ((var == NULL) || (var->mode != ir_var_uniform))
+ if ((var == NULL) || (var->data.mode != ir_var_uniform))
continue;
/* FINISHME: Update code to process built-in uniforms!
return;
}
- if (input->interpolation != output->interpolation) {
+ if (input->data.interpolation != output->data.interpolation) {
linker_error(prog,
"%s shader output `%s' specifies %s "
"interpolation qualifier, "
"interpolation qualifier\n",
_mesa_glsl_shader_target_name(producer_type),
output->name,
- interpolation_string(output->interpolation),
+ interpolation_string(output->data.interpolation),
_mesa_glsl_shader_target_name(consumer_type),
- interpolation_string(input->interpolation));
+ interpolation_string(input->data.interpolation));
return;
}
}
GLenum consumer_type,
GLenum producer_type)
{
- if (front_color != NULL && front_color->assigned)
+ if (front_color != NULL && front_color->data.assigned)
cross_validate_types_and_qualifiers(prog, input, front_color,
consumer_type, producer_type);
- if (back_color != NULL && back_color->assigned)
+ if (back_color != NULL && back_color->data.assigned)
cross_validate_types_and_qualifiers(prog, input, back_color,
consumer_type, producer_type);
}
foreach_list(node, producer->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
- if ((var == NULL) || (var->mode != ir_var_shader_out))
+ if ((var == NULL) || (var->data.mode != ir_var_shader_out))
continue;
parameters.add_variable(var);
foreach_list(node, consumer->ir) {
ir_variable *const input = ((ir_instruction *) node)->as_variable();
- if ((input == NULL) || (input->mode != ir_var_shader_in))
+ if ((input == NULL) || (input->data.mode != ir_var_shader_in))
continue;
- if (strcmp(input->name, "gl_Color") == 0 && input->used) {
+ if (strcmp(input->name, "gl_Color") == 0 && input->data.used) {
const ir_variable *const front_color =
parameters.get_variable("gl_FrontColor");
cross_validate_front_and_back_color(prog, input,
front_color, back_color,
consumer->Type, producer->Type);
- } else if (strcmp(input->name, "gl_SecondaryColor") == 0 && input->used) {
+ } else if (strcmp(input->name, "gl_SecondaryColor") == 0 && input->data.used) {
const ir_variable *const front_color =
parameters.get_variable("gl_FrontSecondaryColor");
*/
producer_var->data.centroid = false;
producer_var->data.sample = false;
- producer_var->interpolation = INTERP_QUALIFIER_FLAT;
+ producer_var->data.interpolation = INTERP_QUALIFIER_FLAT;
if (consumer_var) {
consumer_var->data.centroid = false;
consumer_var->data.sample = false;
- consumer_var->interpolation = INTERP_QUALIFIER_FLAT;
+ consumer_var->data.interpolation = INTERP_QUALIFIER_FLAT;
}
}
*/
unsigned packing_class = var->data.centroid | (var->data.sample << 1);
packing_class *= 4;
- packing_class += var->interpolation;
+ packing_class += var->data.interpolation;
return packing_class;
}
{
/* Only fragment shaders will take a varying variable as an input */
if (shaderType == GL_FRAGMENT_SHADER &&
- var->mode == ir_var_shader_in) {
+ var->data.mode == ir_var_shader_in) {
switch (var->location) {
case VARYING_SLOT_POS:
case VARYING_SLOT_FACE:
ir_variable *const input_var =
((ir_instruction *) node)->as_variable();
- if ((input_var != NULL) && (input_var->mode == ir_var_shader_in)) {
+ if ((input_var != NULL) && (input_var->data.mode == ir_var_shader_in)) {
if (input_var->get_interface_type() != NULL) {
char *const iface_field_name =
ralloc_asprintf(mem_ctx, "%s.%s",
foreach_list(node, producer->ir) {
ir_variable *const output_var = ((ir_instruction *) node)->as_variable();
- if ((output_var == NULL) || (output_var->mode != ir_var_shader_out))
+ if ((output_var == NULL) || (output_var->data.mode != ir_var_shader_out))
continue;
tfeedback_candidate_generator g(mem_ctx, tfeedback_candidates);
(ir_variable *) hash_table_find(consumer_inputs, output_var->name);
}
- if (input_var && input_var->mode != ir_var_shader_in)
+ if (input_var && input_var->data.mode != ir_var_shader_in)
input_var = NULL;
if (input_var) {
foreach_list(node, consumer->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
- if (var && var->mode == ir_var_shader_in &&
+ if (var && var->data.mode == ir_var_shader_in &&
var->is_unmatched_generic_inout) {
if (prog->Version <= 120) {
/* On page 25 (page 31 of the PDF) of the GLSL 1.20 spec:
/* An 'in' variable is only really a shader input if its
* value is written by the previous stage.
*/
- var->mode = ir_var_auto;
+ var->data.mode = ir_var_auto;
}
}
}
foreach_list(node, producer->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
- if (var && var->mode == ir_var_shader_out &&
+ if (var && var->data.mode == ir_var_shader_out &&
is_varying_var(producer->Type, var)) {
output_vectors += var->type->count_attribute_slots();
}
foreach_list(node, consumer->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
- if (var && var->mode == ir_var_shader_in &&
+ if (var && var->data.mode == ir_var_shader_in &&
is_varying_var(consumer->Type, var)) {
input_vectors += var->type->count_attribute_slots();
}
ir_rvalue *param_rval = (ir_rvalue *)iter.get();
ir_variable *sig_param = (ir_variable *)sig_iter.get();
- if (sig_param->mode == ir_var_function_out ||
- sig_param->mode == ir_var_function_inout) {
+ if (sig_param->data.mode == ir_var_function_out ||
+ sig_param->data.mode == ir_var_function_inout) {
ir_variable *var = param_rval->variable_referenced();
if (var && strcmp(name, var->name) == 0) {
found = true;
virtual ir_visitor_status visit(ir_variable *var)
{
- if (!var->type->is_array() || var->mode != ir_var_shader_in)
+ if (!var->type->is_array() || var->data.mode != ir_var_shader_in)
return visit_continue;
unsigned size = var->type->length;
if (var == NULL)
continue;
- if (uniforms_only && (var->mode != ir_var_uniform))
+ if (uniforms_only && (var->data.mode != ir_var_uniform))
continue;
/* Don't cross validate temporaries that are at global scope. These
* will eventually get pulled into the shaders 'main'.
*/
- if (var->mode == ir_var_temporary)
+ if (var->data.mode == ir_var_temporary)
continue;
/* If a global with this name has already been seen, verify that the
"the same set of qualifiers.");
}
- if (var->used && layout_differs) {
+ if (var->data.used && layout_differs) {
linker_error(prog,
"If gl_FragDepth is redeclared with a layout "
"qualifier in any fragment shader, it must be "
virtual ir_visitor_status visit(ir_dereference_variable *ir)
{
- if (ir->var->mode == ir_var_temporary) {
+ if (ir->var->data.mode == ir_var_temporary) {
ir_variable *var = (ir_variable *) hash_table_find(temps, ir->var);
assert(var != NULL);
continue;
ir_variable *var = inst->as_variable();
- if ((var != NULL) && (var->mode != ir_var_temporary))
+ if ((var != NULL) && (var->data.mode != ir_var_temporary))
continue;
assert(inst->as_assignment()
|| inst->as_call()
|| inst->as_if() /* for initializers with the ?: operator */
- || ((var != NULL) && (var->mode == ir_var_temporary)));
+ || ((var != NULL) && (var->data.mode == ir_var_temporary)));
if (make_copies) {
inst = inst->clone(target, NULL);
foreach_list(node, prog->_LinkedShaders[i]->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
- if ((var == NULL) || (var->mode != ir_var_uniform) ||
+ if ((var == NULL) || (var->data.mode != ir_var_uniform) ||
!var->type->is_array())
continue;
foreach_list(node, sh->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
- if ((var == NULL) || (var->mode != (unsigned) direction))
+ if ((var == NULL) || (var->data.mode != (unsigned) direction))
continue;
if (var->explicit_location) {
foreach_list(node, sh->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
- if ((var == NULL) || (var->mode != int(mode)))
+ if ((var == NULL) || (var->data.mode != int(mode)))
continue;
/* A shader 'in' or 'out' variable is only really an input or output if
* to have a location assigned.
*/
if (var->is_unmatched_generic_inout) {
- var->mode = ir_var_auto;
+ var->data.mode = ir_var_auto;
}
}
}
foreach_list(node, ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
- if (var == NULL || var->mode != ir_var_shader_out) {
+ if (var == NULL || var->data.mode != ir_var_shader_out) {
continue;
}
ir->replace_with(this->new_clip_distance_1d_var);
} else {
/* 2D gl_ClipDistance (used for geometry input). */
- assert(ir->mode == ir_var_shader_in &&
+ assert(ir->data.mode == ir_var_shader_in &&
this->shader_type == GL_GEOMETRY_SHADER_ARB);
if (this->old_clip_distance_2d_var)
return visit_continue;
this->base_ir->insert_before(temp_clip_distance);
actual_param->replace_with(
new(ctx) ir_dereference_variable(temp_clip_distance));
- if (formal_param->mode == ir_var_function_in
- || formal_param->mode == ir_var_function_inout) {
+ if (formal_param->data.mode == ir_var_function_in
+ || formal_param->data.mode == ir_var_function_inout) {
/* Copy from gl_ClipDistance to the temporary before the call.
* Since we are going to insert this copy before the current
* instruction, we need to visit it afterwards to make sure it
this->base_ir->insert_before(new_assignment);
this->visit_new_assignment(new_assignment);
}
- if (formal_param->mode == ir_var_function_out
- || formal_param->mode == ir_var_function_inout) {
+ if (formal_param->data.mode == ir_var_function_out
+ || formal_param->data.mode == ir_var_function_inout) {
/* Copy from the temporary to gl_ClipDistance after the call.
* Since visit_list_elements() has already decided which
* instruction it's going to visit next, we need to visit
* but, this will require changes to the other uniform block
* support code.
*/
- if (var->mode == ir_var_uniform)
+ if (var->data.mode == ir_var_uniform)
continue;
const glsl_type * iface_t = var->type;
new_var =
new(mem_ctx) ir_variable(iface_t->fields.structure[i].type,
var_name,
- (ir_variable_mode) var->mode);
+ (ir_variable_mode) var->data.mode);
new_var->from_named_ifc_block_nonarray = 1;
} else {
const glsl_type *new_array_type =
new_var =
new(mem_ctx) ir_variable(new_array_type,
var_name,
- (ir_variable_mode) var->mode);
+ (ir_variable_mode) var->data.mode);
new_var->from_named_ifc_block_array = 1;
}
new_var->location = iface_t->fields.structure[i].location;
new_var->explicit_location = (new_var->location >= 0);
- new_var->interpolation =
+ new_var->data.interpolation =
iface_t->fields.structure[i].interpolation;
new_var->data.centroid = iface_t->fields.structure[i].centroid;
new_var->data.sample = iface_t->fields.structure[i].sample;
* but, this will require changes to the other uniform block
* support code.
*/
- if (var->mode == ir_var_uniform)
+ if (var->data.mode == ir_var_uniform)
return;
if (var->get_interface_type() != NULL) {
ir_visitor_status
output_read_remover::visit(ir_dereference_variable *ir)
{
- if (ir->var->mode != ir_var_shader_out)
+ if (ir->var->data.mode != ir_var_shader_out)
return visit_continue;
ir_variable *temp = (ir_variable *) hash_table_find(replacements, ir->var);
if (var == NULL)
continue;
- if (var->mode != this->mode ||
+ if (var->data.mode != this->mode ||
var->location < (int) this->location_base ||
!this->needs_lowering(var))
continue;
* safe, caller should ensure that integral varyings always use flat
* interpolation, even when this is not required by GLSL.
*/
- assert(var->interpolation == INTERP_QUALIFIER_FLAT ||
+ assert(var->data.interpolation == INTERP_QUALIFIER_FLAT ||
!var->type->contains_integer());
/* Change the old varying into an ordinary global. */
- var->mode = ir_var_auto;
+ var->data.mode = ir_var_auto;
/* Create a reference to the old varying. */
ir_dereference_variable *deref
if (this->packed_varyings[slot] == NULL) {
char *packed_name = ralloc_asprintf(this->mem_ctx, "packed:%s", name);
const glsl_type *packed_type;
- if (unpacked_var->interpolation == INTERP_QUALIFIER_FLAT)
+ if (unpacked_var->data.interpolation == INTERP_QUALIFIER_FLAT)
packed_type = glsl_type::ivec4_type;
else
packed_type = glsl_type::vec4_type;
}
packed_var->data.centroid = unpacked_var->data.centroid;
packed_var->data.sample = unpacked_var->data.sample;
- packed_var->interpolation = unpacked_var->interpolation;
+ packed_var->data.interpolation = unpacked_var->data.interpolation;
packed_var->location = location;
unpacked_var->insert_before(packed_var);
this->packed_varyings[slot] = packed_var;
if (var == NULL)
return this->lower_temps;
- switch (var->mode) {
+ switch (var->data.mode) {
case ir_var_auto:
case ir_var_temporary:
return this->lower_temps;
{
assert(var);
- if (var->mode != ir_var_auto &&
- var->mode != ir_var_temporary)
+ if (var->data.mode != ir_var_auto &&
+ var->data.mode != ir_var_temporary)
return NULL;
if (!(var->type->is_array() || var->type->is_matrix()))
ir_rvalue *param_rval = (ir_rvalue *)iter.get();
ir_variable *sig_param = (ir_variable *)sig_iter.get();
- if (sig_param->mode == ir_var_function_in
- || sig_param->mode == ir_var_const_in) {
+ if (sig_param->data.mode == ir_var_function_in
+ || sig_param->data.mode == ir_var_const_in) {
ir_rvalue *new_param = param_rval;
handle_rvalue(&new_param);
foreach_iter(exec_list_iterator, iter, ir->actual_parameters) {
ir_variable *sig_param = (ir_variable *)sig_param_iter.get();
ir_rvalue *param = (ir_rvalue *)iter.get();
- if (sig_param->mode != ir_var_function_out
- && sig_param->mode != ir_var_function_inout) {
+ if (sig_param->data.mode != ir_var_function_out
+ && sig_param->data.mode != ir_var_function_inout) {
ir_rvalue *new_param = param;
handle_rvalue(&new_param);
if (new_param != param)
ir_rvalue *param_rval = (ir_rvalue *)iter.get();
ir_variable *param = (ir_variable *)sig_iter.get();
- if (param->mode == ir_var_function_out ||
- param->mode == ir_var_function_inout) {
+ if (param->data.mode == ir_var_function_out ||
+ param->data.mode == ir_var_function_inout) {
ir_variable *var = param_rval->variable_referenced();
struct assignment_entry *entry;
foreach_iter(exec_list_iterator, iter, ir->actual_parameters) {
ir_variable *sig_param = (ir_variable *)sig_param_iter.get();
ir_instruction *ir = (ir_instruction *)iter.get();
- if (sig_param->mode != ir_var_function_out
- && sig_param->mode != ir_var_function_inout) {
+ if (sig_param->data.mode != ir_var_function_out
+ && sig_param->data.mode != ir_var_function_inout) {
ir->accept(this);
}
sig_param_iter.next();
foreach_iter(exec_list_iterator, iter, ir->actual_parameters) {
ir_variable *sig_param = (ir_variable *)sig_param_iter.get();
ir_instruction *ir = (ir_instruction *)iter.get();
- if (sig_param->mode != ir_var_function_out
- && sig_param->mode != ir_var_function_inout) {
+ if (sig_param->data.mode != ir_var_function_out
+ && sig_param->data.mode != ir_var_function_inout) {
ir->accept(this);
}
sig_param_iter.next();
{
ir_variable *var = ir->variable_referenced();
- if (!var || var->mode != this->mode)
+ if (!var || var->data.mode != this->mode)
return visit_continue;
if (this->find_frag_outputs && var->location == FRAG_RESULT_DATA0) {
{
ir_variable *var = ir->variable_referenced();
- if (var->mode != this->mode || !var->type->is_array())
+ if (var->data.mode != this->mode || !var->type->is_array())
return visit_continue;
if (this->find_frag_outputs && var->location == FRAG_RESULT_DATA0) {
virtual ir_visitor_status visit(ir_variable *var)
{
- if (var->mode != this->mode)
+ if (var->data.mode != this->mode)
return visit_continue;
/* Nothing to do here for fragment outputs. */
/* Remove a single dead assignment to the variable we found.
* Don't do so if it's a shader or function output, though.
*/
- if (entry->var->mode != ir_var_function_out &&
- entry->var->mode != ir_var_function_inout &&
- entry->var->mode != ir_var_shader_out) {
+ if (entry->var->data.mode != ir_var_function_out &&
+ entry->var->data.mode != ir_var_function_inout &&
+ entry->var->data.mode != ir_var_shader_out) {
entry->assign->remove();
progress = true;
* stage. Also, once uniform locations have been assigned, the
* declaration cannot be deleted.
*/
- if (entry->var->mode == ir_var_uniform &&
+ if (entry->var->data.mode == ir_var_uniform &&
(uniform_locations_assigned ||
entry->var->constant_value))
continue;
*/
foreach_iter(exec_list_iterator, iter, *this->assignments) {
assignment_entry *entry = (assignment_entry *)iter.get();
- if (entry->lhs->mode == ir_var_shader_out) {
+ if (entry->lhs->data.mode == ir_var_shader_out) {
if (debug)
printf("kill %s\n", entry->lhs->name);
entry->remove();
parameters[i] = NULL;
} else {
parameters[i] = sig_param->clone(ctx, ht);
- parameters[i]->mode = ir_var_auto;
+ parameters[i]->data.mode = ir_var_auto;
/* Remove the read-only decoration becuase we're going to write
* directly to this variable. If the cloned variable is left
}
/* Move the actual param into our param variable if it's an 'in' type. */
- if (parameters[i] && (sig_param->mode == ir_var_function_in ||
- sig_param->mode == ir_var_const_in ||
- sig_param->mode == ir_var_function_inout)) {
+ if (parameters[i] && (sig_param->data.mode == ir_var_function_in ||
+ sig_param->data.mode == ir_var_const_in ||
+ sig_param->data.mode == ir_var_function_inout)) {
ir_assignment *assign;
assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(parameters[i]),
const ir_variable *const sig_param = (ir_variable *) sig_param_iter.get();
/* Move our param variable into the actual param if it's an 'out' type. */
- if (parameters[i] && (sig_param->mode == ir_var_function_out ||
- sig_param->mode == ir_var_function_inout)) {
+ if (parameters[i] && (sig_param->data.mode == ir_var_function_out ||
+ sig_param->data.mode == ir_var_function_inout)) {
ir_assignment *assign;
assign = new(ctx) ir_assignment(param->clone(ctx, NULL)->as_rvalue(),
{
assert(var);
- if (!var->type->is_record() || var->mode == ir_var_uniform
- || var->mode == ir_var_shader_in || var->mode == ir_var_shader_out)
+ if (!var->type->is_record() || var->data.mode == ir_var_uniform
+ || var->data.mode == ir_var_shader_in || var->data.mode == ir_var_shader_out)
return NULL;
foreach_iter(exec_list_iterator, iter, this->variable_list) {
ir_rvalue *ir = (ir_rvalue *)iter.get();
ir_rvalue *new_ir = ir;
- if (sig_param->mode != ir_var_function_in
- && sig_param->mode != ir_var_const_in) {
+ if (sig_param->data.mode != ir_var_function_in
+ && sig_param->data.mode != ir_var_const_in) {
if (check_graft(ir, sig_param) == visit_stop)
return visit_stop;
continue;
if (!lhs_var)
continue;
- if (lhs_var->mode == ir_var_function_out ||
- lhs_var->mode == ir_var_function_inout ||
- lhs_var->mode == ir_var_shader_out)
+ if (lhs_var->data.mode == ir_var_function_out ||
+ lhs_var->data.mode == ir_var_function_inout ||
+ lhs_var->data.mode == ir_var_shader_out)
continue;
ir_variable_refcount_entry *entry = info->refs->get_variable_entry(lhs_var);
foreach_list(node, &this->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
- if (var->mode != ir_var_uniform && var->mode != ir_var_system_value)
+ if (var->data.mode != ir_var_uniform && var->data.mode != ir_var_system_value)
continue;
EXPECT_FALSE(var->explicit_location);
foreach_list(node, &this->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
- if (var->mode != ir_var_auto)
+ if (var->data.mode != ir_var_auto)
continue;
EXPECT_FALSE(var->explicit_location);
foreach_list(node, &this->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
- switch (var->mode) {
+ switch (var->data.mode) {
case ir_var_auto:
case ir_var_uniform:
case ir_var_shader_in:
default:
ADD_FAILURE() << "Built-in variable " << var->name
- << " has an invalid mode " << int(var->mode);
+ << " has an invalid mode " << int(var->data.mode);
break;
}
}
foreach_list(node, &this->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
- if (var->mode != ir_var_shader_in)
+ if (var->data.mode != ir_var_shader_in)
continue;
EXPECT_TRUE(var->explicit_location);
foreach_list(node, &this->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
- if (var->mode != ir_var_shader_out)
+ if (var->data.mode != ir_var_shader_out)
continue;
EXPECT_TRUE(var->explicit_location);
foreach_list(node, &this->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
- if (var->mode != ir_var_shader_in)
+ if (var->data.mode != ir_var_shader_in)
continue;
EXPECT_TRUE(var->explicit_location);
foreach_list(node, &this->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
- if (var->mode != ir_var_shader_out)
+ if (var->data.mode != ir_var_shader_out)
continue;
EXPECT_TRUE(var->explicit_location);
foreach_list(node, &this->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
- if (var->mode != ir_var_shader_in)
+ if (var->data.mode != ir_var_shader_in)
continue;
if (var->is_interface_instance()) {
foreach_list(node, &this->ir) {
ir_variable *const var = ((ir_instruction *) node)->as_variable();
- if (var->mode != ir_var_shader_out)
+ if (var->data.mode != ir_var_shader_out)
continue;
EXPECT_TRUE(var->explicit_location);
{
fs_reg *reg = new(this->mem_ctx) fs_reg(this, ir->type);
fs_reg wpos = *reg;
- bool flip = !ir->origin_upper_left ^ c->key.render_to_fbo;
+ bool flip = !ir->data.origin_upper_left ^ c->key.render_to_fbo;
/* gl_FragCoord.x */
- if (ir->pixel_center_integer) {
+ if (ir->data.pixel_center_integer) {
emit(MOV(wpos, this->pixel_x));
} else {
emit(ADD(wpos, this->pixel_x, fs_reg(0.5f)));
wpos.reg_offset++;
/* gl_FragCoord.y */
- if (!flip && ir->pixel_center_integer) {
+ if (!flip && ir->data.pixel_center_integer) {
emit(MOV(wpos, this->pixel_y));
} else {
fs_reg pixel_y = this->pixel_y;
- float offset = (ir->pixel_center_integer ? 0.0 : 0.5);
+ float offset = (ir->data.pixel_center_integer ? 0.0 : 0.5);
if (flip) {
pixel_y.negate = true;
switch (i) {
case VARYING_SLOT_POS:
- ir->pixel_center_integer = fp->PixelCenterInteger;
- ir->origin_upper_left = fp->OriginUpperLeft;
+ ir->data.pixel_center_integer = fp->PixelCenterInteger;
+ ir->data.origin_upper_left = fp->OriginUpperLeft;
fp_input_regs[i] = *emit_fragcoord_interpolation(ir);
break;
case VARYING_SLOT_FACE:
if (!var->type->is_vector())
return NULL;
- switch (var->mode) {
+ switch (var->data.mode) {
case ir_var_uniform:
case ir_var_shader_in:
case ir_var_shader_out:
if (variable_storage(ir))
return;
- if (ir->mode == ir_var_shader_in) {
+ if (ir->data.mode == ir_var_shader_in) {
if (!strcmp(ir->name, "gl_FragCoord")) {
reg = emit_fragcoord_interpolation(ir);
} else if (!strcmp(ir->name, "gl_FrontFacing")) {
assert(reg);
hash_table_insert(this->variable_ht, reg, ir);
return;
- } else if (ir->mode == ir_var_shader_out) {
+ } else if (ir->data.mode == ir_var_shader_out) {
reg = new(this->mem_ctx) fs_reg(this, ir->type);
if (ir->index > 0) {
this->output_components[output] = vector_elements;
}
}
- } else if (ir->mode == ir_var_uniform) {
+ } else if (ir->data.mode == ir_var_uniform) {
int param_index = c->prog_data.nr_params;
/* Thanks to the lower_ubo_reference pass, we will see only
reg = new(this->mem_ctx) fs_reg(UNIFORM, param_index);
reg->type = brw_type_for_base_type(ir->type);
- } else if (ir->mode == ir_var_system_value) {
+ } else if (ir->data.mode == ir_var_system_value) {
if (ir->location == SYSTEM_VALUE_SAMPLE_POS) {
reg = emit_samplepos_setup(ir);
} else if (ir->location == SYSTEM_VALUE_SAMPLE_ID) {
foreach_list(node, shader->ir) {
ir_variable *var = ((ir_instruction *) node)->as_variable();
- if ((var == NULL) || (var->mode != ir_var_uniform)
+ if ((var == NULL) || (var->data.mode != ir_var_uniform)
|| (strncmp(var->name, "gl_", 3) != 0))
continue;
* setup_attributes() will remap our accesses to the actual input array.
*/
ir_dereference_variable *deref_var = ir->array->as_dereference_variable();
- if (deref_var && deref_var->var->mode == ir_var_shader_in)
+ if (deref_var && deref_var->var->data.mode == ir_var_shader_in)
return BRW_VARYING_SLOT_COUNT;
else
return vec4_visitor::compute_array_stride(ir);
if (variable_storage(ir))
return;
- switch (ir->mode) {
+ switch (ir->data.mode) {
case ir_var_shader_in:
reg = new(mem_ctx) dst_reg(ATTR, ir->location);
break;
this->result = src_reg(*reg);
/* System values get their swizzle from the dst_reg writemask */
- if (ir->var->mode == ir_var_system_value)
+ if (ir->var->data.mode == ir_var_system_value)
return;
if (type->is_scalar() || type->is_vector() || type->is_matrix())
const ir_variable *const var = ((ir_instruction *) node)->as_variable();
if (var == NULL
- || var->mode != ir_var_shader_in
+ || var->data.mode != ir_var_shader_in
|| var->location == -1)
continue;
* attribute, or if an error occurs, -1 will be returned."
*/
if (var == NULL
- || var->mode != ir_var_shader_in
+ || var->data.mode != ir_var_shader_in
|| var->location == -1
|| var->location < VERT_ATTRIB_GENERIC0)
continue;
const ir_variable *const var = ((ir_instruction *) node)->as_variable();
if (var == NULL
- || var->mode != ir_var_shader_in
+ || var->data.mode != ir_var_shader_in
|| var->location == -1)
continue;
const ir_variable *const var = ((ir_instruction *) node)->as_variable();
if (var == NULL
- || var->mode != ir_var_shader_in
+ || var->data.mode != ir_var_shader_in
|| var->location == -1)
continue;
* attribute, or if an error occurs, -1 will be returned."
*/
if (var == NULL
- || var->mode != ir_var_shader_out
+ || var->data.mode != ir_var_shader_out
|| var->location == -1
|| var->location < FRAG_RESULT_DATA0)
continue;
* attribute, or if an error occurs, -1 will be returned."
*/
if (var == NULL
- || var->mode != ir_var_shader_out
+ || var->data.mode != ir_var_shader_out
|| var->location == -1
|| var->location < FRAG_RESULT_DATA0)
continue;
if (strcmp(ir->name, "gl_FragCoord") == 0) {
struct gl_fragment_program *fp = (struct gl_fragment_program *)this->prog;
- fp->OriginUpperLeft = ir->origin_upper_left;
- fp->PixelCenterInteger = ir->pixel_center_integer;
+ fp->OriginUpperLeft = ir->data.origin_upper_left;
+ fp->PixelCenterInteger = ir->data.pixel_center_integer;
}
- if (ir->mode == ir_var_uniform && strncmp(ir->name, "gl_", 3) == 0) {
+ if (ir->data.mode == ir_var_uniform && strncmp(ir->name, "gl_", 3) == 0) {
unsigned int i;
const ir_state_slot *const slots = ir->state_slots;
assert(ir->state_slots != NULL);
ir_variable *var = ir->var;
if (!entry) {
- switch (var->mode) {
+ switch (var->data.mode) {
case ir_var_uniform:
entry = new(mem_ctx) variable_storage(var, PROGRAM_UNIFORM,
var->location);
foreach_list(node, sh->ir) {
ir_variable *var = ((ir_instruction *) node)->as_variable();
- if ((var == NULL) || (var->mode != ir_var_uniform)
+ if ((var == NULL) || (var->data.mode != ir_var_uniform)
|| var->is_in_uniform_block() || (strncmp(var->name, "gl_", 3) == 0))
continue;
if (strcmp(ir->name, "gl_FragCoord") == 0) {
struct gl_fragment_program *fp = (struct gl_fragment_program *)this->prog;
- fp->OriginUpperLeft = ir->origin_upper_left;
- fp->PixelCenterInteger = ir->pixel_center_integer;
+ fp->OriginUpperLeft = ir->data.origin_upper_left;
+ fp->PixelCenterInteger = ir->data.pixel_center_integer;
}
- if (ir->mode == ir_var_uniform && strncmp(ir->name, "gl_", 3) == 0) {
+ if (ir->data.mode == ir_var_uniform && strncmp(ir->name, "gl_", 3) == 0) {
unsigned int i;
const ir_state_slot *const slots = ir->state_slots;
assert(ir->state_slots != NULL);
ir_variable *var = ir->var;
if (!entry) {
- switch (var->mode) {
+ switch (var->data.mode) {
case ir_var_uniform:
entry = new(mem_ctx) variable_storage(var, PROGRAM_UNIFORM,
var->location);
assert(!ir->lhs->type->is_scalar() && !ir->lhs->type->is_vector());
l.writemask = WRITEMASK_XYZW;
} else if (ir->lhs->type->is_scalar() &&
- ir->lhs->variable_referenced()->mode == ir_var_shader_out) {
+ ir->lhs->variable_referenced()->data.mode == ir_var_shader_out) {
/* FINISHME: This hack makes writing to gl_FragDepth, which lives in the
* FINISHME: W component of fragment shader output zero, work correctly.
*/
ir_rvalue *param_rval = (ir_rvalue *)iter.get();
ir_variable *param = (ir_variable *)sig_iter.get();
- if (param->mode == ir_var_function_in ||
- param->mode == ir_var_function_inout) {
+ if (param->data.mode == ir_var_function_in ||
+ param->data.mode == ir_var_function_inout) {
variable_storage *storage = find_variable_storage(param);
assert(storage);
ir_rvalue *param_rval = (ir_rvalue *)iter.get();
ir_variable *param = (ir_variable *)sig_iter.get();
- if (param->mode == ir_var_function_out ||
- param->mode == ir_var_function_inout) {
+ if (param->data.mode == ir_var_function_out ||
+ param->data.mode == ir_var_function_inout) {
variable_storage *storage = find_variable_storage(param);
assert(storage);