summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2008-08-06 11:22:36 -0600
committerBrian Paul <[email protected]>2008-08-06 11:22:36 -0600
commit64a795d8e60c42e7ec8c370507864faf3f85d99e (patch)
tree9fbcad086b8e306ae504946359f0acd483bccd85 /src/mesa
parentb9be69b85e8955fa9f773a65e7c3de5c4bb6e507 (diff)
mesa: glsl: check that attribute vars are of float/vec/mat type
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/shader/slang/slang_codegen.c8
-rw-r--r--src/mesa/shader/slang/slang_typeinfo.c28
-rw-r--r--src/mesa/shader/slang/slang_typeinfo.h3
3 files changed, 39 insertions, 0 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index edb060a23f5..f717a22ac93 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -3726,6 +3726,14 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
if (dbg) printf("VARYING ");
}
else if (var->type.qualifier == SLANG_QUAL_ATTRIBUTE) {
+ /* attributes must be float, vec or mat */
+ if (!_slang_type_is_float_vec_mat(var->type.specifier.type)) {
+ slang_info_log_error(A->log,
+ "attribute '%s' must be float/vector/matrix",
+ varName);
+ return GL_FALSE;
+ }
+
if (prog) {
/* user-defined vertex attribute */
const GLint attr = -1; /* unknown */
diff --git a/src/mesa/shader/slang/slang_typeinfo.c b/src/mesa/shader/slang/slang_typeinfo.c
index 8572118f3f3..b3255512ba0 100644
--- a/src/mesa/shader/slang/slang_typeinfo.c
+++ b/src/mesa/shader/slang/slang_typeinfo.c
@@ -875,6 +875,34 @@ _slang_type_is_vector(slang_type_specifier_type ty)
/**
+ * Determine if a type is a float, float vector or float matrix.
+ * \return GL_TRUE if so, GL_FALSE otherwise
+ */
+GLboolean
+_slang_type_is_float_vec_mat(slang_type_specifier_type ty)
+{
+ switch (ty) {
+ case SLANG_SPEC_FLOAT:
+ case SLANG_SPEC_VEC2:
+ case SLANG_SPEC_VEC3:
+ case SLANG_SPEC_VEC4:
+ case SLANG_SPEC_MAT2:
+ case SLANG_SPEC_MAT3:
+ case SLANG_SPEC_MAT4:
+ case SLANG_SPEC_MAT23:
+ case SLANG_SPEC_MAT32:
+ case SLANG_SPEC_MAT24:
+ case SLANG_SPEC_MAT42:
+ case SLANG_SPEC_MAT34:
+ case SLANG_SPEC_MAT43:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
* Given a vector type, return the type of the vector's elements.
* For a matrix, return the type of the columns.
*/
diff --git a/src/mesa/shader/slang/slang_typeinfo.h b/src/mesa/shader/slang/slang_typeinfo.h
index 960e99bda23..b3ad06b65c2 100644
--- a/src/mesa/shader/slang/slang_typeinfo.h
+++ b/src/mesa/shader/slang/slang_typeinfo.h
@@ -191,6 +191,9 @@ _slang_type_is_matrix(slang_type_specifier_type);
extern GLboolean
_slang_type_is_vector(slang_type_specifier_type);
+extern GLboolean
+_slang_type_is_float_vec_mat(slang_type_specifier_type);
+
extern slang_type_specifier_type
_slang_type_base(slang_type_specifier_type);