[Piglit] =?a?q?=5BPATCH=201/2=5D=20arb=5Fframebuffer=5Fobject=3A=20Add=20tests=20to=20check=20GL=5FDEPTH=5FSTENCIL=5FATTACHMENT?=

Chad Versace chad at chad-versace.us
Tue Nov 1 18:34:27 PDT 2011


Add the following tests:
	specs/ARB_framebuffer_object/same-attachment-glFramebufferRenderbuffer-GL_DEPTH_STENCIL_ATTACHMENT
	specs/ARB_framebuffer_object/same-attachment-glFramebufferTexture2D-GL_DEPTH_STENCIL_ATTACHMENT

The test check that if an object is attached to the
GL_DEPTH_STENCIL_ATTACHMENT points, then it is also attached to the
GL_STENCIL_ATTACHMENT, and GL_DEPTH_STENCIL_ATTACHMENT points.
---
 tests/all.tests                                    |    6 +
 tests/spec/CMakeLists.txt                          |    1 +
 .../spec/arb_framebuffer_object/CMakeLists.gl.txt  |   19 +++
 tests/spec/arb_framebuffer_object/CMakeLists.txt   |    1 +
 ...ufferRenderbuffer-GL_DEPTH_STENCIL_ATTACHMENT.c |  128 +++++++++++++++++++
 ...mebufferTexture2D-GL_DEPTH_STENCIL_ATTACHMENT.c |  135 ++++++++++++++++++++
 6 files changed, 290 insertions(+), 0 deletions(-)
 create mode 100644 tests/spec/arb_framebuffer_object/CMakeLists.gl.txt
 create mode 100644 tests/spec/arb_framebuffer_object/CMakeLists.txt
 create mode 100644 tests/spec/arb_framebuffer_object/same-attachment-glFramebufferRenderbuffer-GL_DEPTH_STENCIL_ATTACHMENT.c
 create mode 100644 tests/spec/arb_framebuffer_object/same-attachment-glFramebufferTexture2D-GL_DEPTH_STENCIL_ATTACHMENT.c

diff --git a/tests/all.tests b/tests/all.tests
index e501a80..e611649 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -931,6 +931,12 @@ add_shader_test_dir(arb_draw_instanced,
                     os.path.dirname(__file__) + '/spec/arb_draw_instanced/execution',
                     recursive=True)
 
+# Group ARB_framebuffer_object
+arb_framebuffer_object = Group()
+spec['ARB_framebuffer_object'] = arb_framebuffer_object
+add_plain_test(arb_framebuffer_object, 'same-attachment-glFramebufferTexture2D-GL_DEPTH_STENCIL_ATTACHMENT')
+add_plain_test(arb_framebuffer_object, 'same-attachment-glFramebufferRenderbuffer-GL_DEPTH_STENCIL_ATTACHMENT')
+
 # Group ARB_sampler_objects
 arb_sampler_objects = Group()
 spec['ARB_sampler_objects'] = arb_sampler_objects
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 5a08cd9..07e9913 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -1,5 +1,6 @@
 add_subdirectory (arb_color_buffer_float)
 add_subdirectory (arb_es2_compatibility)
+add_subdirectory (arb_framebuffer_object)
 add_subdirectory (arb_instanced_arrays)
 add_subdirectory (arb_map_buffer_range)
 add_subdirectory (arb_robustness)
diff --git a/tests/spec/arb_framebuffer_object/CMakeLists.gl.txt b/tests/spec/arb_framebuffer_object/CMakeLists.gl.txt
new file mode 100644
index 0000000..3b9fec3
--- /dev/null
+++ b/tests/spec/arb_framebuffer_object/CMakeLists.gl.txt
@@ -0,0 +1,19 @@
+include_directories(
+	${GLEXT_INCLUDE_DIR}
+	${OPENGL_INCLUDE_PATH}
+	${GLUT_INCLUDE_DIR}
+	${piglit_SOURCE_DIR}/tests/mesa/util
+	${piglit_SOURCE_DIR}/tests/util
+)
+
+link_libraries (
+	piglitutil
+	${OPENGL_gl_LIBRARY}
+	${OPENGL_glu_LIBRARY}
+	${GLUT_glut_LIBRARY}
+)
+
+add_executable(same-attachment-glFramebufferTexture2D-GL_DEPTH_STENCIL_ATTACHMENT same-attachment-glFramebufferTexture2D-GL_DEPTH_STENCIL_ATTACHMENT.c)
+add_executable(same-attachment-glFramebufferRenderbuffer-GL_DEPTH_STENCIL_ATTACHMENT same-attachment-glFramebufferRenderbuffer-GL_DEPTH_STENCIL_ATTACHMENT.c)
+
+# vim: ft=cmake:
diff --git a/tests/spec/arb_framebuffer_object/CMakeLists.txt b/tests/spec/arb_framebuffer_object/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/arb_framebuffer_object/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/arb_framebuffer_object/same-attachment-glFramebufferRenderbuffer-GL_DEPTH_STENCIL_ATTACHMENT.c b/tests/spec/arb_framebuffer_object/same-attachment-glFramebufferRenderbuffer-GL_DEPTH_STENCIL_ATTACHMENT.c
new file mode 100644
index 0000000..f8ff87d
--- /dev/null
+++ b/tests/spec/arb_framebuffer_object/same-attachment-glFramebufferRenderbuffer-GL_DEPTH_STENCIL_ATTACHMENT.c
@@ -0,0 +1,128 @@
+/*
+ * 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.
+ */
+
+/**
+ * Attach a GL_TEXTURE_2D to the GL_DEPTH_STENCIL_ATTACHMENT point with
+ * glFramebufferTexture2D(), then verify with
+ * glGetFramebufferAttachmentParameteriv() that all three of
+ * GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT, and GL_DEPTH_STENCIL_ATTACHMENT
+ * point to the texture.
+ */
+
+#include <stdio.h>
+#include "piglit-util.h"
+
+int piglit_width = 200;
+int piglit_height = 200;
+int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB;
+
+const char*
+get_attachment_string(GLint attach)
+{
+	switch (attach) {
+	case GL_DEPTH_ATTACHMENT: return "GL_DEPTH_ATTACHMENT";
+	case GL_STENCIL_ATTACHMENT: return "GL_STENCIL_ATTACHMENT";
+	case GL_DEPTH_STENCIL_ATTACHMENT: return "GL_DEPTH_STENICL";
+	default: return NULL;
+	}
+}
+
+bool
+check_attachment(GLenum attach, GLint expect_name)
+{
+	GLint actual_type;
+	GLint actual_name;
+
+	glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,
+					      attach,
+				              GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
+				              &actual_type);
+
+	if (actual_type != GL_RENDERBUFFER) {
+		char actual_type_str[16];
+
+		if (actual_type == GL_NONE) {
+			sprintf(actual_type_str, "GL_NONE");
+		} else {
+			snprintf(actual_type_str, 16, "0x%x", actual_type);
+		}
+
+		fprintf(stderr,
+			"error: expected GL_RENDERBUFFER for %s attachment type, but found %s\n",
+			get_attachment_string(attach), actual_type_str);
+
+		/* Return now and don't query the attachment name, because
+		 * that would generate a GL error.
+		 */
+		return false;
+	}
+
+	glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,
+					      attach,
+				              GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
+				              &actual_name);
+
+	if (actual_name != expect_name) {
+		fprintf(stderr,
+			"error: expected %d for %s attachment name, but found %d\n",
+			expect_name, get_attachment_string(attach), actual_name);
+		return false;
+	}
+
+	return true;
+}
+
+enum piglit_result
+piglit_display()
+{
+	bool pass = true;
+
+	GLuint fb;
+	GLuint rb;
+
+	glGenRenderbuffers(1, &rb);
+	glGenFramebuffers(1, &fb);
+	glBindRenderbuffer(GL_RENDERBUFFER, rb);
+	glBindFramebuffer(GL_FRAMEBUFFER, fb);
+
+	glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL, 200, 200);
+	glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER,
+			         GL_DEPTH_STENCIL_ATTACHMENT,
+			         GL_RENDERBUFFER,
+			         rb);
+
+	piglit_check_gl_error(0, PIGLIT_FAIL);
+
+	pass = check_attachment(GL_DEPTH_ATTACHMENT, rb) && pass;
+	pass = check_attachment(GL_STENCIL_ATTACHMENT, rb) && pass;
+	pass = check_attachment(GL_DEPTH_STENCIL_ATTACHMENT, rb) && pass;
+
+	piglit_check_gl_error(0, PIGLIT_FAIL);
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void piglit_init(int argc, char **argv)
+{
+	piglit_require_extension("GL_ARB_framebuffer_object");
+}
diff --git a/tests/spec/arb_framebuffer_object/same-attachment-glFramebufferTexture2D-GL_DEPTH_STENCIL_ATTACHMENT.c b/tests/spec/arb_framebuffer_object/same-attachment-glFramebufferTexture2D-GL_DEPTH_STENCIL_ATTACHMENT.c
new file mode 100644
index 0000000..c0c1709
--- /dev/null
+++ b/tests/spec/arb_framebuffer_object/same-attachment-glFramebufferTexture2D-GL_DEPTH_STENCIL_ATTACHMENT.c
@@ -0,0 +1,135 @@
+/*
+ * 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.
+ */
+
+/**
+ * Attach a renderbuffer to the GL_DEPTH_STENCIL_ATTACHMENT point, then verify
+ * with glGetFramebufferAttachmentParameteriv() that all three of
+ * GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT, and GL_DEPTH_STENCIL_ATTACHMENT
+ * point to the renderbuffer.
+ */
+
+#include <stdio.h>
+#include "piglit-util.h"
+
+int piglit_width = 200;
+int piglit_height = 200;
+int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB;
+
+const char*
+get_attachment_string(GLint attach)
+{
+	switch (attach) {
+	case GL_DEPTH_ATTACHMENT: return "GL_DEPTH_ATTACHMENT";
+	case GL_STENCIL_ATTACHMENT: return "GL_STENCIL_ATTACHMENT";
+	case GL_DEPTH_STENCIL_ATTACHMENT: return "GL_DEPTH_STENICL";
+	default: return NULL;
+	}
+}
+
+bool
+check_attachment(GLenum attach, GLint expect_name)
+{
+	GLint actual_type;
+	GLint actual_name;
+
+	glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,
+					      attach,
+				              GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE,
+				              &actual_type);
+
+	if (actual_type != GL_TEXTURE) {
+		char actual_type_str[16];
+
+		if (actual_type == GL_NONE) {
+			sprintf(actual_type_str, "GL_NONE");
+		} else {
+			snprintf(actual_type_str, 16, "0x%x", actual_type);
+		}
+
+		fprintf(stderr,
+			"error: expected GL_TEXTURE for %s attachment type, but found %s\n",
+			get_attachment_string(attach), actual_type_str);
+
+		/* Return now and don't query the attachment name, because
+		 * that would generate a GL error.
+		 */
+		return false;
+	}
+
+	glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,
+					      attach,
+				              GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME,
+				              &actual_name);
+
+	if (actual_name != expect_name) {
+		fprintf(stderr,
+			"error: expected %d for %s attachment name, but found %d\n",
+			expect_name, get_attachment_string(attach), actual_name);
+		return false;
+	}
+
+	return true;
+}
+
+enum piglit_result
+piglit_display()
+{
+	bool pass = true;
+
+	GLuint fb;
+	GLuint tex;
+
+	glGenTextures(1, &tex);
+	glGenFramebuffers(1, &fb);
+	glBindTexture(GL_TEXTURE_2D, tex);
+	glBindFramebuffer(GL_FRAMEBUFFER, fb);
+
+	glTexImage2D(GL_TEXTURE_2D,
+		     0, /*level*/
+		     GL_DEPTH_STENCIL,
+		     200, 200, /*width, height*/
+		     0, /*border*/
+		     GL_DEPTH_STENCIL,
+		     GL_UNSIGNED_INT_24_8,
+		     NULL);
+	glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER,
+			       GL_DEPTH_STENCIL_ATTACHMENT,
+			       GL_TEXTURE_2D,
+			       tex,
+			       0); /*level*/
+
+	piglit_check_gl_error(0, PIGLIT_FAIL);
+
+	pass = check_attachment(GL_DEPTH_ATTACHMENT, tex) && pass;
+	pass = check_attachment(GL_STENCIL_ATTACHMENT, tex) && pass;
+	pass = check_attachment(GL_DEPTH_STENCIL_ATTACHMENT, tex) && pass;
+
+	piglit_check_gl_error(0, PIGLIT_FAIL);
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void piglit_init(int argc, char **argv)
+{
+	piglit_require_extension("GL_ARB_framebuffer_object");
+}
-- 
1.7.7



More information about the Piglit mailing list