[Mesa-dev] [PATCH v2 13/25] nir: add nir_get_nir_type_for_glsl_type()
Juan A. Suarez Romero
jasuarez at igalia.com
Fri Dec 16 14:48:59 UTC 2016
From: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
---
src/compiler/nir/nir.h | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 544d4ba..9310dab 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -670,6 +670,25 @@ nir_alu_type_get_base_type(nir_alu_type type)
return type & NIR_ALU_TYPE_BASE_TYPE_MASK;
}
+static inline nir_alu_type
+nir_get_nir_type_for_glsl_type(const struct glsl_type *type)
+{
+ unsigned bit_size = glsl_get_bit_size(type);
+ if (glsl_type_is_boolean(type))
+ return (nir_alu_type)(nir_type_bool | bit_size);
+
+ if (glsl_type_is_integer(type)) {
+ if (glsl_get_base_type(type) == GLSL_TYPE_UINT)
+ return (nir_alu_type)(nir_type_uint | bit_size);
+ else
+ return (nir_alu_type)(nir_type_int | bit_size);
+ }
+
+ if (glsl_type_is_float(type))
+ return (nir_alu_type)(nir_type_float | bit_size);
+ unreachable("unknown type");
+}
+
typedef enum {
NIR_OP_IS_COMMUTATIVE = (1 << 0),
NIR_OP_IS_ASSOCIATIVE = (1 << 1),
--
2.9.3
More information about the mesa-dev
mailing list