[Piglit] [PATCH 1/7] ARB_explicit_uniform_location: test for uniform location boundary values
Tapani Pälli
tapani.palli at intel.com
Thu Mar 13 23:12:07 PDT 2014
On 03/14/2014 03:34 AM, Pohjolainen, Topi wrote:
> On Thu, Mar 13, 2014 at 02:41:43PM +0200, Tapani P?lli wrote:
>> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
>> ---
>> tests/all.py | 1 +
>> .../CMakeLists.gl.txt | 1 +
>> .../arb_explicit_uniform_location/loc-minmax.c | 107 +++++++++++++++++++++
>> 3 files changed, 109 insertions(+)
>> create mode 100644 tests/spec/arb_explicit_uniform_location/loc-minmax.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..57e90f0 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-minmax.c)
>> diff --git a/tests/spec/arb_explicit_uniform_location/loc-minmax.c b/tests/spec/arb_explicit_uniform_location/loc-minmax.c
>> new file mode 100644
>> index 0000000..d72422d
>> --- /dev/null
>> +++ b/tests/spec/arb_explicit_uniform_location/loc-minmax.c
>> @@ -0,0 +1,107 @@
>> +/*
>> + * 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-minmax.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 : "The explicitly defined locations and the generated
>> + * locations must be in the range of 0 to MAX_UNIFORM_LOCATIONS minus one."
>> + *
>> + * This test tests 0, MAX - 1 and a random value in between, shader contains
> I'm always uncomfortable having tests based on random values - different runs
> are possibly testing different behaviour. Could we just handpick a few from
> now and there in the range. For example,
>
> 0 * (max - 1) / 5
> 1 * (max - 1) / 5
> 2 * (max - 1) / 5
> 3 * (max - 1) / 5
> 4 * (max - 1) / 5
>
OK, I can pick some static values or maybe just take this one away as
it's kind of extra thing here in 'boundaries' test.
>> + * 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"
>> +"}";
>> +
>> +#define VERIFY_LOC(uni, loc)\
>> + if (glGetUniformLocation(prog, uni) != loc)\
>> + piglit_report_result(PIGLIT_FAIL);
>> +
>> +void
>> +piglit_init(int argc, char **argv)
>> +{
>> + int maxloc, randloc;
>> + 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[256];
>> +
>> + /* random location in a range 1 .. (maxloc - 1) */
>> + randloc = 1 + rand() % (maxloc - 2);
>> +
>> + /* test GL_MAX_UNIFORM_LOCATIONS - 1, 0, and rand loc in between */
>> + snprintf(f_sha, 256, fshader_main,
>> + maxloc - 1,
>> + 0,
>> + randloc);
>> +
>> + prog = piglit_build_simple_program(v_sha, f_sha);
>> +
>> + VERIFY_LOC("r", maxloc - 1);
> To me it would be clearer to have the two lines directly instead of the macro.
>
> if (glGetUniformLocation(prog, "r") != maxloc - 1)
> piglit_report_result(PIGLIT_FAIL);
>
OK, I can take the macro away.
>> + VERIFY_LOC("g", 0);
>> + VERIFY_LOC("b", randloc);
>> +
>> + glDeleteProgram(prog);
>> +
>> + piglit_report_result(PIGLIT_PASS);
>> +}
>> --
>> 1.8.3.1
>>
>> _______________________________________________
>> Piglit mailing list
>> Piglit at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/piglit
More information about the Piglit
mailing list