Tests GL_ARB_viewport_array regarding the validity for the indices.
Use both valid and invalid parameters (index, first, count) for these
new
API entry points:
glViewportArrayv, glViewportIndexedf, glViewportIndexedfv,
glGetFloati_v.
Also test that writing to an invalid viewport index for Viewport,
DepthRange,
Scissor Box, Scissor Test does not modify any of the state for the valid
range of indices.
Tested on Nvidia Quadro 600 all tests pass.
---
tests/all.tests | 4 +
tests/spec/CMakeLists.txt | 1 +
tests/spec/arb_viewport_array/CMakeLists.gl.txt | 14 ++
tests/spec/arb_viewport_array/CMakeLists.txt | 1 +
tests/spec/arb_viewport_array/viewport_indices.c | 252
+++++++++++++++++++++++
5 files changed, 272 insertions(+)
create mode 100644 tests/spec/arb_viewport_array/CMakeLists.gl.txt
create mode 100644 tests/spec/arb_viewport_array/CMakeLists.txt
create mode 100644 tests/spec/arb_viewport_array/viewport_indices.c
diff --git a/tests/all.tests b/tests/all.tests
index 550729d..e3d64ff 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1729,6 +1729,10 @@ add_plain_test(arb_vertex_program,
'vp-address-04')
add_plain_test(arb_vertex_program, 'vp-bad-program')
add_plain_test(arb_vertex_program, 'vp-max-array')
+arb_viewport_array = Group()
+spec['ARB_viewport_array'] = arb_viewport_array
+arb_viewport_array['viewport-indices'] =
concurrent_test('arb_viewport_array-viewport-indices')
+
nv_vertex_program = Group()
spec['NV_vertex_program'] = nv_vertex_program
add_vpfpgeneric(nv_vertex_program, 'nv-mov')
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 18b846d..d22d8a4 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -41,6 +41,7 @@ add_subdirectory (arb_texture_storage_multisample)
add_subdirectory (arb_texture_view)
add_subdirectory (arb_timer_query)
add_subdirectory (arb_transform_feedback2)
+add_subdirectory (arb_viewport_array)
add_subdirectory (ati_envmap_bumpmap)
add_subdirectory (ext_fog_coord)
add_subdirectory (ext_framebuffer_multisample)
diff --git a/tests/spec/arb_viewport_array/CMakeLists.gl.txt
b/tests/spec/arb_viewport_array/CMakeLists.gl.txt
new file mode 100644
index 0000000..56ec330
--- /dev/null
+++ b/tests/spec/arb_viewport_array/CMakeLists.gl.txt
@@ -0,0 +1,14 @@
+include_directories(
+ ${GLEXT_INCLUDE_DIR}
+ ${OPENGL_INCLUDE_PATH}
+ )
+
+link_libraries(
+ piglitutil_${piglit_target_api}
+ ${OPENGL_gl_LIBRARY}
+ ${OPENGL_glu_LIBRARY}
+ )
+
+piglit_add_executable(arb_viewport_array-viewport-indices
viewport_indices.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/arb_viewport_array/CMakeLists.txt
b/tests/spec/arb_viewport_array/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/arb_viewport_array/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/arb_viewport_array/viewport_indices.c
b/tests/spec/arb_viewport_array/viewport_indices.c
new file mode 100644
index 0000000..986925b
--- /dev/null
+++ b/tests/spec/arb_viewport_array/viewport_indices.c
@@ -0,0 +1,252 @@
+/*
+ * 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 regarding the validity for the indices.
+ * Use both valid and invalid parameters (index, first, count)
+ * for these new API entry points:
+ * glViewportArrayv, glViewportIndexedf, glViewportIndexedfv,
glGetFloati_v.
+ *
+ * Also test that writing to an invalid viewport index for Viewport,
DepthRange,
+ * Scissor Box, Scissor Test does not modify any of the state for
the valid
+ * range of indices.
+ *
+ */
+
+#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 ViewportArrayv, ViewportIndexedf(v), GetFloati_v give the
+ * "expected_error" gl error. Given the values for "first" and "count"
+ * or "index" in range [first, first+count).
+ */
+static bool
+check_vp_index(GLuint first, GLsizei count, GLenum expected_error)
+{
+ GLfloat v[] = {0.2,-2.3, 50.0, 1000.3};
+ GLfloat *mv;
+ unsigned int i, numIterate;
+
+ /* 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--) {
+ glViewportIndexedf(first+i-1, v[0], v[1], v[2], v[3]);
+ if (!piglit_check_gl_error(expected_error)) {
+ printf("error from call to glViewportIndexedf\n");
+ return false;
+ }
+
+ glViewportIndexedfv(first+i-1, v);
+ if (!piglit_check_gl_error(expected_error)) {
+ printf("error from call to glViewportIndexedfv\n");
+ return false;
+ }
+
+ glGetFloati_v(GL_VIEWPORT,first+i-1, v);