mesa: glsl: check that attribute vars are of float/vec/mat type
This commit is contained in:
@@ -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 */
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user