Mesa (master): nir: add int16 and uint16 type helpers

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 2 20:25:45 UTC 2020


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

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Mon May 11 00:42:51 2020 -0400

nir: add int16 and uint16 type helpers

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Reviewed-by: Rob Clark <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5002>

---

 src/compiler/glsl_types.cpp | 22 ++++++++++++++++++++++
 src/compiler/glsl_types.h   | 10 ++++++++++
 src/compiler/nir_types.cpp  | 12 ++++++++++++
 src/compiler/nir_types.h    |  2 ++
 4 files changed, 46 insertions(+)

diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
index a1c1beae872..d6315845e68 100644
--- a/src/compiler/glsl_types.cpp
+++ b/src/compiler/glsl_types.cpp
@@ -473,6 +473,28 @@ const glsl_type *glsl_type::get_float16_type() const
                        this->interface_row_major);
 }
 
+const glsl_type *glsl_type::get_int16_type() const
+{
+   assert(this->base_type == GLSL_TYPE_INT);
+
+   return get_instance(GLSL_TYPE_INT16,
+                       this->vector_elements,
+                       this->matrix_columns,
+                       this->explicit_stride,
+                       this->interface_row_major);
+}
+
+const glsl_type *glsl_type::get_uint16_type() const
+{
+   assert(this->base_type == GLSL_TYPE_UINT);
+
+   return get_instance(GLSL_TYPE_UINT16,
+                       this->vector_elements,
+                       this->matrix_columns,
+                       this->explicit_stride,
+                       this->interface_row_major);
+}
+
 static void
 hash_free_type_function(struct hash_entry *entry)
 {
diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index c1e0aea2eaa..aa1a4cec324 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -400,6 +400,16 @@ public:
     */
    const glsl_type *get_float16_type() const;
 
+   /**
+    * Gets the int16 version of this type.
+    */
+   const glsl_type *get_int16_type() const;
+
+   /**
+    * Gets the uint16 version of this type.
+    */
+   const glsl_type *get_uint16_type() const;
+
    /**
     * Get the instance of a built-in scalar, vector, or matrix type
     */
diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp
index 58815e12c4b..ac610488814 100644
--- a/src/compiler/nir_types.cpp
+++ b/src/compiler/nir_types.cpp
@@ -632,6 +632,18 @@ glsl_float16_type(const struct glsl_type *type)
    return type->get_float16_type();
 }
 
+const glsl_type *
+glsl_int16_type(const struct glsl_type *type)
+{
+   return type->get_int16_type();
+}
+
+const glsl_type *
+glsl_uint16_type(const struct glsl_type *type)
+{
+   return type->get_uint16_type();
+}
+
 void
 glsl_get_natural_size_align_bytes(const struct glsl_type *type,
                                   unsigned *size, unsigned *align)
diff --git a/src/compiler/nir_types.h b/src/compiler/nir_types.h
index 7f947d3f08e..77a9c787d98 100644
--- a/src/compiler/nir_types.h
+++ b/src/compiler/nir_types.h
@@ -210,6 +210,8 @@ const struct glsl_type *glsl_transposed_type(const struct glsl_type *type);
 const struct glsl_type *glsl_channel_type(const struct glsl_type *type);
 
 const struct glsl_type *glsl_float16_type(const struct glsl_type *type);
+const struct glsl_type *glsl_int16_type(const struct glsl_type *type);
+const struct glsl_type *glsl_uint16_type(const struct glsl_type *type);
 
 void glsl_get_natural_size_align_bytes(const struct glsl_type *type,
                                        unsigned *size, unsigned *align);



More information about the mesa-commit mailing list