nir/types: Add glsl_float16_type() helper
authorKristian H. Kristensen <hoegsberg@google.com>
Wed, 19 Feb 2020 21:13:15 +0000 (13:13 -0800)
committerMarge Bot <eric+marge@anholt.net>
Mon, 24 Feb 2020 17:24:13 +0000 (17:24 +0000)
This returns the float16 version of a float type.

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

src/compiler/glsl_types.cpp
src/compiler/glsl_types.h
src/compiler/nir_types.cpp
src/compiler/nir_types.h

index 79e2f684fcfd2f5fe6bddc520156f8d6518d6535..3af8e034cd171590dbfda11e3a27b25604175afd 100644 (file)
@@ -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)
index ae1a6e0fa7c71434b79ffb4f00c1f7a8272d1be9..4b1f0ab09ea829a671ce3e11ebd5bddccfa1140d 100644 (file)
@@ -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
     */
index 37dde30dd6c6eaf0071bf77f6ad43b39b914a3c2..807529fb2b87c366f12206ca4271899a24ef11e3 100644 (file)
@@ -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)
index 4dfc4648e3df14c9c37057e5da62a8566c02edf6..3351ce9bf9f74aeb577baa4aee581cd3b3f5ce71 100644 (file)
@@ -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);