summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--glsl_types.cpp17
-rw-r--r--glsl_types.h10
2 files changed, 27 insertions, 0 deletions
diff --git a/glsl_types.cpp b/glsl_types.cpp
index af6a40800b..2b06a33553 100644
--- a/glsl_types.cpp
+++ b/glsl_types.cpp
@@ -142,3 +142,20 @@ _mesa_glsl_get_vector_type(unsigned base_type, unsigned vector_length)
return glsl_error_type;
}
}
+
+
+const glsl_type *glsl_type::get_base_type() const
+{
+ switch (base_type) {
+ case GLSL_TYPE_UINT:
+ return glsl_uint_type;
+ case GLSL_TYPE_INT:
+ return glsl_int_type;
+ case GLSL_TYPE_FLOAT:
+ return glsl_float_type;
+ case GLSL_TYPE_BOOL:
+ return glsl_bool_type;
+ default:
+ return glsl_error_type;
+ }
+}
diff --git a/glsl_types.h b/glsl_types.h
index 7c48e792eb..97d8390e60 100644
--- a/glsl_types.h
+++ b/glsl_types.h
@@ -138,6 +138,16 @@ struct glsl_type {
}
/**
+ * For numeric and boolean derrived types returns the basic scalar type
+ *
+ * If the type is a numeric or boolean scalar, vector, or matrix type,
+ * this function gets the scalar type of the individual components. For
+ * all other types, including arrays of numeric or boolean types, the
+ * error type is returned.
+ */
+ const glsl_type *get_base_type() const;
+
+ /**
* Query whether or not a type is a scalar (non-vector and non-matrix).
*/
bool is_scalar() const