[Piglit] [PATCH 2/5] Add a new test for getting GL_RENDERBUFFER_INTERNAL_FORMAT.

Eric Anholt eric at anholt.net
Wed Apr 18 18:29:48 PDT 2012


This was in response to an apparent failure in webgl conformance
tests, but it didn't catch the problem I expected.
---
 tests/all.tests                                    |    1 +
 tests/fbo/fbo-formats.h                            |    5 +-
 .../spec/arb_framebuffer_object/CMakeLists.gl.txt  |    1 +
 .../get-renderbuffer-internalformat.c              |   82 ++++++++++++++++++++
 4 files changed, 87 insertions(+), 2 deletions(-)
 create mode 100644 tests/spec/arb_framebuffer_object/get-renderbuffer-internalformat.c

diff --git a/tests/all.tests b/tests/all.tests
index c2d2d2b..c0ba04c 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -130,6 +130,7 @@ execfile(testsDir + '/glean-vertProg1.tests')
 def add_fbo_formats_tests(path, extension):
 	profile.tests[path + '/fbo-generatemipmap-formats'] = PlainExecTest('fbo-generatemipmap-formats -auto ' + extension)
 	profile.tests[path + '/fbo-clear-formats'] = PlainExecTest('fbo-clear-formats -auto ' + extension)
+	profile.tests[path + '/get-renderbuffer-internalformat'] = concurrent_test('get-renderbuffer-internalformat ' + extension)
 	if 'depth' not in extension:
 		profile.tests[path + '/fbo-blending-formats'] = PlainExecTest('fbo-blending-formats -auto ' + extension)
 		profile.tests[path + '/fbo-alphatest-formats'] = PlainExecTest('fbo-alphatest-formats -auto ' + extension)
diff --git a/tests/fbo/fbo-formats.h b/tests/fbo/fbo-formats.h
index 0c5ff93..9f5d911 100644
--- a/tests/fbo/fbo-formats.h
+++ b/tests/fbo/fbo-formats.h
@@ -547,7 +547,8 @@ static void fbo_formats_init(int argc, char **argv, GLboolean print_options)
 {
 	int i, j, k;
 
-	glutKeyboardFunc(fbo_formats_key_func);
+	if (!piglit_automatic)
+		glutKeyboardFunc(fbo_formats_key_func);
 
 	piglit_require_extension("GL_EXT_framebuffer_object");
 	piglit_require_extension("GL_ARB_texture_env_combine");
@@ -618,7 +619,7 @@ static enum piglit_result fbo_formats_display(test_func test_format)
 		add_result(&all_skip, &end_result, result);
 	}
 
-	glutSwapBuffers();
+	piglit_present_results();
 
 	if (all_skip)
 		return PIGLIT_SKIP;
diff --git a/tests/spec/arb_framebuffer_object/CMakeLists.gl.txt b/tests/spec/arb_framebuffer_object/CMakeLists.gl.txt
index 14b8811..0783358 100644
--- a/tests/spec/arb_framebuffer_object/CMakeLists.gl.txt
+++ b/tests/spec/arb_framebuffer_object/CMakeLists.gl.txt
@@ -12,6 +12,7 @@ link_libraries (
 	${GLUT_glut_LIBRARY}
 )
 
+piglit_add_executable(get-renderbuffer-internalformat get-renderbuffer-internalformat.c)
 piglit_add_executable(same-attachment-glFramebufferTexture2D-GL_DEPTH_STENCIL_ATTACHMENT same-attachment-glFramebufferTexture2D-GL_DEPTH_STENCIL_ATTACHMENT.c)
 piglit_add_executable(same-attachment-glFramebufferRenderbuffer-GL_DEPTH_STENCIL_ATTACHMENT same-attachment-glFramebufferRenderbuffer-GL_DEPTH_STENCIL_ATTACHMENT.c)
 
diff --git a/tests/spec/arb_framebuffer_object/get-renderbuffer-internalformat.c b/tests/spec/arb_framebuffer_object/get-renderbuffer-internalformat.c
new file mode 100644
index 0000000..db76bdf
--- /dev/null
+++ b/tests/spec/arb_framebuffer_object/get-renderbuffer-internalformat.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright © 2012 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.
+ */
+
+/**
+ * Test that
+ * glGetRenderbufferParameteriv(GL_RENDERBUFFER_INTERNAL_FORMAT)
+ * returns the original internalFormat.
+ */
+
+#include <stdio.h>
+#include "piglit-util.h"
+#include "../../fbo/fbo-formats.h"
+
+int piglit_width = 10;
+int piglit_height = 10;
+int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB;
+
+enum piglit_result
+piglit_display()
+{
+	/* Unreached. */
+	return PIGLIT_FAIL;
+}
+
+static enum piglit_result
+test_format(const struct format_desc *format, GLenum baseformat)
+{
+	GLuint rb;
+	GLint internalformat;
+
+	/* These texture image formats are not color-renderable
+	 * internalformats for renderbuffers.
+	 */
+	if (format->internalformat >= 1 &&
+	    format->internalformat <= 4)
+		return PIGLIT_SKIP;
+
+	printf("Testing %s: ", format->name);
+	glGenRenderbuffers(1, &rb);
+	glBindRenderbuffer(GL_RENDERBUFFER, rb);
+	glRenderbufferStorage(GL_RENDERBUFFER, format->internalformat, 1, 1);
+	glGetRenderbufferParameteriv(GL_RENDERBUFFER,
+				     GL_RENDERBUFFER_INTERNAL_FORMAT,
+				     &internalformat);
+
+	if (internalformat == format->internalformat) {
+		printf("OK\n");
+		return PIGLIT_PASS;
+	} else {
+		printf("FAIL (%s instead of %s)\n",
+		       piglit_get_gl_enum_name(internalformat),
+		       piglit_get_gl_enum_name(format->internalformat));
+		return PIGLIT_FAIL;
+	}
+}
+
+void piglit_init(int argc, char **argv)
+{
+	piglit_automatic = true;
+	fbo_formats_init(argc, argv, GL_TRUE);
+	piglit_report_result(fbo_formats_display(test_format));
+}
-- 
1.7.10



More information about the Piglit mailing list