<div style="font-family: arial, helvetica, sans-serif; font-size: 10pt">Time for my weekly nag.  Any comment on my last comment?  Thanks.<br><br><div class="gmail_quote">On Mon, Nov 26, 2012 at 3:15 PM, Frank Henigman <span dir="ltr"><<a href="mailto:fjhenigman@google.com" target="_blank">fjhenigman@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="font-family:arial,helvetica,sans-serif;font-size:10pt"><div><div class="h5">On Mon, Nov 26, 2012 at 2:27 PM, Eric Anholt <span dir="ltr"><<a href="mailto:eric@anholt.net" target="_blank">eric@anholt.net</a>></span> wrote:<br>

</div></div><div class="gmail_quote"><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Frank Henigman <<a href="mailto:fjhenigman@google.com" target="_blank">fjhenigman@google.com</a>> writes:<br>


> diff --git a/tests/all.tests b/tests/all.tests<br>
> index 36c5847..2cf1ef4 100644<br>
> --- a/tests/all.tests<br>
> +++ b/tests/all.tests<br>
> @@ -240,6 +240,7 @@ add_plain_test(shaders, 'glsl-novertexdata')<br>
>  add_plain_test(shaders, 'glsl-preprocessor-comments')<br>
>  add_plain_test(shaders, 'glsl-reload-source')<br>
>  add_plain_test(shaders, 'glsl-uniform-out-of-bounds')<br>
> +add_plain_test(shaders, 'glsl-uniform-out-of-bounds-2')<br>
<br>
</div>I think this could safely be a concurrent test.<br>
<br>
> +static GLint prog;<br>
<br>
Looks like this ought to live next to vs, fs declarations.<br>
<div><br>
> +void<br>
> +piglit_init(int argc, char **argv)<br>
> +{<br>
> +     GLint vs, fs;<br>
> +     int i, j, k;<br>
> +     bool pass = true;<br>
> +     GLint numActiveUniform;<br>
<br>
</div>Generally we try to go for names_with_underscores.<br>
<div><div><br>
> +     // for each array in shader<br>
> +     for (k = 0; k < numActiveUniform; ++k) {<br>
> +             GLchar name[99];<br>
> +             GLint numActiveElements;<br>
> +             GLenum type;<br>
> +             int size;<br>
> +             glGetActiveUniform(prog, k, ARRAY_SIZE(name), NULL,<br>
> +                                                &numActiveElements, &type, name);<br>
> +             if (name[1] != 0)<br>
> +                     continue;<br>
> +             if (name[0] == 'v')<br>
> +                     size = 4;<br>
> +             else if (name[0] == 'm')<br>
> +                     size = 16;<br>
> +             else<br>
> +                     continue;<br>
> +             printf("array '%s' active elements %d\n", name, numActiveElements);<br>
> +<br>
> +             // for each index in array, plus some before and after<br>
> +             for (i = -2; i < 6; ++i) {<br>
> +                     bool isActive = 0 <= i && i < numActiveElements;<br>
> +                     GLchar element[9];<br>
> +                     GLint loc;<br>
> +                     sprintf(element, "%s[%d]", name, i);<br>
> +                     loc = glGetUniformLocation(prog, element);<br>
> +<br>
> +                     // check result of glGetUniformLocation<br>
> +                     if (loc == -1) {<br>
> +                             if (isActive) {<br>
> +                                     printf("FAIL: no location for active %s\n", element);<br>
> +                                     pass = false;<br>
> +                             }<br>
> +                     } else {<br>
> +                             if (!isActive) {<br>
> +                                     printf("FAIL: got location for inactive %s\n", element);<br>
> +                                     pass = false;<br>
> +                             }<br>
> +<br>
> +                             // write location<br>
> +                             if (size == 4) {<br>
> +                                     glUniform4fv(loc, 1, data);<br>
> +                             } else {<br>
> +                                     glUniformMatrix4fv(loc, 1, GL_FALSE, data);<br>
> +                             }<br>
> +                             // read back<br>
> +                             for (j = 0; j < size; ++j)<br>
> +                                     v[j] = 0;<br>
> +                             glGetUniformfv(prog, loc, v);<br>
> +                             // compare<br>
> +                             for (j = 0; j < size; ++j) {<br>
> +                                     if (v[j] != data[j]) {<br>
> +                                             printf("FAIL: wrong value in %s\n", element);<br>
> +                                             pass = false;<br>
> +                                             break;<br>
> +                                     }<br>
> +                             }<br>
<br>
</div></div>Being able to round-trip data through the various components of a<br>
uniform array/matrix seems like a very separate thing to test from<br>
glsl-uniform-out-of-bounds-2.  This test would make a lot more sense to<br>
me without it.  In that case, this loop would just be checking that<br>
out-of-bounds stuff gets -1 location (a good thing to test), and<br>
computing the bounds of the valid locations.<br></blockquote><div><br></div></div></div><div>Mesa currently will return a location for elements past the point where</div><div>glGetActiveUniform says they are active (I posted a patch for that but</div>

<div>was asked for a test, hence this thread) and I wanted to see if those</div><div>locations worked, as an indication of whether glGetActiveUniform or</div><div>glGetUniformLocation was wrong.  Would it be ok if I only test the</div>

<div>round trip on those suspect locations?   Thanks.</div></div></div>
</blockquote></div><br></div>