[Piglit] [PATCH 2/6] ARB_viewport_array: Validity test for depth range index/first/count params

Jon Ashburn jon at lunarg.com
Thu Oct 24 01:34:41 CEST 2013


Tests GL_ARB_viewport_array  validity for indices. Use both valid and
invalid parameters (index, first, count) for all these new API entry points:
 glDepthRangeArrayv, glDepthRangeIndexed, glGetDoublei_v.

Tested on Nvidia Quadro 600 all tests pass.
---
 tests/all.tests                                    |   1 +
 tests/spec/arb_viewport_array/CMakeLists.gl.txt    |   1 +
 .../spec/arb_viewport_array/depth_range_indices.c  | 160 +++++++++++++++++++++
 3 files changed, 162 insertions(+)
 create mode 100644 tests/spec/arb_viewport_array/depth_range_indices.c

diff --git a/tests/all.tests b/tests/all.tests
index d39a79a..324a288 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1655,6 +1655,7 @@ 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')
+arb_viewport_array['depthrange-indices'] = concurrent_test('arb_viewport_array-depthrange-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 56ec330..1a443a5 100644
--- a/tests/spec/arb_viewport_array/CMakeLists.gl.txt
+++ b/tests/spec/arb_viewport_array/CMakeLists.gl.txt
@@ -10,5 +10,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)
 
 # vim: ft=cmake:
diff --git a/tests/spec/arb_viewport_array/depth_range_indices.c b/tests/spec/arb_viewport_array/depth_range_indices.c
new file mode 100644
index 0000000..cddf628
--- /dev/null
+++ b/tests/spec/arb_viewport_array/depth_range_indices.c
@@ -0,0 +1,160 @@
+/*
+ * 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 <jon at lunarg.com>
+ */
+
+/**
+ * Tests GL_ARB_viewport_array  validity for indices.
+ * Use both valid and invalid parameters (index, first, count)
+ * for all these new API entry points:
+ * glDepthRangeArrayv, glDepthRangeIndexed, 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 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 first + count or index valid invalid values.
+ * Valid range is 0 thru (MAX_VIEWPORTS-1).
+ */
+static bool test_dr_indices(GLint maxVP)
+{
+	bool pass = true;
+
+	if (!piglit_check_gl_error(GL_NO_ERROR)) {
+		printf("GL error prior to DepthRange array testing\n");
+		return 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, maxVP, GL_NO_ERROR)) {
+		printf("Got error for valid depth range, max range=%u\n",
+		       maxVP);
+		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(maxVP, 4, GL_INVALID_VALUE)) {
+		printf("Wrong error for invalid DepthRange first index\n");
+		pass = false;
+	}
+	/* invalid count + first for DepthRange */
+	if (!check_dr_index(maxVP-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;
+	}
+
+	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_dr_indices(maxVP);
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
-- 
1.8.1.2



More information about the Piglit mailing list