return var->data.location - location_start;
}
+struct explicit_location_info {
+ ir_variable *var;
+ unsigned base_type;
+};
+
static bool
-check_location_aliasing(ir_variable *explicit_locations[][4],
+check_location_aliasing(struct explicit_location_info explicit_locations[][4],
ir_variable *var,
unsigned location,
unsigned component,
while (location < location_limit) {
unsigned i = component;
while (i < last_comp) {
- if (explicit_locations[location][i] != NULL) {
+ if (explicit_locations[location][i].var != NULL) {
linker_error(prog,
"%s shader has multiple outputs explicitly "
"assigned to location %d and component %d\n",
/* Make sure all component at this location have the same type.
*/
for (unsigned j = 0; j < 4; j++) {
- if (explicit_locations[location][j] &&
- (explicit_locations[location][j]->type->without_array()
- ->base_type != type->without_array()->base_type)) {
+ if (explicit_locations[location][j].var &&
+ explicit_locations[location][j].base_type !=
+ type->without_array()->base_type) {
linker_error(prog,
"Varyings sharing the same location must "
"have the same underlying numerical type. "
}
}
- explicit_locations[location][i] = var;
+ explicit_locations[location][i].var = var;
+ explicit_locations[location][i].base_type =
+ type->without_array()->base_type;
i++;
/* We need to do some special handling for doubles as dvec3 and
gl_linked_shader *consumer)
{
glsl_symbol_table parameters;
- ir_variable *explicit_locations[MAX_VARYINGS_INCL_PATCH][4] =
- { {NULL, NULL} };
+ struct explicit_location_info explicit_locations[MAX_VARYING][4] = { 0 };
/* Find all shader outputs in the "producer" stage.
*/
return;
}
- if (!check_location_aliasing(explicit_locations, var, idx,
- var->data.location_frac, slot_limit,
- type, prog, producer->Stage)) {
+ if (type->without_array()->is_interface()) {
+ for (unsigned i = 0; i < type->without_array()->length; i++) {
+ const glsl_type *field_type = type->fields.structure[i].type;
+ unsigned field_location = type->fields.structure[i].location -
+ (type->fields.structure[i].patch ? VARYING_SLOT_PATCH0 :
+ VARYING_SLOT_VAR0);
+ if (!check_location_aliasing(explicit_locations, var,
+ field_location,
+ 0, field_location + 1,
+ field_type, prog,
+ producer->Stage)) {
+ return;
+ }
+ }
+ } else if (!check_location_aliasing(explicit_locations, var,
+ idx, var->data.location_frac,
+ slot_limit, type, prog,
+ producer->Stage)) {
return;
}
}
return;
}
- output = explicit_locations[idx][input->data.location_frac];
+ output = explicit_locations[idx][input->data.location_frac].var;
if (output == NULL ||
input->data.location != output->data.location) {