[Piglit] [PATCH 1/2] gl-3.0: Add test for invalid drawbuffer parameter to glClearBuffer

Ian Romanick idr at freedesktop.org
Tue Nov 1 15:00:46 PDT 2011


From: Ian Romanick <ian.d.romanick at intel.com>

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 tests/all.tests                                    |    4 +
 tests/spec/CMakeLists.txt                          |    1 +
 tests/spec/gl-3.0/CMakeLists.txt                   |    2 +
 tests/spec/gl-3.0/api/CMakeLists.gl.txt            |   17 ++
 tests/spec/gl-3.0/api/CMakeLists.txt               |    1 +
 .../gl-3.0/api/clearbuffer-invalid-drawbuffer.c    |  226 ++++++++++++++++++++
 6 files changed, 251 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/gl-3.0/CMakeLists.txt
 create mode 100644 tests/spec/gl-3.0/api/CMakeLists.gl.txt
 create mode 100644 tests/spec/gl-3.0/api/CMakeLists.txt
 create mode 100644 tests/spec/gl-3.0/api/clearbuffer-invalid-drawbuffer.c

diff --git a/tests/all.tests b/tests/all.tests
index 987e3b6..74d47ee 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -782,6 +782,10 @@ add_concurrent_test(gl20, 'vertex-program-two-side front2')
 add_concurrent_test(gl20, 'vertex-program-two-side back2')
 add_concurrent_test(gl20, 'vertex-program-two-side')
 
+gl30 = Group()
+spec['!OpenGL 3.0'] = gl30
+add_concurrent_test(gl20, 'clearbuffer-invalid-drawbuffer')
+
 # Group spec/glsl-1.00
 spec['glsl-1.00'] = Group()
 import_glsl_parser_tests(spec['glsl-1.00'],
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 5a08cd9..e625282 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -30,6 +30,7 @@ add_subdirectory (glsl-1.10)
 add_subdirectory (glsl-1.20)
 add_subdirectory (glsl-1.30)
 add_subdirectory (gl-2.0)
+add_subdirectory (gl-3.0)
 add_subdirectory (arb_vertex_type_2_10_10_10_rev)
 add_subdirectory (ext_texture_integer)
 add_subdirectory (arb_draw_buffers)
diff --git a/tests/spec/gl-3.0/CMakeLists.txt b/tests/spec/gl-3.0/CMakeLists.txt
new file mode 100644
index 0000000..6903d88
--- /dev/null
+++ b/tests/spec/gl-3.0/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_subdirectory (api)
+piglit_include_target_api()
\ No newline at end of file
diff --git a/tests/spec/gl-3.0/api/CMakeLists.gl.txt b/tests/spec/gl-3.0/api/CMakeLists.gl.txt
new file mode 100644
index 0000000..ab70ae1
--- /dev/null
+++ b/tests/spec/gl-3.0/api/CMakeLists.gl.txt
@@ -0,0 +1,17 @@
+include_directories(
+	${GLEXT_INCLUDE_DIR}
+	${OPENGL_INCLUDE_PATH}
+	${GLUT_INCLUDE_DIR}
+	${piglit_SOURCE_DIR}/tests/util
+)
+
+link_libraries (
+	piglitutil
+	${OPENGL_gl_LIBRARY}
+	${OPENGL_glu_LIBRARY}
+	${GLUT_glut_LIBRARY}
+)
+
+add_executable (clearbuffer-invalid-drawbuffer clearbuffer-invalid-drawbuffer.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/gl-3.0/api/CMakeLists.txt b/tests/spec/gl-3.0/api/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/gl-3.0/api/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/gl-3.0/api/clearbuffer-invalid-drawbuffer.c b/tests/spec/gl-3.0/api/clearbuffer-invalid-drawbuffer.c
new file mode 100644
index 0000000..13cef9e
--- /dev/null
+++ b/tests/spec/gl-3.0/api/clearbuffer-invalid-drawbuffer.c
@@ -0,0 +1,226 @@
+/*
+ * Copyright © 2011 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 clearbuffer-invalid-drawbuffer.c
+ * Probe various invalid drawbuffer settings for glClearBuffer
+ *
+ * \author Ian Romanick
+ */
+#include "piglit-util.h"
+
+int piglit_width = 100, piglit_height = 100;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
+enum piglit_result
+piglit_display(void)
+{
+	return PIGLIT_FAIL;
+}
+
+void piglit_init(int argc, char **argv)
+{
+	static const float zero_f[4] = {
+		0.0f, 0.0f, 0.0f, 0.0f
+	};
+
+	static const int zero_i[4] = {
+		0, 0, 0, 0
+	};
+
+	GLint max_draw_buffers;
+	unsigned i;
+
+	piglit_require_gl_version(30);
+
+	glGetIntegerv(GL_MAX_DRAW_BUFFERS, &max_draw_buffers);
+
+	/* Table 2.3, "Summary of GL errors" on page 17 (page 33) of the
+	 * OpenGL 3.0 spec says:
+	 *
+	 *     "Error         Description                    Offending command
+	 *                                                   ignored?
+	 *     ...
+	 *     INVALID_VALUE  Numeric argument out of range  Yes"
+	 *
+	 * For all of the tests involving an invalid value passed to the
+	 * drawbuffer argument, we expect an error of GL_INVALID_VALUE.
+	 */
+
+	/* Page 263 (page 279 of the PDF) of the OpenGL 3.0 spec says:
+	 *
+	 *     "If buffer is DEPTH, drawbuffer must be zero, and value points
+	 *     to the single depth value to clear the depth buffer to."
+	 *
+	 */
+	if (!piglit_automatic)
+		printf("Trying invalid drawbuffer with GL_DEPTH...\n");
+
+	glClearBufferfv(GL_DEPTH, 1, zero_f);
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	glClearBufferfv(GL_DEPTH, -1, zero_f);
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	glClearBufferiv(GL_DEPTH, 1, zero_i);
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	glClearBufferiv(GL_DEPTH, -1, zero_i);
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	glClearBufferuiv(GL_DEPTH, 1, (GLuint *) zero_i);
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	glClearBufferuiv(GL_DEPTH, -1, (GLuint *) zero_i);
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	/* Page 263 (page 279 of the PDF) of the OpenGL 3.0 spec says:
+	 *
+	 *     "If buffer is STENCIL, drawbuffer must be zero, and value
+	 *     points to the single stencil value to clear the stencil buffer
+	 *     to."
+	 */
+	if (!piglit_automatic)
+		printf("Trying invalid drawbuffer with GL_STENCIL...\n");
+
+	glClearBufferfv(GL_STENCIL, 1, zero_f);
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	glClearBufferfv(GL_STENCIL, -1, zero_f);
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	glClearBufferiv(GL_STENCIL, 1, zero_i);
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	glClearBufferiv(GL_STENCIL, -1, zero_i);
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	glClearBufferuiv(GL_STENCIL, 1, (GLuint *) zero_i);
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	glClearBufferuiv(GL_STENCIL, -1, (GLuint *) zero_i);
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	/* Page 263 (page 279 of the PDF) of the OpenGL 3.0 spec says:
+	 *
+	 *     "The command
+	 *
+	 *          void ClearBufferfi( enum buffer, int drawbuffer,
+	 *                              float depth, int stencil );
+	 *
+	 *     clears both depth and stencil buffers of the currently bound
+	 *     draw framebuffer.  buffer must be DEPTH STENCIL and drawbuffer
+	 *     must be zero."
+	 */
+	if (!piglit_automatic)
+		printf("Trying invalid drawbuffer with GL_DEPTH_STENCIL...\n");
+
+	glClearBufferfi(GL_DEPTH_STENCIL, 1, 0.0f, 0);
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	glClearBufferfi(GL_DEPTH_STENCIL, -1, 0.0f, 0);
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	/* Page 264 (page 280 of the PDF) of the OpenGL 3.0 spec says:
+	 *
+	 *     "ClearBuffer generates an INVALID VALUE error if buffer is
+	 *     COLOR and drawbuffer is less than zero, or greater than the
+	 *     value of MAX DRAW BUFFERS minus one; or if buffer is DEPTH,
+	 *     STENCIL, or DEPTH STENCIL and drawbuffer is not zero."
+	 */
+	if (!piglit_automatic)
+		printf("Trying invalid drawbuffer with GL_COLOR...\n");
+
+	glClearBufferfv(GL_COLOR, -1, zero_f);
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	glClearBufferfv(GL_COLOR, max_draw_buffers, zero_f);
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	glClearBufferiv(GL_COLOR, -1, zero_i);
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	glClearBufferiv(GL_COLOR, max_draw_buffers, zero_i);
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	glClearBufferuiv(GL_COLOR, -1, (GLuint *) zero_i);
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	glClearBufferuiv(GL_COLOR, max_draw_buffers, (GLuint *) zero_i);
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	for (i = 0; i < max_draw_buffers; i++) {
+		/* It seems reasonable that someone might accidentally use
+		 * GL_DRAW_BUFFERi instead of just i.  Make sure that also
+		 * generates the expected error.
+		 */
+		glClearBufferfv(GL_COLOR, GL_DRAW_BUFFER0 + i, zero_f);
+		piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+		glClearBufferiv(GL_COLOR, GL_DRAW_BUFFER0 + i, zero_i);
+		piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+		glClearBufferuiv(GL_COLOR, GL_DRAW_BUFFER0 + i,
+				 (GLuint *) zero_i);
+		piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+	}
+
+	/* Now try the valid cases and assert no error.
+	 */
+	if (!piglit_automatic)
+		printf("Trying valid drawbuffer with everything...\n");
+
+	for (i = 0; i < max_draw_buffers; i++) {
+		glClearBufferfv(GL_COLOR, i, zero_f);
+		piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+		glClearBufferiv(GL_COLOR, i, zero_i);
+		piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+		glClearBufferuiv(GL_COLOR, i, (GLuint *) zero_i);
+		piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+	}
+
+	glClearBufferfv(GL_DEPTH, 0, zero_f);
+	piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+	glClearBufferiv(GL_DEPTH, 0, zero_i);
+	piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+	glClearBufferuiv(GL_DEPTH, 0, (GLuint *) zero_i);
+	piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+	glClearBufferfv(GL_STENCIL, 0, zero_f);
+	piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+	glClearBufferiv(GL_STENCIL, 0, zero_i);
+	piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+	glClearBufferuiv(GL_STENCIL, 0, (GLuint *) zero_i);
+	piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+	glClearBufferfi(GL_DEPTH_STENCIL, 0, 0.0f, 0);
+	piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+	piglit_report_result(PIGLIT_PASS);
+}
-- 
1.7.6.4



More information about the Piglit mailing list