[Mesa-dev] [RFC PATCH 07/13] spirv/nir: use array_element as interface_type for any array

Alejandro PiƱeiro apinheiro at igalia.com
Sat Dec 8 11:48:15 UTC 2018


This commit removes several of the checks when assigning the
array_element as the interface_type. Reading the comment, and what
commit bb04b84114d2780307f9cbd04447216c3f2d1c0c added on top, this is
done conservatively, for only the builtin cases that makes sense at
that moment. But even if those were true, that should be already
validated on the SPIR-V shader.

Additionally, it is not clear that user-defined array of input/output
blocks are not allowed on Vulkan. And for sure, they will be allowed
on OpenGL (via ARB_gl_spirv), so that method was too restrictive.
---
 src/compiler/spirv/vtn_variables.c | 29 +++++------------------------
 1 file changed, 5 insertions(+), 24 deletions(-)

diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c
index 91e351187d2..be3545aad47 100644
--- a/src/compiler/spirv/vtn_variables.c
+++ b/src/compiler/spirv/vtn_variables.c
@@ -1664,24 +1664,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
 add_missing_member_locations(struct vtn_variable *var,
                              bool is_vertex_input)
@@ -1871,12 +1853,11 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val,
        */
 
       struct vtn_type *interface_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.
+      if (!var->patch && glsl_type_is_array(var->type->type)) {
+         /* On Vulkan, Geometry shaders and some Tessellation, some inputs
+          * come in per-vertex arrays, so we need to check for arrays. On
+          * OpenGL we have the same, plus the possibility of user-defined
+          * inout block arrays.
           */
          interface_type = var->type->array_element;
       }
-- 
2.19.1



More information about the mesa-dev mailing list