summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2016-06-29 15:17:16 -0700
committerIan Romanick <[email protected]>2016-07-05 17:55:29 -0700
commit795d8dff89c7e6841f61e3b9851de95765f4d001 (patch)
tree7c70cf664246ad82caced3afc547eadc3d1038e0 /src/compiler
parent3119871bd9558e5881466b70a4c366d2f83bba82 (diff)
glsl: Document and enforce restriction on type values
Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/glsl_types.cpp7
-rw-r--r--src/compiler/glsl_types.h3
2 files changed, 10 insertions, 0 deletions
diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
index 884f3118e83..066a74e5283 100644
--- a/src/compiler/glsl_types.cpp
+++ b/src/compiler/glsl_types.cpp
@@ -55,6 +55,13 @@ glsl_type::glsl_type(GLenum gl_type,
vector_elements(vector_elements), matrix_columns(matrix_columns),
length(0)
{
+ /* Values of these types must fit in the two bits of
+ * glsl_type::sampled_type.
+ */
+ STATIC_ASSERT((unsigned(GLSL_TYPE_UINT) & 3) == unsigned(GLSL_TYPE_UINT));
+ STATIC_ASSERT((unsigned(GLSL_TYPE_INT) & 3) == unsigned(GLSL_TYPE_INT));
+ STATIC_ASSERT((unsigned(GLSL_TYPE_FLOAT) & 3) == unsigned(GLSL_TYPE_FLOAT));
+
mtx_lock(&glsl_type::mutex);
init_ralloc_type_ctx();
diff --git a/src/compiler/glsl_types.h b/src/compiler/glsl_types.h
index c3a01854fc2..7c4827d8f83 100644
--- a/src/compiler/glsl_types.h
+++ b/src/compiler/glsl_types.h
@@ -47,6 +47,9 @@ _mesa_glsl_release_types(void);
#endif
enum glsl_base_type {
+ /* Note: GLSL_TYPE_UINT, GLSL_TYPE_INT, and GLSL_TYPE_FLOAT must be 0, 1,
+ * and 2 so that they will fit in the 2 bits of glsl_type::sampled_type.
+ */
GLSL_TYPE_UINT = 0,
GLSL_TYPE_INT,
GLSL_TYPE_FLOAT,