[Piglit] [PATCH 1/3] gl-3.0: Verify errors generated for invalid parameters to glBindFragDataLocation

Ian Romanick idr at freedesktop.org
Fri Nov 4 16:34:45 PDT 2011


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

This test passes on AMD's closed-source driver and NVIDIA's
closed-source driver.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 tests/all.tests                                    |    1 +
 tests/spec/gl-3.0/api/CMakeLists.gl.txt            |    1 +
 .../gl-3.0/api/bindfragdata-invalid-parameters.c   |  104 ++++++++++++++++++++
 3 files changed, 106 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/gl-3.0/api/bindfragdata-invalid-parameters.c

diff --git a/tests/all.tests b/tests/all.tests
index 4b1ba12..429f65a 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -788,6 +788,7 @@ add_concurrent_test(gl20, 'vertex-program-two-side')
 
 gl30 = Group()
 spec['!OpenGL 3.0'] = gl30
+add_concurrent_test(gl30, 'bindfragdata-invalid-location')
 add_concurrent_test(gl30, 'clearbuffer-depth-stencil')
 add_concurrent_test(gl30, 'clearbuffer-invalid-drawbuffer')
 add_concurrent_test(gl30, 'clearbuffer-invalid-buffer')
diff --git a/tests/spec/gl-3.0/api/CMakeLists.gl.txt b/tests/spec/gl-3.0/api/CMakeLists.gl.txt
index 13d7353..2e9f190 100644
--- a/tests/spec/gl-3.0/api/CMakeLists.gl.txt
+++ b/tests/spec/gl-3.0/api/CMakeLists.gl.txt
@@ -12,6 +12,7 @@ link_libraries (
 	${GLUT_glut_LIBRARY}
 )
 
+add_executable (bindfragdata-invalid-parameters bindfragdata-invalid-parameters.c)
 add_executable (clearbuffer-depth clearbuffer-common.c clearbuffer-depth.c)
 add_executable (clearbuffer-depth-stencil clearbuffer-common.c clearbuffer-depth-stencil.c)
 add_executable (clearbuffer-invalid-drawbuffer clearbuffer-invalid-drawbuffer.c)
diff --git a/tests/spec/gl-3.0/api/bindfragdata-invalid-parameters.c b/tests/spec/gl-3.0/api/bindfragdata-invalid-parameters.c
new file mode 100644
index 0000000..db54124
--- /dev/null
+++ b/tests/spec/gl-3.0/api/bindfragdata-invalid-parameters.c
@@ -0,0 +1,104 @@
+/* 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 bindfragdata-invalid-parameters.c
+ * Verify that passing invalid parameters to glBindFragDataLocation generates
+ * the correct errors.
+ *
+ * \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)
+{
+	GLint max_draw_buffers;
+	GLuint prog;
+
+	piglit_require_gl_version(30);
+
+	glGetIntegerv(GL_MAX_DRAW_BUFFERS, &max_draw_buffers);
+
+	/* Page 237 (page 253 of the PDF) of the OpenGL 3.0 spec says:
+	 *
+	 *     "BindFragDataLocation may be issued before any shader objects
+	 *     are attached to a program object."
+	 *
+	 * As a result, all of the invalid location tests can be performed
+	 * without a shader at all.  Only a program object is necessary.
+	 */
+	prog = glCreateProgram();
+	piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+
+	/* Page 236 (page 252 of the PDF) of the OpenGL 3.0 spec says:
+	 *
+	 *     "The error INVALID VALUE is generated if colorNumber is equal
+	 *     or greater than MAX DRAW BUFFERS."
+	 *
+	 * Since the colorNumber parameter is unsigned, this statement means
+	 * an error should be generated if a negative number is used.
+	 */
+	printf("Trying location = -1...\n");
+	glBindFragDataLocation(prog, -1, "foo");
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	printf("Trying location = GL_MAX_DRAW_BUFFERS...\n");
+	glBindFragDataLocation(prog, max_draw_buffers, "foo");
+	piglit_check_gl_error(GL_INVALID_VALUE, PIGLIT_FAIL);
+
+	/* Page 236 (page 252 of the PDF) of the OpenGL 3.0 spec says:
+	 *
+	 *     "The error INVALID_OPERATION is generated if name starts with
+	 *     the reserved gl prefix."
+	 *
+	 * This was changed in a later version of the spec.  Page 279 (page
+	 * 296 of the PDF) of the OpenGL 4.2 Core spec says:
+	 *
+	 *     "The error INVALID_OPERATION is generated if name starts with
+	 *     the reserved gl_ prefix."
+	 *
+	 * The OpenGL 4.2 spec also matches the specified behavior of
+	 * glBindAttribLocation as far back as OpenGL 2.0.
+	 */
+	printf("Trying name = `gl_FragColor'...\n");
+	glBindFragDataLocation(prog, 0, "gl_FragColor");
+	piglit_check_gl_error(GL_INVALID_OPERATION, PIGLIT_FAIL);
+
+	printf("Trying name = `gl_FragDepth'...\n");
+	glBindFragDataLocation(prog, 0, "gl_FragDepth");
+	piglit_check_gl_error(GL_INVALID_OPERATION, PIGLIT_FAIL);
+
+	printf("Trying name = `gl_'...\n");
+	glBindFragDataLocation(prog, 0, "gl_");
+	piglit_check_gl_error(GL_INVALID_OPERATION, PIGLIT_FAIL);
+
+	piglit_report_result(PIGLIT_PASS);
+}
-- 
1.7.6.4



More information about the Piglit mailing list