summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2015-08-31 18:44:42 -0700
committerEmil Velikov <emil.l.velikov@gmail.com>2015-09-17 14:58:47 +0100
commit39ececa38673935790c233cfac15b4da8d891658 (patch)
tree4c37435c8764e0765bab93a03de4882c47e9981c
parent0a8c727a9d22b9823c8c6a6b58f9b1c67d6dae17 (diff)
mesa: Don't allow wrong type setters for matrix uniforms
Previously we would allow glUniformMatrix4fv on a dmat4 and glUniformMatrix4dv on a mat4. Both are illegal. That later also overwrites the storage for the mat4 and causes bad things to happen. Should fix the (new) arb_gpu_shader_fp64-wrong-type-setter piglit test. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Timothy Arceri <t_arceri@yahoo.com.au> Cc: Dave Airlie <airlied@redhat.com> Cc: "10.6 11.0" <mesa-stable@lists.freedesktop.org> (cherry picked from commit 7237c937af3b495191bee2f7240901e3a9daf1fb)
-rw-r--r--src/mesa/main/uniform_query.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 4ee1df3ead8..4794d2509aa 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -910,6 +910,31 @@ _mesa_uniform_matrix(struct gl_context *ctx, struct gl_shader_program *shProg,
}
}
+ /* Section 2.11.7 (Uniform Variables) of the OpenGL 4.2 Core Profile spec
+ * says:
+ *
+ * "If any of the following conditions occur, an INVALID_OPERATION
+ * error is generated by the Uniform* commands, and no uniform values
+ * are changed:
+ *
+ * ...
+ *
+ * - if the uniform declared in the shader is not of type boolean and
+ * the type indicated in the name of the Uniform* command used does
+ * not match the type of the uniform"
+ *
+ * There are no Boolean matrix types, so we do not need to allow
+ * GLSL_TYPE_BOOL here (as _mesa_uniform does).
+ */
+ if (uni->type->base_type != basicType) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glUniformMatrix%ux%u(\"%s\"@%d is %s, not %s)",
+ cols, rows, uni->name, location,
+ glsl_type_name(uni->type->base_type),
+ glsl_type_name(basicType));
+ return;
+ }
+
if (unlikely(ctx->_Shader->Flags & GLSL_UNIFORMS)) {
log_uniform(values, uni->type->base_type, components, vectors, count,
bool(transpose), shProg, location, uni);