<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 19, 2015 at 7:53 AM, Brian Paul <span dir="ltr"><<a href="mailto:brianp@vmware.com" target="_blank">brianp@vmware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Different errors for type mismatches, size mismatches and matrix/<br>
non-matrix mismatches. Use a common format of "uniformName"@location<br>
in the messags.<br>
---<br>
src/mesa/main/uniform_query.cpp | 69 ++++++++++++++++++++++++++++++++++++++---<br>
1 file changed, 65 insertions(+), 4 deletions(-)<br>
<br>
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp<br>
index 9f82de9..2ab5528 100644<br>
--- a/src/mesa/main/uniform_query.cpp<br>
+++ b/src/mesa/main/uniform_query.cpp<br>
@@ -260,8 +260,8 @@ validate_uniform_parameters(struct gl_context *ctx,<br>
if (uni->array_elements == 0) {<br>
if (count > 1) {<br>
_mesa_error(ctx, GL_INVALID_OPERATION,<br>
- "%s(count > 1 for non-array, location=%d)",<br>
- caller, location);<br>
+ "%s(count = %u for non-array \"%s\"@%d)",<br></blockquote><div>How about "%s(count=%u > 1 ..." for a little more clarity? It's up to you. <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ caller, count, uni->name, location);<br>
return NULL;<br>
}<br>
<br>
@@ -601,6 +601,46 @@ _mesa_propagate_uniforms_to_driver_storage(struct gl_uniform_storage *uni,<br>
}<br>
}<br>
<br>
+<br>
+/**<br>
+ * Return printable string for a given GLSL_TYPE_x<br>
+ */<br>
+static const char *<br>
+glsl_type_name(enum glsl_base_type type)<br>
+{<br>
+ switch (type) {<br>
+ case GLSL_TYPE_UINT:<br>
+ return "uint";<br>
+ case GLSL_TYPE_INT:<br>
+ return "int";<br>
+ case GLSL_TYPE_FLOAT:<br>
+ return "float";<br>
+ case GLSL_TYPE_DOUBLE:<br>
+ return "double";<br>
+ case GLSL_TYPE_BOOL:<br>
+ return "bool";<br>
+ case GLSL_TYPE_SAMPLER:<br>
+ return "sampler";<br>
+ case GLSL_TYPE_IMAGE:<br>
+ return "image";<br>
+ case GLSL_TYPE_ATOMIC_UINT:<br>
+ return "atomic_uint";<br>
+ case GLSL_TYPE_STRUCT:<br>
+ return "struct";<br>
+ case GLSL_TYPE_INTERFACE:<br>
+ return "interface";<br>
+ case GLSL_TYPE_ARRAY:<br>
+ return "array";<br>
+ case GLSL_TYPE_VOID:<br>
+ return "void";<br>
+ case GLSL_TYPE_ERROR:<br>
+ return "error";<br>
+ default:<br>
+ return "other";<br>
+ }<br>
+}<br>
+<br>
+<br>
/**<br>
* Called via glUniform*() functions.<br>
*/<br>
@@ -620,11 +660,28 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,<br>
if (uni == NULL)<br>
return;<br>
<br>
+ if (uni->type->is_matrix()) {<br>
+ /* Can't set matrix uniforms (like mat4) with glUniform */<br>
+ _mesa_error(ctx, GL_INVALID_OPERATION,<br>
+ "glUniform%u(uniform \"%s\"@%d is matrix)",<br>
+ src_components, uni->name, location);<br>
+ return;<br>
+ }<br>
+<br>
/* Verify that the types are compatible.<br>
*/<br>
const unsigned components = uni->type->is_sampler()<br>
? 1 : uni->type->vector_elements;<br>
<br>
+ if (components != src_components) {<br>
+ /* glUniformN() must match float/vecN type */<br>
+ _mesa_error(ctx, GL_INVALID_OPERATION,<br>
+ "glUniform%u(\"%s\"@%u has %u components, not %u)",<br>
+ src_components, uni->name, location,<br>
+ components, src_components);<br>
+ return;<br>
+ }<br>
+<br>
bool match;<br>
switch (uni->type->base_type) {<br>
case GLSL_TYPE_BOOL:<br>
@@ -639,8 +696,12 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,<br>
break;<br>
}<br>
<br>
- if (uni->type->is_matrix() || components != src_components || !match) {<br>
- _mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(type mismatch)");<br>
+ if (!match) {<br>
+ _mesa_error(ctx, GL_INVALID_OPERATION,<br>
+ "glUniform%u(\"%s\"@%d is %s, not %s)",<br>
+ src_components, uni->name, location,<br>
+ glsl_type_name(uni->type->base_type),<br>
+ glsl_type_name(basicType));<br>
return;<br>
}<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
1.9.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>