From 94d2a51453de5f9e723fed8134872441ebd6d7a2 Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Wed, 3 Mar 2021 14:45:46 -0800 Subject: [PATCH] spirv: Reuse nir_is_per_vertex_io() Reviewed-by: Jason Ekstrand Part-of: --- src/compiler/spirv/vtn_variables.c | 33 ++++-------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index a7f9e8ad23d..5144bd43120 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -1673,24 +1673,6 @@ vtn_pointer_from_ssa(struct vtn_builder *b, nir_ssa_def *ssa, return ptr; } -static bool -is_per_vertex_inout(const struct vtn_variable *var, gl_shader_stage stage) -{ - if (var->patch || !glsl_type_is_array(var->type->type)) - return false; - - if (var->mode == vtn_variable_mode_input) { - return stage == MESA_SHADER_TESS_CTRL || - stage == MESA_SHADER_TESS_EVAL || - stage == MESA_SHADER_GEOMETRY; - } - - if (var->mode == vtn_variable_mode_output) - return stage == MESA_SHADER_TESS_CTRL; - - return false; -} - static void assign_missing_member_locations(struct vtn_variable *var) { @@ -1900,23 +1882,16 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val, * able to preserve that information. */ - struct vtn_type *per_vertex_type = var->type; - if (is_per_vertex_inout(var, b->shader->info.stage)) { - /* In Geometry shaders (and some tessellation), inputs come - * in per-vertex arrays. However, some builtins come in - * non-per-vertex, hence the need for the is_array check. In - * any case, there are no non-builtin arrays allowed so this - * check should be sufficient. - */ - per_vertex_type = var->type->array_element; - } - 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; + /* Figure out the interface block type. */ struct vtn_type *iface_type = per_vertex_type; if (var->mode == vtn_variable_mode_output &&