Tests GL_ARB_viewport_array validity for indices. Use both valid and invalid parameters (index, first, count) for these new API entry points: glScissorArrayv, glScissorIndexed, glScissorIndexedv. Also test SCISSOR_TEST indices with glEnablei and others.
Tested on Nvidia Quadro 600 all test cases pass except for invalid indices with glIsEnabledi(GL_SCISSOR_TEST,...). --- tests/all.tests | 1 + tests/spec/arb_viewport_array/CMakeLists.gl.txt | 1 + tests/spec/arb_viewport_array/scissor_indices.c | 169 ++++++++++++++++++++++++ 3 files changed, 171 insertions(+) create mode 100644 tests/spec/arb_viewport_array/scissor_indices.c diff --git a/tests/all.tests b/tests/all.tests index 0aadd53..57ab720 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -1733,6 +1733,7 @@ arb_viewport_array = Group() spec['ARB_viewport_array'] = arb_viewport_array arb_viewport_array['viewport-indices'] = concurrent_test('arb_viewport_array-viewport-indices') arb_viewport_array['depthrange-indices'] = concurrent_test('arb_viewport_array-depthrange-indices') +arb_viewport_array['scissor-indices'] = concurrent_test('arb_viewport_array-scissor-indices') nv_vertex_program = Group() spec['NV_vertex_program'] = nv_vertex_program diff --git a/tests/spec/arb_viewport_array/CMakeLists.gl.txt b/tests/spec/arb_viewport_array/CMakeLists.gl.txt index 1a443a5..35df5ea 100644 --- a/tests/spec/arb_viewport_array/CMakeLists.gl.txt +++ b/tests/spec/arb_viewport_array/CMakeLists.gl.txt @@ -11,5 +11,6 @@ link_libraries( piglit_add_executable(arb_viewport_array-viewport-indices viewport_indices.c) piglit_add_executable(arb_viewport_array-depthrange-indices depth_range_indices.c) +piglit_add_executable(arb_viewport_array-scissor-indices scissor_indices.c) # vim: ft=cmake: diff --git a/tests/spec/arb_viewport_array/scissor_indices.c b/tests/spec/arb_viewport_array/scissor_indices.c new file mode 100644 index 0000000..45aba66 --- /dev/null +++ b/tests/spec/arb_viewport_array/scissor_indices.c @@ -0,0 +1,169 @@ +/* + * Copyright © 2013 LunarG, Inc. + * + * 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. + * + * Author: Jon Ashburn <j...@lunarg.com> + */ + +/** + * Tests GL_ARB_viewport_array validity for indices. + * Use both valid and invalid parameters (index, first, count) + * for these new API entry points: + * glScissorArrayv, glScissorIndexed, glScissorIndexedv + * + * Also test SCISSOR_TEST indices with glEnablei and others. + */ + +#include "piglit-util-gl-common.h" +#include <stdarg.h> + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 32; + config.supports_gl_core_version = 32; + + config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE; + +PIGLIT_GL_TEST_CONFIG_END + +/** + * Test that ScissorArrayv, ScissorIndexed(v), GetIntegeri_v give the + * "expected_error" gl error. Given the values for "first" and "count" + * or "index" in range [first, first+count). + */ +static bool +check_sc_index(GLuint first, GLsizei count, GLenum expected_error) +{ + GLint sv[] = {0, 10, 20, 35}, *mv; + unsigned int i, numIterate; + + mv = malloc(sizeof(GLint) * 4 * count); + if (mv == NULL) + return false; + for (i =0; i < count; i++) { + mv[i*4] = sv[0]; + mv[i*4 + 1] = sv[1]; + mv[i*4 + 2] = sv[2]; + mv[i*4 + 3] = sv[3]; + } + glScissorArrayv(first, count, mv); + free( mv); + if (!piglit_check_gl_error(expected_error)) + return false; + + /* only iterate multiple indices for no error case */ + if (expected_error == GL_NO_ERROR) + numIterate = count; + else + numIterate = 1; + for (i = count; i > count - numIterate; i--) { + glScissorIndexed(first+i-1, sv[0], sv[1], sv[2], sv[3]); + if (!piglit_check_gl_error(expected_error)) + return false; + glGetIntegeri_v(GL_SCISSOR_BOX, first+i-1, sv); + if (!piglit_check_gl_error(expected_error)) + return false; + glEnablei(GL_SCISSOR_TEST, first+i-1); + if (!piglit_check_gl_error(expected_error)) + return false; + glDisablei(GL_SCISSOR_TEST, first+i-1); + if (!piglit_check_gl_error(expected_error)) + return false; + glIsEnabledi(GL_SCISSOR_TEST, first+i-1); + if (!piglit_check_gl_error(expected_error)) { + printf("expected_err=%s, idx=%d\n", + piglit_get_gl_enum_name(expected_error), first+i-1); + return false; + } + } + + return true; +} + +/** + * Test first + count or index valid invalid values. + * Valid range is 0 thru (MAX_VIEWPORTS-1). + * Also test the Enable, Disable, IsEnabled with invalid index. + */ +static bool test_scissor_indices(GLint maxVP) +{ + bool pass = true; + + if (!piglit_check_gl_error(GL_NO_ERROR)) { + printf("GL error prior to ScissorArray testing\n"); + return false; + } + + /** + * valid largest range Scissor index + * OpenGL Core 4.3 Spec, section 17.3.2 ref: + * "ScissorArrayv defines a set of scissor rectangles that are + * each applied to the corresponding viewport (see section 13.6.1). + * first specifies the index of the first scissor rectangle to + * modify, and count specifies the number of scissor rectangles." + */ + if (!check_sc_index(0, maxVP, GL_NO_ERROR)) { + printf("Got error for valid scissor range, max=%u\n", maxVP); + pass = false; + } + /** + * invalid first index for Scissor index + * OpenGL Core 4.3 Spec, section 17.3.2 ref: + * "An INVALID_VALUE error is generated by ScissorArrayv if + * first +count is greater than the value of MAX_VIEWPORTS." + * "If the viewport index specified to Enablei, Disablei or + * IsEnabledi is greater or equal to the value of + * MAX_VIEWPORTS, then an INVALID_VALUE error is generated." + */ + if (!check_sc_index(maxVP, 1, GL_INVALID_VALUE)) { + printf("Wrong error for invalid Scissor first index\n"); + pass = false; + } + + /* invalid count + first for Scissor */ + if (!check_sc_index(maxVP-4, 5, GL_INVALID_VALUE)) { + printf("Wrong error for invalid Scissor index range\n"); + pass = false; + } + + return pass; +} + +enum piglit_result +piglit_display(void) +{ + return PIGLIT_FAIL; +} + +void +piglit_init(int argc, char **argv) +{ + bool pass = true; + GLint maxVP; + + piglit_require_extension("GL_ARB_viewport_array"); + + glGetIntegerv(GL_MAX_VIEWPORTS, &maxVP); + + pass = test_scissor_indices(maxVP); + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} -- 1.8.1.2 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit