Mesa (master): nir/types: Add glsl_float16_type() helper

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Feb 24 17:42:03 UTC 2020


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

Author: Kristian H. Kristensen <hoegsberg at google.com>
Date:   Wed Feb 19 13:13:15 2020 -0800

nir/types: Add glsl_float16_type() helper

This returns the float16 version of a float type.

Reviewed-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3822>

---

 src/compiler/glsl_types.cpp | 10 ++++++++++
 src/compiler/glsl_types.h   |  5 +++++
 src/compiler/nir_types.cpp  |  6 ++++++
 src/compiler/nir_types.h    |  2 ++
 4 files changed, 23 insertions(+)

diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
index 79e2f684fcf..3af8e034cd1 100644
--- a/src/compiler/glsl_types.cpp
+++ b/src/compiler/glsl_types.cpp
@@ -462,6 +462,16 @@ const glsl_type *glsl_type::get_bare_type() const
    unreachable("Invalid base type");
 }
 
+const glsl_type *glsl_type::get_float16_type() const
+{
+   assert(this->base_type == GLSL_TYPE_FLOAT);
+
+   return get_instance(GLSL_TYPE_FLOAT16,
+                       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 ae1a6e0fa7c..4b1f0ab09ea 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -394,6 +394,11 @@ public:
     */
    const glsl_type *get_bare_type() const;
 
+   /**
+    * Gets the float16 version of this type.
+    */
+   const glsl_type *get_float16_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 37dde30dd6c..807529fb2b8 100644
--- a/src/compiler/nir_types.cpp
+++ b/src/compiler/nir_types.cpp
@@ -620,6 +620,12 @@ glsl_channel_type(const glsl_type *t)
    }
 }
 
+const glsl_type *
+glsl_float16_type(const struct glsl_type *type)
+{
+   return type->get_float16_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 4dfc4648e3d..3351ce9bf9f 100644
--- a/src/compiler/nir_types.h
+++ b/src/compiler/nir_types.h
@@ -198,6 +198,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);
+
 void glsl_get_natural_size_align_bytes(const struct glsl_type *type,
                                        unsigned *size, unsigned *align);
 



More information about the mesa-commit mailing list