[Piglit] [PATCH] Add test glsl-uniform-out-of-bounds-2.c

Frank Henigman fjhenigman at google.com
Mon Dec 3 13:43:17 PST 2012


Time for my weekly nag.  Any comment on my last comment?  Thanks.

On Mon, Nov 26, 2012 at 3:15 PM, Frank Henigman <fjhenigman at google.com>wrote:

> On Mon, Nov 26, 2012 at 2:27 PM, Eric Anholt <eric at anholt.net> wrote:
>
>> Frank Henigman <fjhenigman at google.com> writes:
>> > diff --git a/tests/all.tests b/tests/all.tests
>> > index 36c5847..2cf1ef4 100644
>> > --- a/tests/all.tests
>> > +++ b/tests/all.tests
>> > @@ -240,6 +240,7 @@ add_plain_test(shaders, 'glsl-novertexdata')
>> >  add_plain_test(shaders, 'glsl-preprocessor-comments')
>> >  add_plain_test(shaders, 'glsl-reload-source')
>> >  add_plain_test(shaders, 'glsl-uniform-out-of-bounds')
>> > +add_plain_test(shaders, 'glsl-uniform-out-of-bounds-2')
>>
>> I think this could safely be a concurrent test.
>>
>> > +static GLint prog;
>>
>> Looks like this ought to live next to vs, fs declarations.
>>
>> > +void
>> > +piglit_init(int argc, char **argv)
>> > +{
>> > +     GLint vs, fs;
>> > +     int i, j, k;
>> > +     bool pass = true;
>> > +     GLint numActiveUniform;
>>
>> Generally we try to go for names_with_underscores.
>>
>> > +     // for each array in shader
>> > +     for (k = 0; k < numActiveUniform; ++k) {
>> > +             GLchar name[99];
>> > +             GLint numActiveElements;
>> > +             GLenum type;
>> > +             int size;
>> > +             glGetActiveUniform(prog, k, ARRAY_SIZE(name), NULL,
>> > +                                                &numActiveElements,
>> &type, name);
>> > +             if (name[1] != 0)
>> > +                     continue;
>> > +             if (name[0] == 'v')
>> > +                     size = 4;
>> > +             else if (name[0] == 'm')
>> > +                     size = 16;
>> > +             else
>> > +                     continue;
>> > +             printf("array '%s' active elements %d\n", name,
>> numActiveElements);
>> > +
>> > +             // for each index in array, plus some before and after
>> > +             for (i = -2; i < 6; ++i) {
>> > +                     bool isActive = 0 <= i && i < numActiveElements;
>> > +                     GLchar element[9];
>> > +                     GLint loc;
>> > +                     sprintf(element, "%s[%d]", name, i);
>> > +                     loc = glGetUniformLocation(prog, element);
>> > +
>> > +                     // check result of glGetUniformLocation
>> > +                     if (loc == -1) {
>> > +                             if (isActive) {
>> > +                                     printf("FAIL: no location for
>> active %s\n", element);
>> > +                                     pass = false;
>> > +                             }
>> > +                     } else {
>> > +                             if (!isActive) {
>> > +                                     printf("FAIL: got location for
>> inactive %s\n", element);
>> > +                                     pass = false;
>> > +                             }
>> > +
>> > +                             // write location
>> > +                             if (size == 4) {
>> > +                                     glUniform4fv(loc, 1, data);
>> > +                             } else {
>> > +                                     glUniformMatrix4fv(loc, 1,
>> GL_FALSE, data);
>> > +                             }
>> > +                             // read back
>> > +                             for (j = 0; j < size; ++j)
>> > +                                     v[j] = 0;
>> > +                             glGetUniformfv(prog, loc, v);
>> > +                             // compare
>> > +                             for (j = 0; j < size; ++j) {
>> > +                                     if (v[j] != data[j]) {
>> > +                                             printf("FAIL: wrong value
>> in %s\n", element);
>> > +                                             pass = false;
>> > +                                             break;
>> > +                                     }
>> > +                             }
>>
>> Being able to round-trip data through the various components of a
>> uniform array/matrix seems like a very separate thing to test from
>> glsl-uniform-out-of-bounds-2.  This test would make a lot more sense to
>> me without it.  In that case, this loop would just be checking that
>> out-of-bounds stuff gets -1 location (a good thing to test), and
>> computing the bounds of the valid locations.
>>
>
> Mesa currently will return a location for elements past the point where
> glGetActiveUniform says they are active (I posted a patch for that but
> was asked for a test, hence this thread) and I wanted to see if those
> locations worked, as an indication of whether glGetActiveUniform or
> glGetUniformLocation was wrong.  Would it be ok if I only test the
> round trip on those suspect locations?   Thanks.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20121203/eb1c0a0a/attachment.html>


More information about the Piglit mailing list