From: Brian Paul Date: Wed, 6 Aug 2008 17:22:36 +0000 (-0600) Subject: mesa: glsl: check that attribute vars are of float/vec/mat type X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=64a795d8e60c42e7ec8c370507864faf3f85d99e;p=mesa.git mesa: glsl: check that attribute vars are of float/vec/mat type --- 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 @@ -874,6 +874,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);