{
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.
*/
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:
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;
}
}
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(),
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
* 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) {
_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;
}
}
}
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 {
"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 ||
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;
}
/* 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) {
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
* 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);
*/
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);
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.
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;
}
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;
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)
{
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)
*/
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
unsigned pixel_center_integer:1;
/*@}*/
- } 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 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;
- /**
- * 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;
- /**
- * 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;
- /**
- * 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;
- /**
- * 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 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;
- /**
- * 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;
- /**
- * \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;
- /**
- * 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;
- /**
- * 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;
- /**
- * 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;
- /**
- * 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;
/**
* Built-in state that backs this uniform
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);
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;
*/
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;
* 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();
}
}
}
- 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();
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 *
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.
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());
}
}
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);
}
}
}
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);
}
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);
}
}
}
* 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;
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);
*/
/* 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:
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:
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;
assert(var->data.mode == ir_var_uniform);
if (var->is_interface_instance()) {
- var->location = 0;
+ var->data.location = 0;
continue;
}
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;
}
}
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()) {
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.
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;
}
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;
}
}
}
/* 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:
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);
}
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:
*
* 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;
}
* 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
* 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;
}
}
}
}
}
- 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:
* 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);
* 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,
}
}
- 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,
* 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) {
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 =
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;
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;
}
}
}
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;
}
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;
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;
}
}
}
* 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
/* 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
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);
}
* 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;
}
}
}
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;
"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 {
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);
}
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(
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;
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;
= 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);
}
}
/* 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 {
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;
}
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();
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();
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.
*/
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;
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]);
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;
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
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));
}
}
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);
}
}
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());
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);
}
}
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);
}
}
"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)
"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)
"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)
"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)
"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)
"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);
}
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) {
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);
} 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
/* 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;
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);
}
}
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);
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 */
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;
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);
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 */
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;
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);
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));
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) {
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 );
if (var == NULL
|| var->data.mode != ir_var_shader_in
- || var->location == -1)
+ || var->data.location == -1)
continue;
if (current_index == desired_index) {
*/
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;
if (var == NULL
|| var->data.mode != ir_var_shader_in
- || var->location == -1)
+ || var->data.location == -1)
continue;
i++;
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);
*/
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;
*/
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;
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:
* 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:
this->idx = -1;
this->program_resource_visitor::process(var);
- var->location = this->idx;
+ var->data.location = this->idx;
}
private:
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:
* 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: