[Piglit] [PATCH 3/7] ARB_explicit_uniform_location: test too big uniform array size
Tapani Pälli
tapani.palli at intel.com
Thu Mar 13 23:09:30 PDT 2014
On 03/13/2014 09:46 PM, Anuj Phogat wrote:
> On Thu, Mar 13, 2014 at 5:41 AM, Tapani Pälli <tapani.palli at intel.com> wrote:
>> Tests that array fits in to the boundaries of defined by the spec.
>>
>> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
>> ---
>> tests/all.py | 1 +
>> .../CMakeLists.gl.txt | 1 +
>> .../arb_explicit_uniform_location/array-toobig.c | 105 +++++++++++++++++++++
>> 3 files changed, 107 insertions(+)
>> create mode 100644 tests/spec/arb_explicit_uniform_location/array-toobig.c
>>
>> diff --git a/tests/all.py b/tests/all.py
>> index 03202cd..8f074c7 100644
>> --- a/tests/all.py
>> +++ b/tests/all.py
>> @@ -1927,6 +1927,7 @@ import_glsl_parser_tests(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')
>> add_plain_test(arb_explicit_uniform_location, 'arb_explicit_uniform_location-array-elements')
>> +add_plain_test(arb_explicit_uniform_location, 'arb_explicit_uniform_location-array-toobig')
>>
>> 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 481922e..90d15f9 100644
>> --- a/tests/spec/arb_explicit_uniform_location/CMakeLists.gl.txt
>> +++ b/tests/spec/arb_explicit_uniform_location/CMakeLists.gl.txt
>> @@ -12,3 +12,4 @@ link_libraries (
>> piglit_add_executable (arb_explicit_uniform_location-minmax minmax.c)
>> piglit_add_executable (arb_explicit_uniform_location-boundaries loc-minmax.c)
>> piglit_add_executable (arb_explicit_uniform_location-array-elements array-elements.c)
>> +piglit_add_executable (arb_explicit_uniform_location-array-toobig array-toobig.c)
>> diff --git a/tests/spec/arb_explicit_uniform_location/array-toobig.c b/tests/spec/arb_explicit_uniform_location/array-toobig.c
>> new file mode 100644
>> index 0000000..4f71560
>> --- /dev/null
>> +++ b/tests/spec/arb_explicit_uniform_location/array-toobig.c
>> @@ -0,0 +1,105 @@
>> +/*
>> + * 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 array-toobig.c
>> + *
>> + * Tests that array size cannot exceed GL_MAX_UNIFORM_LOCATIONS - 1
>> + *
>> + * 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."
>> + */
>> +#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"
>> +"layout(location = %d) uniform float a[%d];\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[%d]);\n"
>> +"}";
>> +
>> +static bool
>> +test()
>> +{
>> + GLuint prog;
>> + GLint link_status;
>> + int maxloc, array_size;
>> + char f_sha[512];
>> + unsigned i;
>> +
>> + glGetIntegerv(GL_MAX_UNIFORM_LOCATIONS, &maxloc);
>> +
>> + if (!piglit_check_gl_error(GL_NO_ERROR))
>> + return false;
>> +
>> + array_size = maxloc;
>> +
>> + snprintf(f_sha, 512, fshader_main,
>> + 0, /* array location */
>> + array_size,
>> + 0,
>> + 1,
>> + 2,
>> + array_size - 1);
> An array of size maxloc will use locations from 0 to maxloc - 1, which
> is in the allowed range. Don't we want the size of array to be atleast
> maxloc + 1 to make the linking fail in this test?
Yes indeed, it should be maxloc + 1, will fix.
> You're also assigning locations to r, g, b, which overlap with array's
> locations. So, the test might be failing to link due to overlapping locations,
> not because of the reason we wanted it to fail for. I think you don't
> need r,g,b uniform variables in your shader. May be a separate
> test verifying explicit locations exceeding the maxloc?
True, I will remove those as now the test relies on driver testing these
things in certain order and would have different results for different
drivers. This should test big array case only.
>> +
>> + prog = piglit_build_simple_program_unlinked(v_sha, f_sha);
>> +
>> + glLinkProgram(prog);
>> + glGetProgramiv(prog, GL_LINK_STATUS, &link_status);
>> + glDeleteProgram(prog);
>> +
>> + /* link_status is expected to be GL_FALSE */
>> + return !link_status;
>> +}
>> +
>> +void
>> +piglit_init(int argc, char **argv)
>> +{
>> + piglit_require_extension("GL_ARB_explicit_uniform_location");
>> + piglit_report_result(test() ? PIGLIT_PASS : PIGLIT_FAIL);
>> +}
> Indentation and asprintf comments are also applicable in this patch.
>> --
>> 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