Tests valid and invalid "index", "first", "count" parameters for the following:
 glViewportArrayv, glViewportIndexedf, glViewportIndexedfv
 glScissorArrayv, glScissorIndexed, glScissorIndexedv
 glDepthRangeArrayv, glDepthRangeIndexed
 glGetFloati_v, glGetDoublei_v

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/indices.c         | 329 ++++++++++++++++++++++++
 5 files changed, 349 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/indices.c

diff --git a/tests/all.tests b/tests/all.tests
index 742cc21..9bc3b78 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1650,6 +1650,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['indices'] = concurrent_test('arb_viewport_array-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..73d90f3
--- /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-indices 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/indices.c 
b/tests/spec/arb_viewport_array/indices.c
new file mode 100644
index 0000000..63d0275
--- /dev/null
+++ b/tests/spec/arb_viewport_array/indices.c
@@ -0,0 +1,329 @@
+/*
+ * 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 all the new API entry points:
+ * glViewportArrayv, glViewportIndexedf, glViewportIndexedfv
+ * glScissorArrayv, glScissorIndexed, glScissorIndexedv
+ * glDepthRangeArrayv, glDepthRangeIndexed
+ * glGetFloati_v, glGetDoublei_v
+ *
+ */
+
+#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);
+               if (!piglit_check_gl_error(expected_error)) {
+                       printf("error from call to glGetFloati_v\n");
+                       return false;
+               }
+
+       }
+
+       mv = malloc(sizeof(GLfloat) * 4 * count);
+       if (mv == NULL)
+               return false;
+       for (i =0; i < count; i++) {
+               mv[i*4] = v[0];
+               mv[i*4 + 1] = v[1];
+               mv[i*4 + 2] = v[2];
+               mv[i*4 + 3] = v[3];
+       }
+       glViewportArrayv(first, count, mv);
+       free(mv);
+       if (!piglit_check_gl_error(expected_error)) {
+               printf("error from call to glViewportArrayv\n");
+           return false;
+       }
+
+       return true;
+}
+
+/**
+ * Test that DepthRangeArrayv, DepthRangeIndexed, GetDoublei_v give the
+ * "expected_error" gl error.  Given the values for "first" and "count"
+ * or "index" in range [first, first+count).
+ */
+static bool
+check_dr_index(GLuint first, GLsizei count, GLenum expected_error)
+{
+       GLclampd dv[] = {0.213, 1.0}, *mv;
+       unsigned int i, numIterate;
+
+       mv = malloc(sizeof(GLclampd) * 2 * count);
+       if (mv == NULL)
+               return false;
+       for (i =0; i < count; i++) {
+               mv[i*2] = dv[0];
+               mv[i*2 + 1] = dv[1];
+       }
+       glDepthRangeArrayv(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--) {
+               glDepthRangeIndexed(first+i-1, dv[0], dv[1]);
+               if (!piglit_check_gl_error(expected_error))
+                       return false;
+               glGetDoublei_v(GL_DEPTH_RANGE, first+i-1, dv);
+               if (!piglit_check_gl_error(expected_error))
+                       return false;
+       }
+
+       return true;
+}
+
+/**
+ * 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;
+       }
+
+       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_param_indices()
+{
+       GLint max;
+       bool pass = true;
+
+       glGetIntegerv(GL_MAX_VIEWPORTS, &max);
+       if (!piglit_check_gl_error(GL_NO_ERROR)) {
+               printf("GL error prior to ViewportArray testing\n");
+               return false;
+       }
+
+       /**
+        * valid largest range viewport index
+        * OpenGL Core 4.3 Spec, section 13.6.1 ref:
+        *    "Multiple viewports are available and are numbered zero
+        *    through the value of MAX_VIEWPORTS minus one."
+        */
+       if (!check_vp_index(0, max, GL_NO_ERROR)) {
+               printf("Got error for valid viewport range, max range=%u\n", 
max);
+               pass = false;
+       }
+       /**
+        *  invalid first index for viewport
+        * OpenGL Spec Core 4.3 Spec, section 13.6.1 ref:
+        *     "An INVALID_VALUE error is generated if first + count
+        *     is greater than the valuue of MAX_VIEWPORTS."
+        */
+       if (!check_vp_index(max, 1, GL_INVALID_VALUE)) {
+               printf("Wrong error for invalid viewport first index\n");
+               pass = false;
+       }
+       /* invalid count + first for viewport */
+       if (!check_vp_index(max-1, 2, GL_INVALID_VALUE)) {
+               printf("Wrong error for invalid viewport range\n");
+               pass = false;
+       }
+       /**
+        * invalid count for viewport
+        * OpenGL Spec Core 4.3 Spec, section 13.6.1 ref:
+        *    "An INVALID_VALUE error is generated if count is negative."
+        */
+       glViewportArrayv(0, -1, NULL);
+       if (!piglit_check_gl_error(GL_INVALID_VALUE)) {
+               printf("Wrong error for invalid viewport count\n");
+               pass = false;
+       }
+
+       /**
+        * valid largest range depth index
+        * OpenGL Core 4.3 Spec, section 13.6.1 ref:
+        *    "Multiple viewports are available and are numbered zero
+        *    through the value of MAX_VIEWPORTS minus one."
+        */
+       if (!check_dr_index(0, max, GL_NO_ERROR)) {
+               printf("Got error for valid depth range, max range=%u\n", max);
+               pass = false;
+       }
+
+       /**
+        * invalid first index for DepthRange
+        * OpenGL Spec Core 4.3 Spec, section 13.6.1 ref:
+        *     "An INVALID_VALUE error is generated if first + count
+        *     is greater than the valuue of MAX_VIEWPORTS."
+        */
+       if (!check_dr_index(max, 4, GL_INVALID_VALUE)) {
+               printf("Wrong error for invalid DepthRange first index\n");
+               pass = false;
+       }
+       /* invalid count + first for DepthRange */
+       if (!check_dr_index(max-2, 3, GL_INVALID_VALUE)) {
+               printf("Wrong error for invalid DepthRange index range\n");
+               pass = false;
+       }
+       /**
+        * invalid count for DepthRange
+        * OpenGL Spec Core 4.3 Spec, section 13.6.1 ref:
+        *    "An INVALID_VALUE error is generated if count is negative."
+        */
+       glDepthRangeArrayv(0, -1, NULL);
+       if (!piglit_check_gl_error(GL_INVALID_VALUE)) {
+               printf("Wrong error for invalid DepthRange count\n");
+               pass = 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, max, GL_NO_ERROR)) {
+               printf("Got error for valid scissor range, max=%u\n", max);
+               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 (!check_dr_index(max, 1, GL_INVALID_VALUE)) {
+               printf("Wrong error for invalid Scissor first index\n");
+               pass = false;
+       }
+
+       /* invalid count + first for Scissor */
+       if (!check_dr_index(max-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;
+
+       piglit_require_extension("GL_ARB_viewport_array");
+
+       pass = test_param_indices();
+       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

Reply via email to