diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h index 67c2d4420ae..8e27298a026 100644 --- a/src/compiler/spirv/vtn_private.h +++ b/src/compiler/spirv/vtn_private.h @@ -556,7 +556,6 @@ struct vtn_variable { bool explicit_binding; unsigned offset; unsigned input_attachment_index; - bool patch; nir_variable *var; diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index 01d79a9f2be..f63dd322bdb 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -1282,11 +1282,11 @@ apply_var_decoration(struct vtn_builder *b, static void var_is_patch_cb(struct vtn_builder *b, struct vtn_value *val, int member, - const struct vtn_decoration *dec, void *out_is_patch) + const struct vtn_decoration *dec, void *void_var) { - if (dec->decoration == SpvDecorationPatch) { - *((bool *) out_is_patch) = true; - } + struct vtn_variable *vtn_var = void_var; + if (dec->decoration == SpvDecorationPatch) + vtn_var->var->data.patch = true; } static void @@ -1308,7 +1308,7 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member, vtn_var->input_attachment_index = dec->operands[0]; return; case SpvDecorationPatch: - vtn_var->patch = true; + vtn_var->var->data.patch = true; break; case SpvDecorationOffset: vtn_var->offset = dec->operands[0]; @@ -1353,7 +1353,7 @@ var_decoration_cb(struct vtn_builder *b, struct vtn_value *val, int member, location += VERT_ATTRIB_GENERIC0; } else if (vtn_var->mode == vtn_variable_mode_input || vtn_var->mode == vtn_variable_mode_output) { - location += vtn_var->patch ? VARYING_SLOT_PATCH0 : VARYING_SLOT_VAR0; + location += vtn_var->var->data.patch ? VARYING_SLOT_PATCH0 : VARYING_SLOT_VAR0; } else if (vtn_var->mode == vtn_variable_mode_call_data || vtn_var->mode == vtn_variable_mode_ray_payload) { /* This location is fine as-is */ @@ -1854,6 +1854,11 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val, case vtn_variable_mode_input: case vtn_variable_mode_output: { + var->var = rzalloc(b->shader, nir_variable); + var->var->name = ralloc_strdup(var->var, val->name); + var->var->type = vtn_type_get_nir_type(b, var->type, var->mode); + var->var->data.mode = nir_mode; + /* In order to know whether or not we're a per-vertex inout, we need * the patch qualifier. This means walking the variable decorations * early before we actually create any variables. Not a big deal. @@ -1870,21 +1875,14 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val, * it to be all or nothing, we'll call it patch if any of the members * are declared patch. */ - var->patch = false; - vtn_foreach_decoration(b, val, var_is_patch_cb, &var->patch); + vtn_foreach_decoration(b, val, var_is_patch_cb, var); if (glsl_type_is_array(var->type->type) && glsl_type_is_struct_or_ifc(without_array->type)) { vtn_foreach_decoration(b, vtn_value(b, without_array->id, vtn_value_type_type), - var_is_patch_cb, &var->patch); + var_is_patch_cb, var); } - var->var = rzalloc(b->shader, nir_variable); - var->var->name = ralloc_strdup(var->var, val->name); - var->var->type = vtn_type_get_nir_type(b, var->type, var->mode); - var->var->data.mode = nir_mode; - var->var->data.patch = var->patch; - struct vtn_type *per_vertex_type = var->type; if (nir_is_per_vertex_io(var->var, b->shader->info.stage)) per_vertex_type = var->type->array_element; @@ -1923,7 +1921,7 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val, for (unsigned i = 0; i < var->var->num_members; i++) { var->var->members[i].mode = nir_mode; - var->var->members[i].patch = var->patch; + var->var->members[i].patch = var->var->data.patch; var->var->members[i].location = -1; } }