Mesa (master): compiler/types: Add glsl_baseN_t_type(bit_size) helpers
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Sep 26 00:09:59 UTC 2020
Module: Mesa
Branch: master
Commit: de295b61da3465e1341d43f9acc8b22225c83358
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=de295b61da3465e1341d43f9acc8b22225c83358
Author: Jason Ekstrand <jason at jlekstrand.net>
Date: Mon Sep 14 16:30:03 2020 -0500
compiler/types: Add glsl_baseN_t_type(bit_size) helpers
Reviewed-by: Jesse Natalie <jenatali at microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6713>
---
src/compiler/nir_types.cpp | 38 ++++++++++++++++++++++++++++++++++++++
src/compiler/nir_types.h | 3 +++
2 files changed, 41 insertions(+)
diff --git a/src/compiler/nir_types.cpp b/src/compiler/nir_types.cpp
index 1fff15c7cd5..698706e883c 100644
--- a/src/compiler/nir_types.cpp
+++ b/src/compiler/nir_types.cpp
@@ -420,6 +420,18 @@ glsl_float16_t_type(void)
return glsl_type::float16_t_type;
}
+const glsl_type *
+glsl_floatN_t_type(unsigned bit_size)
+{
+ switch (bit_size) {
+ case 16: return glsl_type::float16_t_type;
+ case 32: return glsl_type::float_type;
+ case 64: return glsl_type::double_type;
+ default:
+ unreachable("Unsupported bit size");
+ }
+}
+
const glsl_type *
glsl_vec_type(unsigned n)
{
@@ -492,6 +504,32 @@ glsl_uint8_t_type(void)
return glsl_type::uint8_t_type;
}
+const glsl_type *
+glsl_intN_t_type(unsigned bit_size)
+{
+ switch (bit_size) {
+ case 8: return glsl_type::int8_t_type;
+ case 16: return glsl_type::int16_t_type;
+ case 32: return glsl_type::int_type;
+ case 64: return glsl_type::int64_t_type;
+ default:
+ unreachable("Unsupported bit size");
+ }
+}
+
+const glsl_type *
+glsl_uintN_t_type(unsigned bit_size)
+{
+ switch (bit_size) {
+ case 8: return glsl_type::uint8_t_type;
+ case 16: return glsl_type::uint16_t_type;
+ case 32: return glsl_type::uint_type;
+ case 64: return glsl_type::uint64_t_type;
+ default:
+ unreachable("Unsupported bit size");
+ }
+}
+
const glsl_type *
glsl_bool_type(void)
{
diff --git a/src/compiler/nir_types.h b/src/compiler/nir_types.h
index 14fae6a5f58..6e778153b21 100644
--- a/src/compiler/nir_types.h
+++ b/src/compiler/nir_types.h
@@ -165,6 +165,7 @@ const struct glsl_type *glsl_void_type(void);
const struct glsl_type *glsl_float_type(void);
const struct glsl_type *glsl_float16_t_type(void);
const struct glsl_type *glsl_double_type(void);
+const struct glsl_type *glsl_floatN_t_type(unsigned bit_size);
const struct glsl_type *glsl_vec_type(unsigned n);
const struct glsl_type *glsl_dvec_type(unsigned n);
const struct glsl_type *glsl_vec4_type(void);
@@ -177,6 +178,8 @@ const struct glsl_type *glsl_int16_t_type(void);
const struct glsl_type *glsl_uint16_t_type(void);
const struct glsl_type *glsl_int8_t_type(void);
const struct glsl_type *glsl_uint8_t_type(void);
+const struct glsl_type *glsl_intN_t_type(unsigned bit_size);
+const struct glsl_type *glsl_uintN_t_type(unsigned bit_size);
const struct glsl_type *glsl_bool_type(void);
const struct glsl_type *glsl_scalar_type(enum glsl_base_type base_type);
More information about the mesa-commit
mailing list