spirv: Support EXT_mesh_shader indices and mark them per-primitive.
authorTimur Kristóf <timur.kristof@gmail.com>
Thu, 20 Jan 2022 15:33:27 +0000 (16:33 +0100)
committerMarge Bot <emma+marge@anholt.net>
Fri, 2 Sep 2022 16:18:33 +0000 (16:18 +0000)
They are not defined as per-primitive in the EXT, but they behave
like per-primitive outputs so it's easier to treat them like that.
They may still require special treatment in the backend in order to
control where and how they are stored.

Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18366>

src/compiler/spirv/vtn_variables.c

index 89e3996..196f1a0 100644 (file)
@@ -1143,6 +1143,9 @@ vtn_get_builtin_location(struct vtn_builder *b,
    case SpvBuiltInPrimitiveCountNV:
       *location = VARYING_SLOT_PRIMITIVE_COUNT;
       break;
+   case SpvBuiltInPrimitivePointIndicesEXT:
+   case SpvBuiltInPrimitiveLineIndicesEXT:
+   case SpvBuiltInPrimitiveTriangleIndicesEXT:
    case SpvBuiltInPrimitiveIndicesNV:
       *location = VARYING_SLOT_PRIMITIVE_INDICES;
       break;
@@ -1236,6 +1239,19 @@ apply_var_decoration(struct vtn_builder *b,
       case SpvBuiltInCullDistancePerViewNV:
          var_data->compact = true;
          break;
+      case SpvBuiltInPrimitivePointIndicesEXT:
+      case SpvBuiltInPrimitiveLineIndicesEXT:
+      case SpvBuiltInPrimitiveTriangleIndicesEXT:
+         /* Not defined as per-primitive in the EXT, but they behave
+          * like per-primitive outputs so it's easier to treat them like that.
+          * They may still require special treatment in the backend in order to
+          * control where and how they are stored.
+          *
+          * EXT_mesh_shader: write-only array of vectors indexed by the primitive index
+          * NV_mesh_shader: read/write flat array
+          */
+         var_data->per_primitive = true;
+         break;
       default:
          break;
       }