vnt_variables uses interface_type on several use cases, but on nir variable it is more limited. From nir.h:
/** * For variables that are in an interface block or are an instance of an * interface block, this is the \c GLSL_TYPE_INTERFACE type for that block. * * \sa ir_variable::location */ But interface blocks expects the type to be an struct, so those cases should not be filled. For example, glsl checks if a variable is in an uniform block if it is an uniform and has an interface type. One example of why this is needed: gl_PatchVerticesIn is lowered to an uniform. Without this change, it would include a interface_type. Then, we would try to initialize the uniform block, and find that it doesn't have any component. v2: rearrange/clean code to only set interface_type for structs, instead of a default assignment, and a NULL reassignement for non-structs (Timothy) Reviewed-by: Timothy Arceri <tarc...@itsqueeze.com> --- src/compiler/spirv/vtn_variables.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index 0606ae0e243..541ba73e643 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -1789,6 +1789,12 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val, var_is_patch_cb, &var->patch); } + var->var = rzalloc(b->shader, nir_variable); + var->var->name = ralloc_strdup(var->var, val->name); + var->var->type = var->type->type; + var->var->data.mode = nir_mode; + var->var->data.patch = var->patch; + /* For inputs and outputs, we immediately split structures. This * is for a couple of reasons. For one, builtins may all come in * a struct and we really want those split out into separate @@ -1808,14 +1814,9 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val, interface_type = var->type->array_element; } - var->var = rzalloc(b->shader, nir_variable); - var->var->name = ralloc_strdup(var->var, val->name); - var->var->type = var->type->type; - var->var->interface_type = interface_type->type; - var->var->data.mode = nir_mode; - var->var->data.patch = var->patch; - if (glsl_type_is_struct(interface_type->type)) { + var->var->interface_type = 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.14.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev