glsl: move variables in to ir_variable::data, part II

This patch moves following bitfields and variables to the data
structure:

explicit_location, explicit_index, explicit_binding, has_initializer,
is_unmatched_generic_inout, location_frac, from_named_ifc_block_nonarray,
from_named_ifc_block_array, depth_layout, location, index, binding,
max_array_access, atomic

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
This commit is contained in:
Tapani Pälli 2013-12-12 15:08:59 +02:00
parent 33ee2c67c0
commit 447bb9029f
31 changed files with 432 additions and 422 deletions

View file

@ -41,8 +41,8 @@ update_max_array_access(ir_rvalue *ir, unsigned idx, YYLTYPE *loc,
{
if (ir_dereference_variable *deref_var = ir->as_dereference_variable()) {
ir_variable *var = deref_var->var;
if (idx > var->max_array_access) {
var->max_array_access = idx;
if (idx > var->data.max_array_access) {
var->data.max_array_access = idx;
/* Check whether this access will, as a side effect, implicitly cause
* the size of a built-in array to be too large.
@ -184,7 +184,7 @@ _mesa_ast_array_index_to_hir(void *mem_ctx,
*/
ir_variable *v = array->whole_variable_referenced();
if (v != NULL)
v->max_array_access = array->type->array_size() - 1;
v->data.max_array_access = array->type->array_size() - 1;
}
/* From page 23 (29 of the PDF) of the GLSL 1.30 spec:

View file

@ -728,7 +728,7 @@ mark_whole_array_access(ir_rvalue *access)
ir_dereference_variable *deref = access->as_dereference_variable();
if (deref && deref->var) {
deref->var->max_array_access = deref->type->length - 1;
deref->var->data.max_array_access = deref->type->length - 1;
}
}
@ -819,11 +819,11 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state,
assert(var != NULL);
if (var->max_array_access >= unsigned(rhs->type->array_size())) {
if (var->data.max_array_access >= unsigned(rhs->type->array_size())) {
/* FINISHME: This should actually log the location of the RHS. */
_mesa_glsl_error(& lhs_loc, state, "array size must be > %u due to "
"previous access",
var->max_array_access);
var->data.max_array_access);
}
var->type = glsl_type::get_array_instance(lhs->type->element_type(),
@ -2112,7 +2112,7 @@ validate_explicit_location(const struct ast_type_qualifier *qual,
mode_string(var),
_mesa_glsl_shader_target_name(state->target));
} else {
var->explicit_location = true;
var->data.explicit_location = true;
/* This bit of silliness is needed because invalid explicit locations
* are supposed to be flagged during linking. Small negative values
@ -2122,11 +2122,11 @@ validate_explicit_location(const struct ast_type_qualifier *qual,
* ensures that negative values stay negative.
*/
if (qual->location >= 0) {
var->location = (state->target == vertex_shader)
var->data.location = (state->target == vertex_shader)
? (qual->location + VERT_ATTRIB_GENERIC0)
: (qual->location + FRAG_RESULT_DATA0);
} else {
var->location = qual->location;
var->data.location = qual->location;
}
if (qual->flags.q.explicit_index) {
@ -2143,8 +2143,8 @@ validate_explicit_location(const struct ast_type_qualifier *qual,
_mesa_glsl_error(loc, state,
"explicit index may only be 0 or 1");
} else {
var->explicit_index = true;
var->index = qual->index;
var->data.explicit_index = true;
var->data.index = qual->index;
}
}
}
@ -2315,20 +2315,21 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
if (qual->flags.q.explicit_binding &&
validate_binding_qualifier(state, loc, var, qual)) {
var->explicit_binding = true;
var->binding = qual->binding;
var->data.explicit_binding = true;
var->data.binding = qual->binding;
}
if (var->type->contains_atomic()) {
if (var->data.mode == ir_var_uniform) {
if (var->explicit_binding) {
unsigned *offset = &state->atomic_counter_offsets[var->binding];
if (var->data.explicit_binding) {
unsigned *offset =
&state->atomic_counter_offsets[var->data.binding];
if (*offset % ATOMIC_COUNTER_SIZE)
_mesa_glsl_error(loc, state,
"misaligned atomic counter offset");
var->atomic.offset = *offset;
var->data.atomic.offset = *offset;
*offset += var->type->atomic_size();
} else {
@ -2409,15 +2410,15 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
"gl_FragDepth");
}
if (qual->flags.q.depth_any)
var->depth_layout = ir_depth_layout_any;
var->data.depth_layout = ir_depth_layout_any;
else if (qual->flags.q.depth_greater)
var->depth_layout = ir_depth_layout_greater;
var->data.depth_layout = ir_depth_layout_greater;
else if (qual->flags.q.depth_less)
var->depth_layout = ir_depth_layout_less;
var->data.depth_layout = ir_depth_layout_less;
else if (qual->flags.q.depth_unchanged)
var->depth_layout = ir_depth_layout_unchanged;
var->data.depth_layout = ir_depth_layout_unchanged;
else
var->depth_layout = ir_depth_layout_none;
var->data.depth_layout = ir_depth_layout_none;
if (qual->flags.q.std140 ||
qual->flags.q.packed ||
@ -2478,10 +2479,10 @@ get_variable_being_redeclared(ir_variable *var, YYLTYPE loc,
const unsigned size = unsigned(var->type->array_size());
check_builtin_array_max_size(var->name, size, loc, state);
if ((size > 0) && (size <= earlier->max_array_access)) {
if ((size > 0) && (size <= earlier->data.max_array_access)) {
_mesa_glsl_error(& loc, state, "array size must be > %u due to "
"previous access",
earlier->max_array_access);
earlier->data.max_array_access);
}
earlier->type = var->type;
@ -2537,17 +2538,17 @@ get_variable_being_redeclared(ir_variable *var, YYLTYPE loc,
}
/* Prevent inconsistent redeclaration of depth layout qualifier. */
if (earlier->depth_layout != ir_depth_layout_none
&& earlier->depth_layout != var->depth_layout) {
if (earlier->data.depth_layout != ir_depth_layout_none
&& earlier->data.depth_layout != var->data.depth_layout) {
_mesa_glsl_error(&loc, state,
"gl_FragDepth: depth layout is declared here "
"as '%s, but it was previously declared as "
"'%s'",
depth_layout_string(var->depth_layout),
depth_layout_string(earlier->depth_layout));
depth_layout_string(var->data.depth_layout),
depth_layout_string(earlier->data.depth_layout));
}
earlier->depth_layout = var->depth_layout;
earlier->data.depth_layout = var->data.depth_layout;
} else if (allow_all_redeclarations) {
if (earlier->data.mode != var->data.mode) {
@ -2667,7 +2668,7 @@ process_initializer(ir_variable *var, ast_declaration *decl,
initializer_type = rhs->type;
var->constant_initializer = rhs->constant_expression_value();
var->has_initializer = true;
var->data.has_initializer = true;
/* If the declared variable is an unsized array, it must inherrit
* its full type from the initializer. A declaration such as
@ -5126,8 +5127,8 @@ ast_interface_block::hir(exec_list *instructions,
* the UBO declaration itself doesn't get an ir_variable unless it
* has an instance name. This is ugly.
*/
var->explicit_binding = this->layout.flags.q.explicit_binding;
var->binding = this->layout.binding;
var->data.explicit_binding = this->layout.flags.q.explicit_binding;
var->data.binding = this->layout.binding;
state->symbols->add_variable(var);
instructions->push_tail(var);
@ -5223,12 +5224,12 @@ ast_gs_input_layout::hir(exec_list *instructions,
*/
if (var->type->is_unsized_array()) {
if (var->max_array_access >= num_vertices) {
if (var->data.max_array_access >= num_vertices) {
_mesa_glsl_error(&loc, state,
"this geometry shader input layout implies %u"
" vertices, but an access to element %u of input"
" `%s' already exists", num_vertices,
var->max_array_access, var->name);
var->data.max_array_access, var->name);
} else {
var->type = glsl_type::get_array_instance(var->type->fields.array,
num_vertices);

View file

@ -455,9 +455,9 @@ builtin_variable_generator::add_variable(const char *name,
break;
}
var->location = slot;
var->explicit_location = (slot >= 0);
var->explicit_index = 0;
var->data.location = slot;
var->data.explicit_location = (slot >= 0);
var->data.explicit_index = 0;
/* Once the variable is created an initialized, add it to the symbol table
* and add the declaration to the IR stream.
@ -524,7 +524,7 @@ builtin_variable_generator::add_const(const char *name, int value)
ir_var_auto, -1);
var->constant_value = new(var) ir_constant(value);
var->constant_initializer = new(var) ir_constant(value);
var->has_initializer = true;
var->data.has_initializer = true;
return var;
}

View file

@ -1579,21 +1579,21 @@ ir_swizzle::variable_referenced() const
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), atomic()
: max_ifc_array_access(NULL)
{
this->ir_type = ir_type_variable;
this->type = type;
this->name = ralloc_strdup(this, name);
this->explicit_location = false;
this->has_initializer = false;
this->location = -1;
this->location_frac = 0;
this->data.explicit_location = false;
this->data.has_initializer = false;
this->data.location = -1;
this->data.location_frac = 0;
this->warn_extension = NULL;
this->constant_value = NULL;
this->constant_initializer = NULL;
this->data.origin_upper_left = false;
this->data.pixel_center_integer = false;
this->depth_layout = ir_depth_layout_none;
this->data.depth_layout = ir_depth_layout_none;
this->data.used = false;
this->data.read_only = false;
this->data.centroid = false;
@ -1602,6 +1602,9 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name,
this->data.how_declared = ir_var_declared_normally;
this->data.mode = mode;
this->data.interpolation = INTERP_QUALIFIER_NONE;
this->data.max_array_access = 0;
this->data.atomic.buffer_index = 0;
this->data.atomic.offset = 0;
if (type != NULL) {
if (type->base_type == GLSL_TYPE_SAMPLER)
@ -1635,7 +1638,7 @@ ir_variable::determine_interpolation_mode(bool flat_shade)
{
if (this->data.interpolation != INTERP_QUALIFIER_NONE)
return (glsl_interp_qualifier) this->data.interpolation;
int location = this->location;
int location = this->data.location;
bool is_gl_Color =
location == VARYING_SLOT_COL0 || location == VARYING_SLOT_COL1;
if (flat_shade && is_gl_Color)

View file

@ -502,13 +502,6 @@ public:
*/
const char *name;
/**
* Highest element accessed with a constant expression array index
*
* Not used for non-array variables.
*/
unsigned max_array_access;
/**
* For variables which satisfy the is_interface_instance() predicate, this
* points to an array of integers such that if the ith member of the
@ -587,118 +580,125 @@ public:
unsigned pixel_center_integer:1;
/*@}*/
/**
* Was the location explicitly set in the shader?
*
* If the location is explicitly set in the shader, it \b cannot be changed
* by the linker or by the API (e.g., calls to \c glBindAttribLocation have
* no effect).
*/
unsigned explicit_location:1;
unsigned explicit_index:1;
/**
* Was an initial binding explicitly set in the shader?
*
* If so, constant_value contains an integer ir_constant representing the
* initial binding point.
*/
unsigned explicit_binding:1;
/**
* Does this variable have an initializer?
*
* This is used by the linker to cross-validiate initializers of global
* variables.
*/
unsigned has_initializer:1;
/**
* Is this variable a generic output or input that has not yet been matched
* up to a variable in another stage of the pipeline?
*
* This is used by the linker as scratch storage while assigning locations
* to generic inputs and outputs.
*/
unsigned is_unmatched_generic_inout:1;
/**
* If non-zero, then this variable may be packed along with other variables
* into a single varying slot, so this offset should be applied when
* accessing components. For example, an offset of 1 means that the x
* component of this variable is actually stored in component y of the
* location specified by \c location.
*/
unsigned location_frac:2;
/**
* Non-zero if this variable was created by lowering a named interface
* block which was not an array.
*
* Note that this variable and \c from_named_ifc_block_array will never
* both be non-zero.
*/
unsigned from_named_ifc_block_nonarray:1;
/**
* Non-zero if this variable was created by lowering a named interface
* block which was an array.
*
* Note that this variable and \c from_named_ifc_block_nonarray will never
* both be non-zero.
*/
unsigned from_named_ifc_block_array:1;
/**
* \brief Layout qualifier for gl_FragDepth.
*
* This is not equal to \c ir_depth_layout_none if and only if this
* variable is \c gl_FragDepth and a layout qualifier is specified.
*/
ir_depth_layout depth_layout;
/**
* Storage location of the base of this variable
*
* The precise meaning of this field depends on the nature of the variable.
*
* - Vertex shader input: one of the values from \c gl_vert_attrib.
* - Vertex shader output: one of the values from \c gl_varying_slot.
* - Geometry shader input: one of the values from \c gl_varying_slot.
* - Geometry shader output: one of the values from \c gl_varying_slot.
* - Fragment shader input: one of the values from \c gl_varying_slot.
* - Fragment shader output: one of the values from \c gl_frag_result.
* - Uniforms: Per-stage uniform slot number for default uniform block.
* - Uniforms: Index within the uniform block definition for UBO members.
* - Other: This field is not currently used.
*
* If the variable is a uniform, shader input, or shader output, and the
* slot has not been assigned, the value will be -1.
*/
int location;
/**
* output index for dual source blending.
*/
int index;
/**
* Initial binding point for a sampler or UBO.
*
* For array types, this represents the binding point for the first element.
*/
int binding;
/**
* Location an atomic counter is stored at.
*/
struct {
unsigned buffer_index;
unsigned offset;
} atomic;
/**
* Highest element accessed with a constant expression array index
*
* Not used for non-array variables.
*/
unsigned max_array_access;
} data;
/**
* Was the location explicitly set in the shader?
*
* If the location is explicitly set in the shader, it \b cannot be changed
* by the linker or by the API (e.g., calls to \c glBindAttribLocation have
* no effect).
*/
unsigned explicit_location:1;
unsigned explicit_index:1;
/**
* Was an initial binding explicitly set in the shader?
*
* If so, constant_value contains an integer ir_constant representing the
* initial binding point.
*/
unsigned explicit_binding:1;
/**
* Does this variable have an initializer?
*
* This is used by the linker to cross-validiate initializers of global
* variables.
*/
unsigned has_initializer:1;
/**
* Is this variable a generic output or input that has not yet been matched
* up to a variable in another stage of the pipeline?
*
* This is used by the linker as scratch storage while assigning locations
* to generic inputs and outputs.
*/
unsigned is_unmatched_generic_inout:1;
/**
* If non-zero, then this variable may be packed along with other variables
* into a single varying slot, so this offset should be applied when
* accessing components. For example, an offset of 1 means that the x
* component of this variable is actually stored in component y of the
* location specified by \c location.
*/
unsigned location_frac:2;
/**
* Non-zero if this variable was created by lowering a named interface
* block which was not an array.
*
* Note that this variable and \c from_named_ifc_block_array will never
* both be non-zero.
*/
unsigned from_named_ifc_block_nonarray:1;
/**
* Non-zero if this variable was created by lowering a named interface
* block which was an array.
*
* Note that this variable and \c from_named_ifc_block_nonarray will never
* both be non-zero.
*/
unsigned from_named_ifc_block_array:1;
/**
* \brief Layout qualifier for gl_FragDepth.
*
* This is not equal to \c ir_depth_layout_none if and only if this
* variable is \c gl_FragDepth and a layout qualifier is specified.
*/
ir_depth_layout depth_layout;
/**
* Storage location of the base of this variable
*
* The precise meaning of this field depends on the nature of the variable.
*
* - Vertex shader input: one of the values from \c gl_vert_attrib.
* - Vertex shader output: one of the values from \c gl_varying_slot.
* - Geometry shader input: one of the values from \c gl_varying_slot.
* - Geometry shader output: one of the values from \c gl_varying_slot.
* - Fragment shader input: one of the values from \c gl_varying_slot.
* - Fragment shader output: one of the values from \c gl_frag_result.
* - Uniforms: Per-stage uniform slot number for default uniform block.
* - Uniforms: Index within the uniform block definition for UBO members.
* - Other: This field is not currently used.
*
* If the variable is a uniform, shader input, or shader output, and the
* slot has not been assigned, the value will be -1.
*/
int location;
/**
* output index for dual source blending.
*/
int index;
/**
* Initial binding point for a sampler or UBO.
*
* For array types, this represents the binding point for the first element.
*/
int binding;
/**
* Location an atomic counter is stored at.
*/
struct {
unsigned buffer_index;
unsigned offset;
} atomic;
/**
* Built-in state that backs this uniform
*

View file

@ -43,7 +43,7 @@ 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->data.mode);
var->max_array_access = this->max_array_access;
var->data.max_array_access = this->data.max_array_access;
if (this->is_interface_instance()) {
var->max_ifc_array_access =
rzalloc_array(var, unsigned, this->interface_type->length);
@ -55,19 +55,19 @@ ir_variable::clone(void *mem_ctx, struct hash_table *ht) const
var->data.sample = this->data.sample;
var->data.invariant = this->data.invariant;
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->data.location = this->data.location;
var->data.index = this->data.index;
var->data.binding = this->data.binding;
var->data.atomic.buffer_index = this->data.atomic.buffer_index;
var->data.atomic.offset = this->data.atomic.offset;
var->warn_extension = this->warn_extension;
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->data.explicit_location = this->data.explicit_location;
var->data.explicit_index = this->data.explicit_index;
var->data.explicit_binding = this->data.explicit_binding;
var->data.has_initializer = this->data.has_initializer;
var->data.depth_layout = this->data.depth_layout;
var->data.assigned = this->data.assigned;
var->data.how_declared = this->data.how_declared;
var->data.used = this->data.used;

View file

@ -93,12 +93,14 @@ mark(struct gl_program *prog, ir_variable *var, int offset, int len,
*/
for (int i = 0; i < len; i++) {
GLbitfield64 bitfield = BITFIELD64_BIT(var->location + var->index + offset + i);
GLbitfield64 bitfield =
BITFIELD64_BIT(var->data.location + var->data.index + offset + i);
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] =
fprog->InterpQualifier[var->data.location +
var->data.index + offset + i] =
(glsl_interp_qualifier) var->data.interpolation;
if (var->data.centroid)
fprog->IsCentroid |= bitfield;

View file

@ -642,9 +642,9 @@ ir_validate::visit(ir_variable *ir)
* to be out of bounds.
*/
if (ir->type->array_size() > 0) {
if (ir->max_array_access >= ir->type->length) {
if (ir->data.max_array_access >= ir->type->length) {
printf("ir_variable has maximum access out of bounds (%d vs %d)\n",
ir->max_array_access, ir->type->length - 1);
ir->data.max_array_access, ir->type->length - 1);
ir->print();
abort();
}
@ -670,7 +670,7 @@ ir_validate::visit(ir_variable *ir)
}
}
if (ir->constant_initializer != NULL && !ir->has_initializer) {
if (ir->constant_initializer != NULL && !ir->data.has_initializer) {
printf("ir_variable didn't have an initializer, but has a constant "
"initializer value.\n");
ir->print();

View file

@ -73,16 +73,16 @@ namespace {
const active_atomic_counter *const first = (active_atomic_counter *) a;
const active_atomic_counter *const second = (active_atomic_counter *) b;
return int(first->var->atomic.offset) - int(second->var->atomic.offset);
return int(first->var->data.atomic.offset) - int(second->var->data.atomic.offset);
}
bool
check_atomic_counters_overlap(const ir_variable *x, const ir_variable *y)
{
return ((x->atomic.offset >= y->atomic.offset &&
x->atomic.offset < y->atomic.offset + y->type->atomic_size()) ||
(y->atomic.offset >= x->atomic.offset &&
y->atomic.offset < x->atomic.offset + x->type->atomic_size()));
return ((x->data.atomic.offset >= y->data.atomic.offset &&
x->data.atomic.offset < y->data.atomic.offset + y->type->atomic_size()) ||
(y->data.atomic.offset >= x->data.atomic.offset &&
y->data.atomic.offset < x->data.atomic.offset + x->type->atomic_size()));
}
active_atomic_buffer *
@ -107,7 +107,7 @@ namespace {
unsigned id;
bool found = prog->UniformHash->get(id, var->name);
assert(found);
active_atomic_buffer *buf = &buffers[var->binding];
active_atomic_buffer *buf = &buffers[var->data.binding];
/* If this is the first time the buffer is used, increment
* the counter of buffers used.
@ -118,7 +118,7 @@ namespace {
buf->push_back(id, var);
buf->stage_references[i]++;
buf->size = MAX2(buf->size, var->atomic.offset +
buf->size = MAX2(buf->size, var->data.atomic.offset +
var->type->atomic_size());
}
}
@ -143,7 +143,7 @@ namespace {
linker_error(prog, "Atomic counter %s declared at offset %d "
"which is already in use.",
buffers[i].counters[j].var->name,
buffers[i].counters[j].var->atomic.offset);
buffers[i].counters[j].var->data.atomic.offset);
}
}
}
@ -190,9 +190,9 @@ link_assign_atomic_counter_resources(struct gl_context *ctx,
gl_uniform_storage *const storage = &prog->UniformStorage[id];
mab.Uniforms[j] = id;
var->atomic.buffer_index = i;
var->data.atomic.buffer_index = i;
storage->atomic_buffer_index = i;
storage->offset = var->atomic.offset;
storage->offset = var->data.atomic.offset;
storage->array_stride = (var->type->is_array() ?
var->type->element_type()->atomic_size() : 0);
}

View file

@ -201,8 +201,9 @@ public:
if (formal_param->type->is_array()) {
ir_dereference_variable *deref = actual_param->as_dereference_variable();
if (deref && deref->var && deref->var->type->is_array()) {
deref->var->max_array_access =
MAX2(formal_param->max_array_access, deref->var->max_array_access);
deref->var->data.max_array_access =
MAX2(formal_param->data.max_array_access,
deref->var->data.max_array_access);
}
}
}
@ -234,8 +235,9 @@ public:
* we need to track the maximal access to the array as linking
* pulls more functions in that access the array.
*/
var->max_array_access =
MAX2(var->max_array_access, ir->var->max_array_access);
var->data.max_array_access =
MAX2(var->data.max_array_access,
ir->var->data.max_array_access);
if (var->type->length == 0 && ir->var->type->length != 0)
var->type = ir->var->type;

View file

@ -230,9 +230,9 @@ link_set_uniform_initializers(struct gl_shader_program *prog)
if (!mem_ctx)
mem_ctx = ralloc_context(NULL);
if (var->explicit_binding) {
if (var->data.explicit_binding) {
linker::set_uniform_binding(mem_ctx, prog, var->name,
var->type, var->binding);
var->type, var->data.binding);
} else if (var->constant_value) {
linker::set_uniform_initializer(mem_ctx, prog, var->name,
var->type, var->constant_value);

View file

@ -75,7 +75,7 @@ program_resource_visitor::process(ir_variable *var)
*/
/* Only strdup the name if we actually will need to modify it. */
if (var->from_named_ifc_block_array) {
if (var->data.from_named_ifc_block_array) {
/* lower_named_interface_blocks created this variable by lowering an
* interface block array to an array variable. For example if the
* original source code was:
@ -108,7 +108,7 @@ program_resource_visitor::process(ir_variable *var)
recursion(var->type, &name, new_length, false, NULL);
}
ralloc_free(name);
} else if (var->from_named_ifc_block_nonarray) {
} else if (var->data.from_named_ifc_block_nonarray) {
/* lower_named_interface_blocks created this variable by lowering a
* named interface block (non-array) to an ordinary variable. For
* example if the original source code was:
@ -408,10 +408,10 @@ public:
const struct gl_uniform_block *const block =
&prog->UniformBlocks[ubo_block_index];
assert(var->location != -1);
assert(var->data.location != -1);
const struct gl_uniform_buffer_variable *const ubo_var =
&block->Uniforms[var->location];
&block->Uniforms[var->data.location];
ubo_row_major = ubo_var->RowMajor;
ubo_byte_offset = ubo_var->Offset;
@ -640,7 +640,7 @@ link_update_uniform_buffer_variables(struct gl_shader *shader)
assert(var->data.mode == ir_var_uniform);
if (var->is_interface_instance()) {
var->location = 0;
var->data.location = 0;
continue;
}
@ -669,13 +669,13 @@ link_update_uniform_buffer_variables(struct gl_shader *shader)
if (strncmp(var->name, begin, l) == 0) {
found = true;
var->location = j;
var->data.location = j;
break;
}
} else if (!strcmp(var->name,
shader->UniformBlocks[i].Uniforms[j].Name)) {
found = true;
var->location = j;
var->data.location = j;
break;
}
}

View file

@ -329,8 +329,8 @@ tfeedback_decl::assign_location(struct gl_context *ctx,
assert(this->is_varying());
unsigned fine_location
= this->matched_candidate->toplevel_var->location * 4
+ this->matched_candidate->toplevel_var->location_frac
= this->matched_candidate->toplevel_var->data.location * 4
+ this->matched_candidate->toplevel_var->data.location_frac
+ this->matched_candidate->offset;
if (this->matched_candidate->type->is_array()) {
@ -746,7 +746,7 @@ varying_matches::~varying_matches()
void
varying_matches::record(ir_variable *producer_var, ir_variable *consumer_var)
{
if (!producer_var->is_unmatched_generic_inout) {
if (!producer_var->data.is_unmatched_generic_inout) {
/* Either a location already exists for this variable (since it is part
* of fixed functionality), or it has already been recorded as part of a
* previous match.
@ -798,9 +798,9 @@ varying_matches::record(ir_variable *producer_var, ir_variable *consumer_var)
this->matches[this->num_matches].producer_var = producer_var;
this->matches[this->num_matches].consumer_var = consumer_var;
this->num_matches++;
producer_var->is_unmatched_generic_inout = 0;
producer_var->data.is_unmatched_generic_inout = 0;
if (consumer_var)
consumer_var->is_unmatched_generic_inout = 0;
consumer_var->data.is_unmatched_generic_inout = 0;
}
@ -852,12 +852,12 @@ varying_matches::store_locations(unsigned producer_base,
unsigned slot = generic_location / 4;
unsigned offset = generic_location % 4;
producer_var->location = producer_base + slot;
producer_var->location_frac = offset;
producer_var->data.location = producer_base + slot;
producer_var->data.location_frac = offset;
if (consumer_var) {
assert(consumer_var->location == -1);
consumer_var->location = consumer_base + slot;
consumer_var->location_frac = offset;
assert(consumer_var->data.location == -1);
consumer_var->data.location = consumer_base + slot;
consumer_var->data.location_frac = offset;
}
}
}
@ -948,7 +948,7 @@ is_varying_var(GLenum shaderType, const ir_variable *var)
/* Only fragment shaders will take a varying variable as an input */
if (shaderType == GL_FRAGMENT_SHADER &&
var->data.mode == ir_var_shader_in) {
switch (var->location) {
switch (var->data.location) {
case VARYING_SLOT_POS:
case VARYING_SLOT_FACE:
case VARYING_SLOT_PNTC:
@ -1157,7 +1157,7 @@ assign_varying_locations(struct gl_context *ctx,
return false;
}
if (matched_candidate->toplevel_var->is_unmatched_generic_inout)
if (matched_candidate->toplevel_var->data.is_unmatched_generic_inout)
matches.record(matched_candidate->toplevel_var, NULL);
}
@ -1200,7 +1200,7 @@ assign_varying_locations(struct gl_context *ctx,
ir_variable *const var = ((ir_instruction *) node)->as_variable();
if (var && var->data.mode == ir_var_shader_in &&
var->is_unmatched_generic_inout) {
var->data.is_unmatched_generic_inout) {
if (prog->Version <= 120) {
/* On page 25 (page 31 of the PDF) of the GLSL 1.20 spec:
*

View file

@ -217,16 +217,16 @@ public:
* array using an index too large for its actual size assigned at link
* time.
*/
if (var->max_array_access >= this->num_vertices) {
if (var->data.max_array_access >= this->num_vertices) {
linker_error(this->prog, "geometry shader accesses element %i of "
"%s, but only %i input vertices\n",
var->max_array_access, var->name, this->num_vertices);
var->data.max_array_access, var->name, this->num_vertices);
return visit_continue;
}
var->type = glsl_type::get_array_instance(var->type->element_type(),
this->num_vertices);
var->max_array_access = this->num_vertices - 1;
var->data.max_array_access = this->num_vertices - 1;
return visit_continue;
}
@ -379,9 +379,9 @@ link_invalidate_variable_locations(exec_list *ir)
* shader inputs (via layout(location=...)), and generic fragment shader
* outputs (also via layout(location=...)).
*/
if (!var->explicit_location) {
var->location = -1;
var->location_frac = 0;
if (!var->data.explicit_location) {
var->data.location = -1;
var->data.location_frac = 0;
}
/* ir_variable::is_unmatched_generic_inout is used by the linker while
@ -396,10 +396,10 @@ link_invalidate_variable_locations(exec_list *ir)
* GL_ARB_separate_shader_objects is supported. When that extension is
* implemented, this function will need some modifications.
*/
if (!var->explicit_location) {
var->is_unmatched_generic_inout = 1;
if (!var->data.explicit_location) {
var->data.is_unmatched_generic_inout = 1;
} else {
var->is_unmatched_generic_inout = 0;
var->data.is_unmatched_generic_inout = 0;
}
}
}
@ -619,17 +619,17 @@ cross_validate_globals(struct gl_shader_program *prog,
}
}
if (var->explicit_location) {
if (existing->explicit_location
&& (var->location != existing->location)) {
if (var->data.explicit_location) {
if (existing->data.explicit_location
&& (var->data.location != existing->data.location)) {
linker_error(prog, "explicit locations for %s "
"`%s' have differing values\n",
mode_string(var), var->name);
return;
}
existing->location = var->location;
existing->explicit_location = true;
existing->data.location = var->data.location;
existing->data.explicit_location = true;
}
/* From the GLSL 4.20 specification:
@ -638,21 +638,21 @@ cross_validate_globals(struct gl_shader_program *prog,
* opaque-uniform name. However, it is not an error to specify a
* binding on some but not all declarations for the same name"
*/
if (var->explicit_binding) {
if (existing->explicit_binding &&
var->binding != existing->binding) {
if (var->data.explicit_binding) {
if (existing->data.explicit_binding &&
var->data.binding != existing->data.binding) {
linker_error(prog, "explicit bindings for %s "
"`%s' have differing values\n",
mode_string(var), var->name);
return;
}
existing->binding = var->binding;
existing->explicit_binding = true;
existing->data.binding = var->data.binding;
existing->data.explicit_binding = true;
}
if (var->type->contains_atomic() &&
var->atomic.offset != existing->atomic.offset) {
var->data.atomic.offset != existing->data.atomic.offset) {
linker_error(prog, "offset specifications for %s "
"`%s' have differing values\n",
mode_string(var), var->name);
@ -671,9 +671,9 @@ cross_validate_globals(struct gl_shader_program *prog,
* of qualifiers."
*/
if (strcmp(var->name, "gl_FragDepth") == 0) {
bool layout_declared = var->depth_layout != ir_depth_layout_none;
bool layout_declared = var->data.depth_layout != ir_depth_layout_none;
bool layout_differs =
var->depth_layout != existing->depth_layout;
var->data.depth_layout != existing->data.depth_layout;
if (layout_declared && layout_differs) {
linker_error(prog,
@ -734,8 +734,8 @@ cross_validate_globals(struct gl_shader_program *prog,
}
}
if (var->has_initializer) {
if (existing->has_initializer
if (var->data.has_initializer) {
if (existing->data.has_initializer
&& (var->constant_initializer == NULL
|| existing->constant_initializer == NULL)) {
linker_error(prog,
@ -750,7 +750,7 @@ cross_validate_globals(struct gl_shader_program *prog,
* otherwise) will propagate the existence to the variable
* stored in the symbol table.
*/
existing->has_initializer = true;
existing->data.has_initializer = true;
}
if (existing->data.invariant != var->data.invariant) {
@ -1042,7 +1042,7 @@ public:
virtual ir_visitor_status visit(ir_variable *var)
{
fixup_type(&var->type, var->max_array_access);
fixup_type(&var->type, var->data.max_array_access);
if (var->type->is_interface()) {
if (interface_contains_unsized_arrays(var->type)) {
const glsl_type *new_type =
@ -1509,7 +1509,7 @@ update_array_sizes(struct gl_shader_program *prog)
if (var->is_in_uniform_block() || var->type->contains_atomic())
continue;
unsigned int size = var->max_array_access;
unsigned int size = var->data.max_array_access;
for (unsigned j = 0; j < MESA_SHADER_TYPES; j++) {
if (prog->_LinkedShaders[j] == NULL)
continue;
@ -1520,8 +1520,8 @@ update_array_sizes(struct gl_shader_program *prog)
continue;
if (strcmp(var->name, other_var->name) == 0 &&
other_var->max_array_access > size) {
size = other_var->max_array_access;
other_var->data.max_array_access > size) {
size = other_var->data.max_array_access;
}
}
}
@ -1663,13 +1663,14 @@ assign_attribute_or_color_locations(gl_shader_program *prog,
if ((var == NULL) || (var->data.mode != (unsigned) direction))
continue;
if (var->explicit_location) {
if ((var->location >= (int)(max_index + generic_base))
|| (var->location < 0)) {
if (var->data.explicit_location) {
if ((var->data.location >= (int)(max_index + generic_base))
|| (var->data.location < 0)) {
linker_error(prog,
"invalid explicit location %d specified for `%s'\n",
(var->location < 0)
? var->location : var->location - generic_base,
(var->data.location < 0)
? var->data.location
: var->data.location - generic_base,
var->name);
return false;
}
@ -1678,8 +1679,8 @@ assign_attribute_or_color_locations(gl_shader_program *prog,
if (prog->AttributeBindings->get(binding, var->name)) {
assert(binding >= VERT_ATTRIB_GENERIC0);
var->location = binding;
var->is_unmatched_generic_inout = 0;
var->data.location = binding;
var->data.is_unmatched_generic_inout = 0;
}
} else if (target_index == MESA_SHADER_FRAGMENT) {
unsigned binding;
@ -1687,11 +1688,11 @@ assign_attribute_or_color_locations(gl_shader_program *prog,
if (prog->FragDataBindings->get(binding, var->name)) {
assert(binding >= FRAG_RESULT_DATA0);
var->location = binding;
var->is_unmatched_generic_inout = 0;
var->data.location = binding;
var->data.is_unmatched_generic_inout = 0;
if (prog->FragDataIndexBindings->get(index, var->name)) {
var->index = index;
var->data.index = index;
}
}
}
@ -1702,8 +1703,8 @@ assign_attribute_or_color_locations(gl_shader_program *prog,
* add it to the list of variables that need linker-assigned locations.
*/
const unsigned slots = var->type->count_attribute_slots();
if (var->location != -1) {
if (var->location >= generic_base && var->index < 1) {
if (var->data.location != -1) {
if (var->data.location >= generic_base && var->data.index < 1) {
/* From page 61 of the OpenGL 4.0 spec:
*
* "LinkProgram will fail if the attribute bindings assigned
@ -1737,7 +1738,7 @@ assign_attribute_or_color_locations(gl_shader_program *prog,
/* Mask representing the contiguous slots that will be used by
* this attribute.
*/
const unsigned attr = var->location - generic_base;
const unsigned attr = var->data.location - generic_base;
const unsigned use_mask = (1 << slots) - 1;
/* Generate a link error if the set of bits requested for this
@ -1803,8 +1804,8 @@ assign_attribute_or_color_locations(gl_shader_program *prog,
return false;
}
to_assign[i].var->location = generic_base + location;
to_assign[i].var->is_unmatched_generic_inout = 0;
to_assign[i].var->data.location = generic_base + location;
to_assign[i].var->data.is_unmatched_generic_inout = 0;
used_locations |= (use_mask << location);
}
@ -1828,7 +1829,7 @@ demote_shader_inputs_and_outputs(gl_shader *sh, enum ir_variable_mode mode)
* its value is used by other shader stages. This will cause the variable
* to have a location assigned.
*/
if (var->is_unmatched_generic_inout) {
if (var->data.is_unmatched_generic_inout) {
var->data.mode = ir_var_auto;
}
}
@ -1862,7 +1863,7 @@ store_fragdepth_layout(struct gl_shader_program *prog)
}
if (strcmp(var->name, "gl_FragDepth") == 0) {
switch (var->depth_layout) {
switch (var->data.depth_layout) {
case ir_depth_layout_none:
prog->FragDepthLayout = FRAG_DEPTH_LAYOUT_NONE;
return;

View file

@ -135,8 +135,8 @@ lower_clip_distance_visitor::visit(ir_variable *ir)
"gl_ClipDistanceMESA");
this->new_clip_distance_1d_var->type
= glsl_type::get_array_instance(glsl_type::vec4_type, new_size);
this->new_clip_distance_1d_var->max_array_access
= ir->max_array_access / 4;
this->new_clip_distance_1d_var->data.max_array_access
= ir->data.max_array_access / 4;
ir->replace_with(this->new_clip_distance_1d_var);
} else {
@ -161,8 +161,8 @@ lower_clip_distance_visitor::visit(ir_variable *ir)
glsl_type::get_array_instance(glsl_type::vec4_type,
new_size),
ir->type->array_size());
this->new_clip_distance_2d_var->max_array_access
= ir->max_array_access / 4;
this->new_clip_distance_2d_var->data.max_array_access
= ir->data.max_array_access / 4;
ir->replace_with(this->new_clip_distance_2d_var);
}

View file

@ -140,7 +140,7 @@ flatten_named_interface_blocks_declarations::run(exec_list *instructions)
new(mem_ctx) ir_variable(iface_t->fields.structure[i].type,
var_name,
(ir_variable_mode) var->data.mode);
new_var->from_named_ifc_block_nonarray = 1;
new_var->data.from_named_ifc_block_nonarray = 1;
} else {
const glsl_type *new_array_type =
glsl_type::get_array_instance(
@ -150,10 +150,10 @@ flatten_named_interface_blocks_declarations::run(exec_list *instructions)
new(mem_ctx) ir_variable(new_array_type,
var_name,
(ir_variable_mode) var->data.mode);
new_var->from_named_ifc_block_array = 1;
new_var->data.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->data.location = iface_t->fields.structure[i].location;
new_var->data.explicit_location = (new_var->data.location >= 0);
new_var->data.interpolation =
iface_t->fields.structure[i].interpolation;
new_var->data.centroid = iface_t->fields.structure[i].centroid;

View file

@ -259,7 +259,7 @@ lower_packed_varyings_visitor::run(exec_list *instructions)
continue;
if (var->data.mode != this->mode ||
var->location < (int) this->location_base ||
var->data.location < (int) this->location_base ||
!this->needs_lowering(var))
continue;
@ -279,7 +279,7 @@ lower_packed_varyings_visitor::run(exec_list *instructions)
= new(this->mem_ctx) ir_dereference_variable(var);
/* Recursively pack or unpack it. */
this->lower_rvalue(deref, var->location * 4 + var->location_frac, var,
this->lower_rvalue(deref, var->data.location * 4 + var->data.location_frac, var,
var->name, this->gs_input_vertices != 0, 0);
}
}
@ -562,12 +562,12 @@ lower_packed_varyings_visitor::get_packed_varying_deref(
/* Prevent update_array_sizes() from messing with the size of the
* array.
*/
packed_var->max_array_access = this->gs_input_vertices - 1;
packed_var->data.max_array_access = this->gs_input_vertices - 1;
}
packed_var->data.centroid = unpacked_var->data.centroid;
packed_var->data.sample = unpacked_var->data.sample;
packed_var->data.interpolation = unpacked_var->data.interpolation;
packed_var->location = location;
packed_var->data.location = location;
unpacked_var->insert_before(packed_var);
this->packed_varyings[slot] = packed_var;
} else {

View file

@ -143,7 +143,7 @@ lower_ubo_reference_visitor::handle_rvalue(ir_rvalue **rvalue)
struct gl_uniform_block *block = &shader->UniformBlocks[i];
this->ubo_var = var->is_interface_instance()
? &block->Uniforms[0] : &block->Uniforms[var->location];
? &block->Uniforms[0] : &block->Uniforms[var->data.location];
break;
}

View file

@ -88,7 +88,7 @@ public:
if (!var || var->data.mode != this->mode)
return visit_continue;
if (this->find_frag_outputs && var->location == FRAG_RESULT_DATA0) {
if (this->find_frag_outputs && var->data.location == FRAG_RESULT_DATA0) {
this->fragdata_array = var;
ir_constant *index = ir->array_index->as_constant();
@ -105,7 +105,7 @@ public:
return visit_continue_with_parent;
}
if (!this->find_frag_outputs && var->location == VARYING_SLOT_TEX0) {
if (!this->find_frag_outputs && var->data.location == VARYING_SLOT_TEX0) {
this->texcoord_array = var;
ir_constant *index = ir->array_index->as_constant();
@ -133,14 +133,14 @@ public:
if (var->data.mode != this->mode || !var->type->is_array())
return visit_continue;
if (this->find_frag_outputs && var->location == FRAG_RESULT_DATA0) {
if (this->find_frag_outputs && var->data.location == FRAG_RESULT_DATA0) {
/* This is a whole array dereference. */
this->fragdata_usage |= (1 << var->type->array_size()) - 1;
this->lower_fragdata_array = false;
return visit_continue;
}
if (!this->find_frag_outputs && var->location == VARYING_SLOT_TEX0) {
if (!this->find_frag_outputs && var->data.location == VARYING_SLOT_TEX0) {
/* This is a whole array dereference like "gl_TexCoord = x;",
* there's probably no point in lowering that.
*/
@ -160,7 +160,7 @@ public:
return visit_continue;
/* Handle colors and fog. */
switch (var->location) {
switch (var->data.location) {
case VARYING_SLOT_COL0:
this->color[0] = var;
this->color_usage |= 1;
@ -358,9 +358,9 @@ public:
new_var[i] =
new(ctx) ir_variable(glsl_type::vec4_type, name,
this->info->mode);
new_var[i]->location = start_location + i;
new_var[i]->explicit_location = true;
new_var[i]->explicit_index = 0;
new_var[i]->data.location = start_location + i;
new_var[i]->data.explicit_location = true;
new_var[i]->data.explicit_index = 0;
}
ir->head->insert_before(new_var[i]);

View file

@ -104,8 +104,8 @@ matrix_flipper::visit_enter(ir_expression *ir)
var_ref->var = texmat_transpose;
texmat_transpose->max_array_access =
MAX2(texmat_transpose->max_array_access, mat_var->max_array_access);
texmat_transpose->data.max_array_access =
MAX2(texmat_transpose->data.max_array_access, mat_var->data.max_array_access);
progress = true;
}

View file

@ -113,8 +113,8 @@ common_builtin::uniforms_and_system_values_dont_have_explicit_location()
if (var->data.mode != ir_var_uniform && var->data.mode != ir_var_system_value)
continue;
EXPECT_FALSE(var->explicit_location);
EXPECT_EQ(-1, var->location);
EXPECT_FALSE(var->data.explicit_location);
EXPECT_EQ(-1, var->data.location);
}
}
@ -127,8 +127,8 @@ common_builtin::constants_are_constant()
if (var->data.mode != ir_var_auto)
continue;
EXPECT_FALSE(var->explicit_location);
EXPECT_EQ(-1, var->location);
EXPECT_FALSE(var->data.explicit_location);
EXPECT_EQ(-1, var->data.location);
EXPECT_TRUE(var->data.read_only);
}
}
@ -179,10 +179,10 @@ TEST_F(vertex_builtin, inputs_have_explicit_location)
if (var->data.mode != ir_var_shader_in)
continue;
EXPECT_TRUE(var->explicit_location);
EXPECT_NE(-1, var->location);
EXPECT_GT(VERT_ATTRIB_GENERIC0, var->location);
EXPECT_EQ(0u, var->location_frac);
EXPECT_TRUE(var->data.explicit_location);
EXPECT_NE(-1, var->data.location);
EXPECT_GT(VERT_ATTRIB_GENERIC0, var->data.location);
EXPECT_EQ(0u, var->data.location_frac);
}
}
@ -194,17 +194,17 @@ TEST_F(vertex_builtin, outputs_have_explicit_location)
if (var->data.mode != ir_var_shader_out)
continue;
EXPECT_TRUE(var->explicit_location);
EXPECT_NE(-1, var->location);
EXPECT_GT(VARYING_SLOT_VAR0, var->location);
EXPECT_EQ(0u, var->location_frac);
EXPECT_TRUE(var->data.explicit_location);
EXPECT_NE(-1, var->data.location);
EXPECT_GT(VARYING_SLOT_VAR0, var->data.location);
EXPECT_EQ(0u, var->data.location_frac);
/* Several varyings only exist in the fragment shader. Be sure that no
* outputs with these locations exist.
*/
EXPECT_NE(VARYING_SLOT_PNTC, var->location);
EXPECT_NE(VARYING_SLOT_FACE, var->location);
EXPECT_NE(VARYING_SLOT_PRIMITIVE_ID, var->location);
EXPECT_NE(VARYING_SLOT_PNTC, var->data.location);
EXPECT_NE(VARYING_SLOT_FACE, var->data.location);
EXPECT_NE(VARYING_SLOT_PRIMITIVE_ID, var->data.location);
}
}
@ -247,15 +247,15 @@ TEST_F(fragment_builtin, inputs_have_explicit_location)
if (var->data.mode != ir_var_shader_in)
continue;
EXPECT_TRUE(var->explicit_location);
EXPECT_NE(-1, var->location);
EXPECT_GT(VARYING_SLOT_VAR0, var->location);
EXPECT_EQ(0u, var->location_frac);
EXPECT_TRUE(var->data.explicit_location);
EXPECT_NE(-1, var->data.location);
EXPECT_GT(VARYING_SLOT_VAR0, var->data.location);
EXPECT_EQ(0u, var->data.location_frac);
/* Several varyings only exist in the vertex / geometry shader. Be sure
* that no inputs with these locations exist.
*/
EXPECT_TRUE(_mesa_varying_slot_in_fs((gl_varying_slot) var->location));
EXPECT_TRUE(_mesa_varying_slot_in_fs((gl_varying_slot) var->data.location));
}
}
@ -267,15 +267,15 @@ TEST_F(fragment_builtin, outputs_have_explicit_location)
if (var->data.mode != ir_var_shader_out)
continue;
EXPECT_TRUE(var->explicit_location);
EXPECT_NE(-1, var->location);
EXPECT_TRUE(var->data.explicit_location);
EXPECT_NE(-1, var->data.location);
/* gl_FragData[] has location FRAG_RESULT_DATA0. Locations beyond that
* are invalid.
*/
EXPECT_GE(FRAG_RESULT_DATA0, var->location);
EXPECT_GE(FRAG_RESULT_DATA0, var->data.location);
EXPECT_EQ(0u, var->location_frac);
EXPECT_EQ(0u, var->data.location_frac);
}
}
@ -320,8 +320,8 @@ TEST_F(geometry_builtin, inputs_have_explicit_location)
if (var->is_interface_instance()) {
EXPECT_STREQ("gl_in", var->name);
EXPECT_FALSE(var->explicit_location);
EXPECT_EQ(-1, var->location);
EXPECT_FALSE(var->data.explicit_location);
EXPECT_EQ(-1, var->data.location);
ASSERT_TRUE(var->type->is_array());
@ -342,17 +342,17 @@ TEST_F(geometry_builtin, inputs_have_explicit_location)
EXPECT_NE(VARYING_SLOT_FACE, input->location);
}
} else {
EXPECT_TRUE(var->explicit_location);
EXPECT_NE(-1, var->location);
EXPECT_GT(VARYING_SLOT_VAR0, var->location);
EXPECT_EQ(0u, var->location_frac);
EXPECT_TRUE(var->data.explicit_location);
EXPECT_NE(-1, var->data.location);
EXPECT_GT(VARYING_SLOT_VAR0, var->data.location);
EXPECT_EQ(0u, var->data.location_frac);
}
/* Several varyings only exist in the fragment shader. Be sure that no
* inputs with these locations exist.
*/
EXPECT_NE(VARYING_SLOT_PNTC, var->location);
EXPECT_NE(VARYING_SLOT_FACE, var->location);
EXPECT_NE(VARYING_SLOT_PNTC, var->data.location);
EXPECT_NE(VARYING_SLOT_FACE, var->data.location);
}
}
@ -364,16 +364,16 @@ TEST_F(geometry_builtin, outputs_have_explicit_location)
if (var->data.mode != ir_var_shader_out)
continue;
EXPECT_TRUE(var->explicit_location);
EXPECT_NE(-1, var->location);
EXPECT_GT(VARYING_SLOT_VAR0, var->location);
EXPECT_EQ(0u, var->location_frac);
EXPECT_TRUE(var->data.explicit_location);
EXPECT_NE(-1, var->data.location);
EXPECT_GT(VARYING_SLOT_VAR0, var->data.location);
EXPECT_EQ(0u, var->data.location_frac);
/* Several varyings only exist in the fragment shader. Be sure that no
* outputs with these locations exist.
*/
EXPECT_NE(VARYING_SLOT_PNTC, var->location);
EXPECT_NE(VARYING_SLOT_FACE, var->location);
EXPECT_NE(VARYING_SLOT_PNTC, var->data.location);
EXPECT_NE(VARYING_SLOT_FACE, var->data.location);
}
}

View file

@ -64,20 +64,20 @@ TEST_F(invalidate_locations, simple_vertex_in_generic)
"a",
ir_var_shader_in);
EXPECT_FALSE(var->explicit_location);
EXPECT_EQ(-1, var->location);
EXPECT_FALSE(var->data.explicit_location);
EXPECT_EQ(-1, var->data.location);
var->location = VERT_ATTRIB_GENERIC0;
var->location_frac = 2;
var->data.location = VERT_ATTRIB_GENERIC0;
var->data.location_frac = 2;
ir.push_tail(var);
link_invalidate_variable_locations(&ir);
EXPECT_EQ(-1, var->location);
EXPECT_EQ(0u, var->location_frac);
EXPECT_FALSE(var->explicit_location);
EXPECT_TRUE(var->is_unmatched_generic_inout);
EXPECT_EQ(-1, var->data.location);
EXPECT_EQ(0u, var->data.location_frac);
EXPECT_FALSE(var->data.explicit_location);
EXPECT_TRUE(var->data.is_unmatched_generic_inout);
}
TEST_F(invalidate_locations, explicit_location_vertex_in_generic)
@ -87,20 +87,20 @@ TEST_F(invalidate_locations, explicit_location_vertex_in_generic)
"a",
ir_var_shader_in);
EXPECT_FALSE(var->explicit_location);
EXPECT_EQ(-1, var->location);
EXPECT_FALSE(var->data.explicit_location);
EXPECT_EQ(-1, var->data.location);
var->location = VERT_ATTRIB_GENERIC0;
var->explicit_location = true;
var->data.location = VERT_ATTRIB_GENERIC0;
var->data.explicit_location = true;
ir.push_tail(var);
link_invalidate_variable_locations(&ir);
EXPECT_EQ(VERT_ATTRIB_GENERIC0, var->location);
EXPECT_EQ(0u, var->location_frac);
EXPECT_TRUE(var->explicit_location);
EXPECT_FALSE(var->is_unmatched_generic_inout);
EXPECT_EQ(VERT_ATTRIB_GENERIC0, var->data.location);
EXPECT_EQ(0u, var->data.location_frac);
EXPECT_TRUE(var->data.explicit_location);
EXPECT_FALSE(var->data.is_unmatched_generic_inout);
}
TEST_F(invalidate_locations, explicit_location_frac_vertex_in_generic)
@ -110,21 +110,21 @@ TEST_F(invalidate_locations, explicit_location_frac_vertex_in_generic)
"a",
ir_var_shader_in);
EXPECT_FALSE(var->explicit_location);
EXPECT_EQ(-1, var->location);
EXPECT_FALSE(var->data.explicit_location);
EXPECT_EQ(-1, var->data.location);
var->location = VERT_ATTRIB_GENERIC0;
var->location_frac = 2;
var->explicit_location = true;
var->data.location = VERT_ATTRIB_GENERIC0;
var->data.location_frac = 2;
var->data.explicit_location = true;
ir.push_tail(var);
link_invalidate_variable_locations(&ir);
EXPECT_EQ(VERT_ATTRIB_GENERIC0, var->location);
EXPECT_EQ(2u, var->location_frac);
EXPECT_TRUE(var->explicit_location);
EXPECT_FALSE(var->is_unmatched_generic_inout);
EXPECT_EQ(VERT_ATTRIB_GENERIC0, var->data.location);
EXPECT_EQ(2u, var->data.location_frac);
EXPECT_TRUE(var->data.explicit_location);
EXPECT_FALSE(var->data.is_unmatched_generic_inout);
}
TEST_F(invalidate_locations, vertex_in_builtin)
@ -134,20 +134,20 @@ TEST_F(invalidate_locations, vertex_in_builtin)
"gl_Vertex",
ir_var_shader_in);
EXPECT_FALSE(var->explicit_location);
EXPECT_EQ(-1, var->location);
EXPECT_FALSE(var->data.explicit_location);
EXPECT_EQ(-1, var->data.location);
var->location = VERT_ATTRIB_POS;
var->explicit_location = true;
var->data.location = VERT_ATTRIB_POS;
var->data.explicit_location = true;
ir.push_tail(var);
link_invalidate_variable_locations(&ir);
EXPECT_EQ(VERT_ATTRIB_POS, var->location);
EXPECT_EQ(0u, var->location_frac);
EXPECT_TRUE(var->explicit_location);
EXPECT_FALSE(var->is_unmatched_generic_inout);
EXPECT_EQ(VERT_ATTRIB_POS, var->data.location);
EXPECT_EQ(0u, var->data.location_frac);
EXPECT_TRUE(var->data.explicit_location);
EXPECT_FALSE(var->data.is_unmatched_generic_inout);
}
TEST_F(invalidate_locations, simple_vertex_out_generic)
@ -157,19 +157,19 @@ TEST_F(invalidate_locations, simple_vertex_out_generic)
"a",
ir_var_shader_out);
EXPECT_FALSE(var->explicit_location);
EXPECT_EQ(-1, var->location);
EXPECT_FALSE(var->data.explicit_location);
EXPECT_EQ(-1, var->data.location);
var->location = VARYING_SLOT_VAR0;
var->data.location = VARYING_SLOT_VAR0;
ir.push_tail(var);
link_invalidate_variable_locations(&ir);
EXPECT_EQ(-1, var->location);
EXPECT_EQ(0u, var->location_frac);
EXPECT_FALSE(var->explicit_location);
EXPECT_TRUE(var->is_unmatched_generic_inout);
EXPECT_EQ(-1, var->data.location);
EXPECT_EQ(0u, var->data.location_frac);
EXPECT_FALSE(var->data.explicit_location);
EXPECT_TRUE(var->data.is_unmatched_generic_inout);
}
TEST_F(invalidate_locations, vertex_out_builtin)
@ -179,18 +179,18 @@ TEST_F(invalidate_locations, vertex_out_builtin)
"gl_FrontColor",
ir_var_shader_out);
EXPECT_FALSE(var->explicit_location);
EXPECT_EQ(-1, var->location);
EXPECT_FALSE(var->data.explicit_location);
EXPECT_EQ(-1, var->data.location);
var->location = VARYING_SLOT_COL0;
var->explicit_location = true;
var->data.location = VARYING_SLOT_COL0;
var->data.explicit_location = true;
ir.push_tail(var);
link_invalidate_variable_locations(&ir);
EXPECT_EQ(VARYING_SLOT_COL0, var->location);
EXPECT_EQ(0u, var->location_frac);
EXPECT_TRUE(var->explicit_location);
EXPECT_FALSE(var->is_unmatched_generic_inout);
EXPECT_EQ(VARYING_SLOT_COL0, var->data.location);
EXPECT_EQ(0u, var->data.location_frac);
EXPECT_TRUE(var->data.explicit_location);
EXPECT_FALSE(var->data.is_unmatched_generic_inout);
}

View file

@ -1049,7 +1049,7 @@ fs_visitor::emit_general_interpolation(ir_variable *ir)
glsl_interp_qualifier interpolation_mode =
ir->determine_interpolation_mode(c->key.flat_shade);
int location = ir->location;
int location = ir->data.location;
for (unsigned int i = 0; i < array_elements; i++) {
for (unsigned int j = 0; j < type->matrix_columns; j++) {
if (c->prog_data.urb_setup[location] == -1) {

View file

@ -608,7 +608,7 @@ fs_visitor::setup_fp_regs()
ir_variable *ir = new(mem_ctx) ir_variable(glsl_type::vec4_type,
"fp_input",
ir_var_shader_in);
ir->location = i;
ir->data.location = i;
this->current_annotation = ralloc_asprintf(ctx, "interpolate input %d",
i);

View file

@ -70,24 +70,24 @@ fs_visitor::visit(ir_variable *ir)
} else if (ir->data.mode == ir_var_shader_out) {
reg = new(this->mem_ctx) fs_reg(this, ir->type);
if (ir->index > 0) {
assert(ir->location == FRAG_RESULT_DATA0);
assert(ir->index == 1);
if (ir->data.index > 0) {
assert(ir->data.location == FRAG_RESULT_DATA0);
assert(ir->data.index == 1);
this->dual_src_output = *reg;
} else if (ir->location == FRAG_RESULT_COLOR) {
} else if (ir->data.location == FRAG_RESULT_COLOR) {
/* Writing gl_FragColor outputs to all color regions. */
for (unsigned int i = 0; i < MAX2(c->key.nr_color_regions, 1); i++) {
this->outputs[i] = *reg;
this->output_components[i] = 4;
}
} else if (ir->location == FRAG_RESULT_DEPTH) {
} else if (ir->data.location == FRAG_RESULT_DEPTH) {
this->frag_depth = *reg;
} else if (ir->location == FRAG_RESULT_SAMPLE_MASK) {
} else if (ir->data.location == FRAG_RESULT_SAMPLE_MASK) {
this->sample_mask = *reg;
} else {
/* gl_FragData or a user-defined FS output */
assert(ir->location >= FRAG_RESULT_DATA0 &&
ir->location < FRAG_RESULT_DATA0 + BRW_MAX_DRAW_BUFFERS);
assert(ir->data.location >= FRAG_RESULT_DATA0 &&
ir->data.location < FRAG_RESULT_DATA0 + BRW_MAX_DRAW_BUFFERS);
int vector_elements =
ir->type->is_array() ? ir->type->fields.array->vector_elements
@ -95,7 +95,7 @@ fs_visitor::visit(ir_variable *ir)
/* General color output. */
for (unsigned int i = 0; i < MAX2(1, ir->type->length); i++) {
int output = ir->location - FRAG_RESULT_DATA0 + i;
int output = ir->data.location - FRAG_RESULT_DATA0 + i;
this->outputs[output] = *reg;
this->outputs[output].reg_offset += vector_elements * i;
this->output_components[output] = vector_elements;
@ -132,9 +132,9 @@ fs_visitor::visit(ir_variable *ir)
reg->type = brw_type_for_base_type(ir->type);
} else if (ir->data.mode == ir_var_system_value) {
if (ir->location == SYSTEM_VALUE_SAMPLE_POS) {
if (ir->data.location == SYSTEM_VALUE_SAMPLE_POS) {
reg = emit_samplepos_setup(ir);
} else if (ir->location == SYSTEM_VALUE_SAMPLE_ID) {
} else if (ir->data.location == SYSTEM_VALUE_SAMPLE_ID) {
reg = emit_sampleid_setup(ir);
}
}
@ -2219,7 +2219,7 @@ fs_visitor::visit_atomic_counter_intrinsic(ir_call *ir)
ir->actual_parameters.get_head());
ir_variable *location = deref->variable_referenced();
unsigned surf_index = (c->prog_data.base.binding_table.abo_start +
location->atomic.buffer_index);
location->data.atomic.buffer_index);
/* Calculate the surface offset */
fs_reg offset(this, glsl_type::uint_type);
@ -2230,9 +2230,9 @@ fs_visitor::visit_atomic_counter_intrinsic(ir_call *ir)
fs_reg tmp(this, glsl_type::uint_type);
emit(MUL(tmp, this->result, ATOMIC_COUNTER_SIZE));
emit(ADD(offset, tmp, location->atomic.offset));
emit(ADD(offset, tmp, location->data.atomic.offset));
} else {
offset = location->atomic.offset;
offset = location->data.atomic.offset;
}
/* Emit the appropriate machine instruction */

View file

@ -947,18 +947,18 @@ vec4_visitor::visit(ir_variable *ir)
switch (ir->data.mode) {
case ir_var_shader_in:
reg = new(mem_ctx) dst_reg(ATTR, ir->location);
reg = new(mem_ctx) dst_reg(ATTR, ir->data.location);
break;
case ir_var_shader_out:
reg = new(mem_ctx) dst_reg(this, ir->type);
for (int i = 0; i < type_size(ir->type); i++) {
output_reg[ir->location + i] = *reg;
output_reg[ir->location + i].reg_offset = i;
output_reg[ir->location + i].type =
output_reg[ir->data.location + i] = *reg;
output_reg[ir->data.location + i].reg_offset = i;
output_reg[ir->data.location + i].type =
brw_type_for_base_type(ir->type->get_scalar_type());
output_reg_annotation[ir->location + i] = ir->name;
output_reg_annotation[ir->data.location + i] = ir->name;
}
break;
@ -2163,7 +2163,7 @@ vec4_visitor::visit_atomic_counter_intrinsic(ir_call *ir)
ir->actual_parameters.get_head());
ir_variable *location = deref->variable_referenced();
unsigned surf_index = (prog_data->base.binding_table.abo_start +
location->atomic.buffer_index);
location->data.atomic.buffer_index);
/* Calculate the surface offset */
src_reg offset(this, glsl_type::uint_type);
@ -2173,9 +2173,9 @@ vec4_visitor::visit_atomic_counter_intrinsic(ir_call *ir)
src_reg tmp(this, glsl_type::uint_type);
emit(MUL(dst_reg(tmp), this->result, ATOMIC_COUNTER_SIZE));
emit(ADD(dst_reg(offset), tmp, location->atomic.offset));
emit(ADD(dst_reg(offset), tmp, location->data.atomic.offset));
} else {
offset = location->atomic.offset;
offset = location->data.atomic.offset;
}
/* Emit the appropriate machine instruction */

View file

@ -153,7 +153,7 @@ vec4_vs_visitor::make_reg_for_system_value(ir_variable *ir)
dst_reg *reg = new(mem_ctx) dst_reg(ATTR, VERT_ATTRIB_MAX);
vs_prog_data->uses_vertexid = true;
switch (ir->location) {
switch (ir->data.location) {
case SYSTEM_VALUE_VERTEX_ID:
reg->writemask = WRITEMASK_X;
break;

View file

@ -543,7 +543,7 @@ get_current_attrib(texenv_fragment_program *p, GLuint attrib)
ir_rvalue *val;
current = p->shader->symbols->get_variable("gl_CurrentAttribFragMESA");
current->max_array_access = MAX2(current->max_array_access, attrib);
current->data.max_array_access = MAX2(current->data.max_array_access, attrib);
val = new(p->mem_ctx) ir_dereference_variable(current);
ir_rvalue *index = new(p->mem_ctx) ir_constant(attrib);
return new(p->mem_ctx) ir_dereference_array(val, index);
@ -587,7 +587,7 @@ get_source(texenv_fragment_program *p,
var = p->shader->symbols->get_variable("gl_TextureEnvColor");
assert(var);
deref = new(p->mem_ctx) ir_dereference_variable(var);
var->max_array_access = MAX2(var->max_array_access, unit);
var->data.max_array_access = MAX2(var->data.max_array_access, unit);
return new(p->mem_ctx) ir_dereference_array(deref,
new(p->mem_ctx) ir_constant(unit));
@ -927,7 +927,7 @@ static void load_texture( texenv_fragment_program *p, GLuint unit )
texcoord = new(p->mem_ctx) ir_dereference_variable(tc_array);
ir_rvalue *index = new(p->mem_ctx) ir_constant(unit);
texcoord = new(p->mem_ctx) ir_dereference_array(texcoord, index);
tc_array->max_array_access = MAX2(tc_array->max_array_access, unit);
tc_array->data.max_array_access = MAX2(tc_array->data.max_array_access, unit);
}
if (!p->state->unit[unit].enabled) {
@ -1103,7 +1103,7 @@ load_texunit_bumpmap( texenv_fragment_program *p, GLuint unit )
texcoord = new(p->mem_ctx) ir_dereference_variable(tc_array);
ir_rvalue *index = new(p->mem_ctx) ir_constant(bumpedUnitNr);
texcoord = new(p->mem_ctx) ir_dereference_array(texcoord, index);
tc_array->max_array_access = MAX2(tc_array->max_array_access, unit);
tc_array->data.max_array_access = MAX2(tc_array->data.max_array_access, unit);
load_texenv_source( p, unit + SRC_TEXTURE0, unit );

View file

@ -107,7 +107,7 @@ _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index,
if (var == NULL
|| var->data.mode != ir_var_shader_in
|| var->location == -1)
|| var->data.location == -1)
continue;
if (current_index == desired_index) {
@ -170,12 +170,12 @@ _mesa_GetAttribLocation(GLhandleARB program, const GLcharARB * name)
*/
if (var == NULL
|| var->data.mode != ir_var_shader_in
|| var->location == -1
|| var->location < VERT_ATTRIB_GENERIC0)
|| var->data.location == -1
|| var->data.location < VERT_ATTRIB_GENERIC0)
continue;
if (strcmp(var->name, name) == 0)
return var->location - VERT_ATTRIB_GENERIC0;
return var->data.location - VERT_ATTRIB_GENERIC0;
}
return -1;
@ -198,7 +198,7 @@ _mesa_count_active_attribs(struct gl_shader_program *shProg)
if (var == NULL
|| var->data.mode != ir_var_shader_in
|| var->location == -1)
|| var->data.location == -1)
continue;
i++;
@ -224,7 +224,7 @@ _mesa_longest_attribute_name_length(struct gl_shader_program *shProg)
if (var == NULL
|| var->data.mode != ir_var_shader_in
|| var->location == -1)
|| var->data.location == -1)
continue;
const size_t len = strlen(var->name);
@ -334,12 +334,12 @@ _mesa_GetFragDataIndex(GLuint program, const GLchar *name)
*/
if (var == NULL
|| var->data.mode != ir_var_shader_out
|| var->location == -1
|| var->location < FRAG_RESULT_DATA0)
|| var->data.location == -1
|| var->data.location < FRAG_RESULT_DATA0)
continue;
if (strcmp(var->name, name) == 0)
return var->index;
return var->data.index;
}
return -1;
@ -390,12 +390,12 @@ _mesa_GetFragDataLocation(GLuint program, const GLchar *name)
*/
if (var == NULL
|| var->data.mode != ir_var_shader_out
|| var->location == -1
|| var->location < FRAG_RESULT_DATA0)
|| var->data.location == -1
|| var->data.location < FRAG_RESULT_DATA0)
continue;
if (strcmp(var->name, name) == 0)
return var->location - FRAG_RESULT_DATA0;
return var->data.location - FRAG_RESULT_DATA0;
}
return -1;

View file

@ -1531,7 +1531,7 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir)
switch (var->data.mode) {
case ir_var_uniform:
entry = new(mem_ctx) variable_storage(var, PROGRAM_UNIFORM,
var->location);
var->data.location);
this->variables.push_tail(entry);
break;
case ir_var_shader_in:
@ -1540,21 +1540,21 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir)
* user-assigned generic attributes (glBindVertexLocation),
* and user-defined varyings.
*/
assert(var->location != -1);
assert(var->data.location != -1);
entry = new(mem_ctx) variable_storage(var,
PROGRAM_INPUT,
var->location);
var->data.location);
break;
case ir_var_shader_out:
assert(var->location != -1);
assert(var->data.location != -1);
entry = new(mem_ctx) variable_storage(var,
PROGRAM_OUTPUT,
var->location);
var->data.location);
break;
case ir_var_system_value:
entry = new(mem_ctx) variable_storage(var,
PROGRAM_SYSTEM_VALUE,
var->location);
var->data.location);
break;
case ir_var_auto:
case ir_var_temporary:
@ -2404,7 +2404,7 @@ public:
this->idx = -1;
this->program_resource_visitor::process(var);
var->location = this->idx;
var->data.location = this->idx;
}
private:

View file

@ -2023,7 +2023,7 @@ glsl_to_tgsi_visitor::visit(ir_dereference_variable *ir)
switch (var->data.mode) {
case ir_var_uniform:
entry = new(mem_ctx) variable_storage(var, PROGRAM_UNIFORM,
var->location);
var->data.location);
this->variables.push_tail(entry);
break;
case ir_var_shader_in:
@ -2032,21 +2032,22 @@ glsl_to_tgsi_visitor::visit(ir_dereference_variable *ir)
* generic attributes (glBindVertexLocation), and
* user-defined varyings.
*/
assert(var->location != -1);
assert(var->data.location != -1);
entry = new(mem_ctx) variable_storage(var,
PROGRAM_INPUT,
var->location);
var->data.location);
break;
case ir_var_shader_out:
assert(var->location != -1);
assert(var->data.location != -1);
entry = new(mem_ctx) variable_storage(var,
PROGRAM_OUTPUT,
var->location + var->index);
var->data.location
+ var->data.index);
break;
case ir_var_system_value:
entry = new(mem_ctx) variable_storage(var,
PROGRAM_SYSTEM_VALUE,
var->location);
var->data.location);
break;
case ir_var_auto:
case ir_var_temporary: