Current code assumes that if the type is an struct it would behave as a block. That is not always the case (like xfb_offset/xfb_buffer assignment on arrays of structs vs arrays of blocks), so we need to differentiate. --- src/compiler/spirv/vtn_variables.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index be3545aad47..6d7d5dfc691 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -1677,9 +1677,12 @@ add_missing_member_locations(struct vtn_variable *var, * * “If the structure type is a Block but without a Location, then each * of its members must have a Location decoration.” + * */ - assert(var->base_location != -1 || - var->var->members[i].location != -1); + if (var->type->block) { + assert(var->base_location != -1 || + var->var->members[i].location != -1); + } /* From the Vulkan spec: * @@ -1692,8 +1695,12 @@ add_missing_member_locations(struct vtn_variable *var, else var->var->members[i].location = location; + /* Below we use type instead of interface_type, because interface_type + * is only available when it is a Block. This code also supports + * input/outputs that are just structs + */ const struct glsl_type *member_type = - glsl_get_struct_field(var->var->interface_type, i); + glsl_get_struct_field(glsl_without_array(var->type->type), i); location += glsl_count_attribute_slots(member_type, is_vertex_input); @@ -1862,9 +1869,11 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val, interface_type = var->type->array_element; } - if (glsl_type_is_struct(interface_type->type)) { + if (interface_type->block) { var->var->interface_type = interface_type->type; + } + if (glsl_type_is_struct(interface_type->type)) { /* It's a struct. Set it up as per-member. */ var->var->num_members = glsl_get_length(interface_type->type); var->var->members = rzalloc_array(var->var, struct nir_variable_data, -- 2.19.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev