Mesa (master): spirv: Use the new types helpers

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Sep 26 00:09:59 UTC 2020


Module: Mesa
Branch: master
Commit: 8cbb6640f0ea5b7d843293439233d15f3f38e108
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8cbb6640f0ea5b7d843293439233d15f3f38e108

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Mon Sep 14 16:30:16 2020 -0500

spirv: Use the new types helpers

Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6713>

---

 src/compiler/spirv/spirv_to_nir.c | 37 ++++++++-----------------------------
 1 file changed, 8 insertions(+), 29 deletions(-)

diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c
index d07a40b7246..e19fd027483 100644
--- a/src/compiler/spirv/spirv_to_nir.c
+++ b/src/compiler/spirv/spirv_to_nir.c
@@ -1366,23 +1366,12 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
    case SpvOpTypeInt: {
       int bit_size = w[2];
       const bool signedness = w[3];
+      vtn_fail_if(bit_size != 8 && bit_size != 16 &&
+                  bit_size != 32 && bit_size != 64,
+                  "Invalid int bit size: %u", bit_size);
       val->type->base_type = vtn_base_type_scalar;
-      switch (bit_size) {
-      case 64:
-         val->type->type = (signedness ? glsl_int64_t_type() : glsl_uint64_t_type());
-         break;
-      case 32:
-         val->type->type = (signedness ? glsl_int_type() : glsl_uint_type());
-         break;
-      case 16:
-         val->type->type = (signedness ? glsl_int16_t_type() : glsl_uint16_t_type());
-         break;
-      case 8:
-         val->type->type = (signedness ? glsl_int8_t_type() : glsl_uint8_t_type());
-         break;
-      default:
-         vtn_fail("Invalid int bit size: %u", bit_size);
-      }
+      val->type->type = signedness ? glsl_intN_t_type(bit_size) :
+                                     glsl_uintN_t_type(bit_size);
       val->type->length = 1;
       break;
    }
@@ -1390,19 +1379,9 @@ vtn_handle_type(struct vtn_builder *b, SpvOp opcode,
    case SpvOpTypeFloat: {
       int bit_size = w[2];
       val->type->base_type = vtn_base_type_scalar;
-      switch (bit_size) {
-      case 16:
-         val->type->type = glsl_float16_t_type();
-         break;
-      case 32:
-         val->type->type = glsl_float_type();
-         break;
-      case 64:
-         val->type->type = glsl_double_type();
-         break;
-      default:
-         vtn_fail("Invalid float bit size: %u", bit_size);
-      }
+      vtn_fail_if(bit_size != 16 && bit_size != 32 && bit_size != 64,
+                  "Invalid float bit size: %u", bit_size);
+      val->type->type = glsl_floatN_t_type(bit_size);
       val->type->length = 1;
       break;
    }



More information about the mesa-commit mailing list