[Mesa-dev] [PATCH 5/7] nir: add 16bit type information to glsl types

Daniel Schürmann daniel.schuermann at campus.tu-berlin.de
Wed Feb 7 18:47:59 UTC 2018


Signed-off-by: Daniel Schürmann <daniel.schuermann at campus.tu-berlin.de>
---
 src/compiler/glsl_types.h  | 15 +++++++++++++++
 src/compiler/nir_types.cpp | 12 ++++++++++++
 src/compiler/nir_types.h   |  1 +
 3 files changed, 28 insertions(+)

diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index ab0b263764..0704510630 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -80,6 +80,13 @@ enum glsl_base_type {
    GLSL_TYPE_ERROR
 };
 
+static inline bool glsl_base_type_is_16bit(enum glsl_base_type type)
+{
+   return type == GLSL_TYPE_FLOAT16 ||
+          type == GLSL_TYPE_UINT16 ||
+          type == GLSL_TYPE_INT16;
+}
+
 static inline bool glsl_base_type_is_64bit(enum glsl_base_type type)
 {
    return type == GLSL_TYPE_DOUBLE ||
@@ -574,6 +581,14 @@ public:
       return glsl_base_type_is_64bit(base_type);
    }
 
+   /**
+    * Query whether or not a type is 64-bit
+    */
+   bool is_16bit() const
+   {
+      return glsl_base_type_is_16bit(base_type);
+   }
+
    /**
     * Query whether or not a type is a non-array boolean type
     */
diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp
index cbdd452dc8..e8782729f7 100644
--- a/src/compiler/nir_types.cpp
+++ b/src/compiler/nir_types.cpp
@@ -151,6 +151,12 @@ glsl_get_record_location_offset(const struct glsl_type *type,
    return type->record_location_offset(length);
 }
 
+bool
+glsl_type_is_16bit(const glsl_type *type)
+{
+   return type->is_16bit();
+}
+
 bool
 glsl_type_is_64bit(const glsl_type *type)
 {
@@ -446,6 +452,12 @@ glsl_channel_type(const glsl_type *t)
       return glsl_uint64_t_type();
    case GLSL_TYPE_INT64:
       return glsl_int64_t_type();
+   case GLSL_TYPE_FLOAT16:
+      return glsl_float16_t_type();
+   case GLSL_TYPE_UINT16:
+      return glsl_uint16_t_type();
+   case GLSL_TYPE_INT16:
+      return glsl_int16_t_type();
    default:
       unreachable("Unhandled base type glsl_channel_type()");
    }
diff --git a/src/compiler/nir_types.h b/src/compiler/nir_types.h
index e2dfd1ef5b..88ae7cef33 100644
--- a/src/compiler/nir_types.h
+++ b/src/compiler/nir_types.h
@@ -113,6 +113,7 @@ glsl_get_bit_size(const struct glsl_type *type)
    return 0;
 }
 
+bool glsl_type_is_16bit(const struct glsl_type *type);
 bool glsl_type_is_64bit(const struct glsl_type *type);
 bool glsl_type_is_void(const struct glsl_type *type);
 bool glsl_type_is_error(const struct glsl_type *type);
-- 
2.14.1



More information about the mesa-dev mailing list