Skip to content

Commit

Permalink
glsl: add varying resources for arrays of complex types
Browse files Browse the repository at this point in the history
Fixes some parts of

KHR-GL45.enhanced_layouts.varying_structure_locations

TODO: fix locations for TCS/TES/GS arrayed things

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
  • Loading branch information
imirkin committed Sep 11, 2017
1 parent c2985f8 commit 4d9d4c4
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/compiler/glsl/linker.cpp
Expand Up @@ -3870,7 +3870,41 @@ add_shader_variable(const struct gl_context *ctx,
}
return true;
}

case GLSL_TYPE_ARRAY: {
/* The ARB_program_interface_query spec says:
*
* "For an active variable declared as an array of basic types, a
* single entry will be generated, with its name string formed by
* concatenating the name of the array and the string "[0]"."
*
* "For an active variable declared as an array of an aggregate data
* type (structures or arrays), a separate entry will be generated
* for each active array element, unless noted immediately below.
* The name of each entry is formed by concatenating the name of
* the array, the "[" character, an integer identifying the element
* number, and the "]" character. These enumeration rules are
* applied recursively, treating each enumerated array element as a
* separate active variable."
*/
const struct glsl_type *array_type = type->fields.array;
if (array_type->base_type == GLSL_TYPE_STRUCT ||
array_type->base_type == GLSL_TYPE_ARRAY) {
unsigned elem_location = location;
unsigned stride = array_type->count_attribute_slots(false);
for (unsigned i = 0; i < type->length; i++) {
char *elem = ralloc_asprintf(shProg, "%s[%d]", name, i);
if (!add_shader_variable(ctx, shProg, resource_set,
stage_mask, programInterface,
var, elem, array_type,
use_implicit_location, elem_location,
outermost_struct_type))
return false;
elem_location += stride;
}
return true;
}
/* fallthrough */
}
default: {
/* The ARB_program_interface_query spec says:
*
Expand Down

0 comments on commit 4d9d4c4

Please sign in to comment.