summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Iglesias Gonsálvez <[email protected]>2016-12-07 08:34:02 +0100
committerSamuel Iglesias Gonsálvez <[email protected]>2017-01-09 09:10:13 +0100
commit3a571fcc43e70731417f0b81cbce4b0a0c1be71d (patch)
treedd4127aa8da4a2634727180670a87c9492142e3d
parent59944a77ae5a01b6fd074def1d5031e0b7d5e47b (diff)
nir: add nir_get_nir_type_for_glsl_type()
v2 (Jason): - Refactor nir_get_nir_type_for_glsl_type() to avoid using unneeded helpers (Jason) v3: - Use return directly (Jason) Signed-off-by: Samuel Iglesias Gonsálvez <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
-rw-r--r--src/compiler/nir/nir.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index d17924c2aac..654a26728ac 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -675,6 +675,30 @@ 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)
+{
+ switch (glsl_get_base_type(type)) {
+ case GLSL_TYPE_BOOL:
+ return nir_type_bool32;
+ break;
+ case GLSL_TYPE_UINT:
+ return nir_type_uint32;
+ break;
+ case GLSL_TYPE_INT:
+ return nir_type_int32;
+ break;
+ case GLSL_TYPE_FLOAT:
+ return nir_type_float32;
+ break;
+ case GLSL_TYPE_DOUBLE:
+ return nir_type_float64;
+ break;
+ default:
+ unreachable("unknown type");
+ }
+}
+
typedef enum {
NIR_OP_IS_COMMUTATIVE = (1 << 0),
NIR_OP_IS_ASSOCIATIVE = (1 << 1),