[Piglit] [V2 1/8] ARB_explicit_uniform_location: test for uniform location boundary values

Anuj Phogat anuj.phogat at gmail.com
Fri Mar 14 11:07:35 PDT 2014


On Fri, Mar 14, 2014 at 8:06 AM, Ian Romanick <idr at freedesktop.org> wrote:
> On 03/14/2014 04:23 AM, Tapani Pälli wrote:
>> v2: fix style issues, use asprintf (Topi, Anuj)
>>
>> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
>> ---
>>  tests/all.py                                       |   1 +
>>  .../CMakeLists.gl.txt                              |   1 +
>>  .../arb_explicit_uniform_location/loc-boundaries.c | 104 +++++++++++++++++++++
>>  3 files changed, 106 insertions(+)
>>  create mode 100644 tests/spec/arb_explicit_uniform_location/loc-boundaries.c
>>
>> diff --git a/tests/all.py b/tests/all.py
>> index 6642019..25ec0ea 100644
>> --- a/tests/all.py
>> +++ b/tests/all.py
>> @@ -1925,6 +1925,7 @@ import_glsl_parser_tests(arb_explicit_uniform_location,
>>                           os.path.join(testsDir, 'spec', 'arb_explicit_uniform_location'),
>>                           [''])
>>  add_plain_test(arb_explicit_uniform_location, 'arb_explicit_uniform_location-minmax')
>> +add_plain_test(arb_explicit_uniform_location, 'arb_explicit_uniform_location-boundaries')
>>
>>  arb_texture_buffer_object = Group()
>>  spec['ARB_texture_buffer_object'] = arb_texture_buffer_object
>> diff --git a/tests/spec/arb_explicit_uniform_location/CMakeLists.gl.txt b/tests/spec/arb_explicit_uniform_location/CMakeLists.gl.txt
>> index 2bac595..e871ca1 100644
>> --- a/tests/spec/arb_explicit_uniform_location/CMakeLists.gl.txt
>> +++ b/tests/spec/arb_explicit_uniform_location/CMakeLists.gl.txt
>> @@ -10,3 +10,4 @@ link_libraries (
>>  )
>>
>>  piglit_add_executable (arb_explicit_uniform_location-minmax minmax.c)
>> +piglit_add_executable (arb_explicit_uniform_location-boundaries loc-boundaries.c)
>> diff --git a/tests/spec/arb_explicit_uniform_location/loc-boundaries.c b/tests/spec/arb_explicit_uniform_location/loc-boundaries.c
>> new file mode 100644
>> index 0000000..1dc1060
>> --- /dev/null
>> +++ b/tests/spec/arb_explicit_uniform_location/loc-boundaries.c
>> @@ -0,0 +1,104 @@
>> +/*
>> + * Copyright © 2014 Intel Corporation
>> + *
>> + * Permission is hereby granted, free of charge, to any person obtaining a
>> + * copy of this software and associated documentation files (the "Software"),
>> + * to deal in the Software without restriction, including without limitation
>> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
>> + * and/or sell copies of the Software, and to permit persons to whom the
>> + * Software is furnished to do so, subject to the following conditions:
>> + *
>> + * The above copyright notice and this permission notice (including the next
>> + * paragraph) shall be included in all copies or substantial portions of the
>> + * Software.
>> + *
>> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
>> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
>> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
>> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
>> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
>> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
>> + * IN THE SOFTWARE.
>> + */
>> +
>> +/**
>> + * \file loc-boundaries.c
>> + *
>> + * Tests the boundary values for uniform locations, this is a positive test
>> + * for the locations, every check here is expected to pass.
>> + *
>> + * https://www.opengl.org/registry/specs/ARB/explicit_uniform_location.txt
>> + *
>> + * Specification states : "Valid locations for default-block uniform variable
>> + *                         locations are in the range of 0 to the
>> + *                         implementation-defined maximum number of uniform
>> + *                         locations."
>
> Please format this like other spec quotations.  Sometimes people search
> for spec quotes using grep, and having them all formatted the same helps.
>
>  * The GL_ARB_explicit_uniform_location spec says:
>  *
>  *     "Valid locations for default-block uniform variable locations are in
>  *     the range of 0 to the implementation-defined maximum number of
>  *     uniform locations."
>
> With that fixed,
>
> Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
>
>> + *
>> + * This test tests 0, MAX and a single value in between, shader contains
>> + * also uniform without explicit location to see that it does not affect
>> + * getting the wanted locations.
>> + */
>> +#include "piglit-util-gl-common.h"
>> +
>> +PIGLIT_GL_TEST_CONFIG_BEGIN
>> +
>> +     config.supports_gl_compat_version = 20;
>> +     config.window_visual = PIGLIT_GL_VISUAL_RGB;
>> +
>> +PIGLIT_GL_TEST_CONFIG_END
>> +
>> +enum piglit_result
>> +piglit_display(void)
>> +{
>> +     return PIGLIT_FAIL;
>> +}
>> +
>> +const char v_sha[] =
>> +     "vec4 vertex;\n"
>> +     "void main() {\n"
>> +             "gl_Position = vertex;\n"
>> +     "}";
>> +
>> +const char fshader_main[] =
>> +     "#extension GL_ARB_explicit_uniform_location: require\n"
>> +     "uniform float a;\n"
>> +     "layout(location = %d) uniform float r;\n"
>> +     "layout(location = %d) uniform float g;\n"
>> +     "layout(location = %d) uniform float b;\n"
>> +     "void main() {\n"
>> +             "gl_FragColor = vec4(r, g, b, a);\n"
>> +     "}";
>> +
>> +void
>> +piglit_init(int argc, char **argv)
>> +{
>> +     int maxloc;
>> +     GLuint prog;
>> +
>> +     piglit_require_extension("GL_ARB_explicit_uniform_location");
>> +
>> +     glGetIntegerv(GL_MAX_UNIFORM_LOCATIONS, &maxloc);
>> +
>> +     if (!piglit_check_gl_error(GL_NO_ERROR))
>> +             piglit_report_result(PIGLIT_FAIL);
>> +
>> +     char *f_sha;
>> +
>> +     /* test GL_MAX_UNIFORM_LOCATIONS, 0, and a loc in between (1) */
>> +     if (asprintf(&f_sha, fshader_main, maxloc, 0, 1) == -1)
>> +             piglit_report_result(PIGLIT_FAIL);
>> +
>> +     prog = piglit_build_simple_program(v_sha, f_sha);
>> +
>> +     free(f_sha);
>> +
>> +     if (glGetUniformLocation(prog, "r") != maxloc)
>> +             piglit_report_result(PIGLIT_FAIL);
>> +     if (glGetUniformLocation(prog, "g") != 0)
>> +             piglit_report_result(PIGLIT_FAIL);
>> +     if (glGetUniformLocation(prog, "b") != 1)
>> +             piglit_report_result(PIGLIT_FAIL);
>> +
>> +     glDeleteProgram(prog);
>> +     piglit_report_result(PIGLIT_PASS);
>> +}
>>
>
With comments from Ian and Topi fixed:
Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>


More information about the Piglit mailing list