zink: generically handle matrix types
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Tue, 23 Jun 2020 18:50:37 +0000 (14:50 -0400)
committerMarge Bot <eric+marge@anholt.net>
Thu, 3 Sep 2020 14:01:09 +0000 (14:01 +0000)
there's a bunch of glsl 1.10 tests for this

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6268>

src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c
src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h

index bcbb208de1177203c088a6511e582597a0c40662..97ea028c939f14d00980b4b8b2ebeba31fdd0ae2 100644 (file)
@@ -285,6 +285,12 @@ get_glsl_type(struct ntv_context *ctx, const struct glsl_type *type)
       return ret;
    }
 
+   if (glsl_type_is_matrix(type))
+      return spirv_builder_type_matrix(&ctx->builder,
+                                       spirv_builder_type_vector(&ctx->builder,
+                                                                 get_glsl_basetype(ctx, glsl_get_base_type(type)),
+                                                                 glsl_get_vector_elements(type)),
+                                       glsl_get_matrix_columns(type));
 
    unreachable("we shouldn't get here, I think...");
 }
index 1b7c676486add9665a57638b2e428c24caff5b18..3a522c4bb7704f2a2d57894fcee51b008fbfff74 100644 (file)
@@ -915,6 +915,15 @@ spirv_builder_type_vector(struct spirv_builder *b, SpvId component_type,
    return get_type_def(b, SpvOpTypeVector, args, ARRAY_SIZE(args));
 }
 
+SpvId
+spirv_builder_type_matrix(struct spirv_builder *b, SpvId component_type,
+                          unsigned component_count)
+{
+   assert(component_count > 1);
+   uint32_t args[] = { component_type, component_count };
+   return get_type_def(b, SpvOpTypeMatrix, args, ARRAY_SIZE(args));
+}
+
 SpvId
 spirv_builder_type_array(struct spirv_builder *b, SpvId component_type,
                          SpvId length)
index a1e9b6c655ef131b295a1a533d8a5f6acef8b560..487d4f79fda153ee2cbfbea7df535e2477524985 100644 (file)
@@ -301,6 +301,10 @@ SpvId
 spirv_builder_type_vector(struct spirv_builder *b, SpvId component_type,
                           unsigned component_count);
 
+SpvId
+spirv_builder_type_matrix(struct spirv_builder *b, SpvId component_type,
+                          unsigned component_count);
+
 SpvId
 spirv_builder_type_array(struct spirv_builder *b, SpvId component_type,
                          SpvId length);