[Mesa-dev] [PATCH v3 12/22] nir: add nir_get_nir_type_for_glsl_type()
Samuel Iglesias Gonsálvez
siglesias at igalia.com
Thu Jan 5 10:18:35 UTC 2017
v2 (Jason):
- Refactor nir_get_nir_type_for_glsl_type() to avoid using unneeded helpers (Jason)
Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
---
src/compiler/nir/nir.h | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 0596d31b903..09326a25a54 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -675,6 +675,33 @@ 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)
+{
+ nir_alu_type ret = nir_type_invalid;
+ switch (glsl_get_base_type(type)) {
+ case GLSL_TYPE_BOOL:
+ ret = nir_type_bool32;
+ break;
+ case GLSL_TYPE_UINT:
+ ret = nir_type_uint32;
+ break;
+ case GLSL_TYPE_INT:
+ ret = nir_type_int32;
+ break;
+ case GLSL_TYPE_FLOAT:
+ ret = nir_type_float32;
+ break;
+ case GLSL_TYPE_DOUBLE:
+ ret = nir_type_float64;
+ break;
+ default:
+ unreachable("unknown type");
+ };
+
+ return ret;
+}
+
typedef enum {
NIR_OP_IS_COMMUTATIVE = (1 << 0),
NIR_OP_IS_ASSOCIATIVE = (1 << 1),
--
2.11.0
More information about the mesa-dev
mailing list