summaryrefslogtreecommitdiffstats
path: root/src/glsl/linker.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/glsl/linker.cpp')
-rw-r--r--src/glsl/linker.cpp93
1 files changed, 47 insertions, 46 deletions
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 446e7996671..a6133ea9cb5 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -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;