From: Mike Blumenkrantz Date: Tue, 23 Jun 2020 18:50:37 +0000 (-0400) Subject: zink: generically handle matrix types X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9005c9cae40b93dee36a57cbf2a2917fd6902235;p=mesa.git zink: generically handle matrix types there's a bunch of glsl 1.10 tests for this Reviewed-by: Erik Faye-Lund Part-of: --- diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c index bcbb208de11..97ea028c939 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c +++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c @@ -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..."); } diff --git a/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c b/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c index 1b7c676486a..3a522c4bb77 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c +++ b/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.c @@ -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) diff --git a/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h b/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h index a1e9b6c655e..487d4f79fda 100644 --- a/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h +++ b/src/gallium/drivers/zink/nir_to_spirv/spirv_builder.h @@ -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);