Mesa (master): nir: Add glsl_base_type unsigned -> signed version helper

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Sep 25 20:42:55 UTC 2020


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

Author: Jesse Natalie <jenatali at microsoft.com>
Date:   Mon Jun 22 15:00:20 2020 -0700

nir: Add glsl_base_type unsigned -> signed version helper

Reviewed-by: Boris Brezillon <boris.brezillon at collabora.com>
Reviewed-by: Dave Airlie <airlied at redhat.com>
Reviewed-by: Daniel Stone <daniels at collabora.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6035>

---

 src/compiler/glsl_types.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index 8058425e0d0..d3ca3c86d5e 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -218,6 +218,27 @@ glsl_unsigned_base_type_of(enum glsl_base_type type)
    }
 }
 
+static inline enum glsl_base_type
+glsl_signed_base_type_of(enum glsl_base_type type)
+{
+   switch (type) {
+   case GLSL_TYPE_UINT:
+      return GLSL_TYPE_INT;
+   case GLSL_TYPE_UINT8:
+      return GLSL_TYPE_INT8;
+   case GLSL_TYPE_UINT16:
+      return GLSL_TYPE_INT16;
+   case GLSL_TYPE_UINT64:
+      return GLSL_TYPE_INT64;
+   default:
+      assert(type == GLSL_TYPE_INT ||
+             type == GLSL_TYPE_INT8 ||
+             type == GLSL_TYPE_INT16 ||
+             type == GLSL_TYPE_INT64);
+      return type;
+   }
+}
+
 enum glsl_sampler_dim {
    GLSL_SAMPLER_DIM_1D = 0,
    GLSL_SAMPLER_DIM_2D,



More information about the mesa-commit mailing list