[Piglit] [PATCH] Test that all layered framebuffer attachments must be of the same type.

Paul Berry stereotype441 at gmail.com
Fri Nov 22 14:24:03 PST 2013


As of commit ec79c05, mesa checks that all layered framebuffer
attachments have the same layer count (which is actually
incorrect--layered framebuffer attachments are allowed to have
different layer counts), but it does not check that all layered
framebuffer attachments have the same type.

Therefore, to exercise this bug, we need a test which uses two layered
attachments with different types but the same layer count.  In this
test, one attachment is a cube map (which by its nature has 6 layers),
and the other is a 2D array texture with 6 layers.

This test is known to fail with Mesa commit ec79c05.
---
 tests/all.tests                                    |   1 +
 .../gl-3.2/layered-rendering/CMakeLists.gl.txt     |   1 +
 .../framebuffer-layer-attachment-mismatch.c        | 108 +++++++++++++++++++++
 3 files changed, 110 insertions(+)
 create mode 100644 tests/spec/gl-3.2/layered-rendering/framebuffer-layer-attachment-mismatch.c

diff --git a/tests/all.tests b/tests/all.tests
index c4ebfa7..28f6347 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -768,6 +768,7 @@ spec['!OpenGL 3.2/layered-rendering/framebuffertexture'] = concurrent_test('gl-3
 spec['!OpenGL 3.2/layered-rendering/framebuffertexture-buffer-textures'] = concurrent_test('gl-3.2-layered-rendering-framebuffertexture-buffer-textures')
 spec['!OpenGL 3.2/layered-rendering/framebuffertexture-defaults'] = concurrent_test('gl-3.2-layered-rendering-framebuffertexture-defaults')
 spec['!OpenGL 3.2/layered-rendering/readpixels'] = concurrent_test('gl-3.2-layered-rendering-readpixels')
+spec['!OpenGL 3.2/layered-rendering/framebuffer-layer-attachment-mismatch'] = concurrent_test('gl-3.2-layered-rendering-framebuffer-layer-attachment-mismatch')
 spec['!OpenGL 3.2/layered-rendering/framebuffer-layer-complete'] = concurrent_test('gl-3.2-layered-rendering-framebuffer-layer-complete')
 spec['!OpenGL 3.2/layered-rendering/framebuffer-layered-attachments'] = concurrent_test('gl-3.2-layered-rendering-framebuffer-layered-attachments')
 spec['!OpenGL 3.2/layered-rendering/gl-layer'] = concurrent_test('gl-3.2-layered-rendering-gl-layer')
diff --git a/tests/spec/gl-3.2/layered-rendering/CMakeLists.gl.txt b/tests/spec/gl-3.2/layered-rendering/CMakeLists.gl.txt
index c769b15..a24ed8f 100644
--- a/tests/spec/gl-3.2/layered-rendering/CMakeLists.gl.txt
+++ b/tests/spec/gl-3.2/layered-rendering/CMakeLists.gl.txt
@@ -14,6 +14,7 @@ piglit_add_executable (gl-3.2-layered-rendering-clear-color clear-color.c)
 piglit_add_executable (gl-3.2-layered-rendering-clear-color-all-types clear-color-all-types.c)
 piglit_add_executable (gl-3.2-layered-rendering-clear-depth clear-depth.c)
 piglit_add_executable (gl-3.2-layered-rendering-framebuffer-layered-attachments framebuffer-layered-attachments.c)
+piglit_add_executable (gl-3.2-layered-rendering-framebuffer-layer-attachment-mismatch framebuffer-layer-attachment-mismatch.c)
 piglit_add_executable (gl-3.2-layered-rendering-framebuffer-layer-complete framebuffer-layer-complete.c)
 piglit_add_executable (gl-3.2-layered-rendering-framebuffertexture framebuffertexture.c)
 piglit_add_executable (gl-3.2-layered-rendering-framebuffertexture-buffer-textures framebuffertexture-buffer-textures.c)
diff --git a/tests/spec/gl-3.2/layered-rendering/framebuffer-layer-attachment-mismatch.c b/tests/spec/gl-3.2/layered-rendering/framebuffer-layer-attachment-mismatch.c
new file mode 100644
index 0000000..2ae07b1
--- /dev/null
+++ b/tests/spec/gl-3.2/layered-rendering/framebuffer-layer-attachment-mismatch.c
@@ -0,0 +1,108 @@
+/*
+ * Copyright © 2013 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
+ *
+ * From section 4.4.4 (Framebuffer Completeness) of the GL 3.2 spec,
+ * under the "Whole Framebuffer Completeness" heading:
+ *
+ *     If any framebuffer attachment is layered, all populated
+ *     attachments must be layered.  Additionally, all populated color
+ *     attachments must be from textures of the same target.
+ *
+ *     { FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS }
+ *
+ * This test verifies that if two layered framebuffer attachments use
+ * different texture targets, then the framebuffer is incomplete, even
+ * if the two attachments have the same number of layer.  We test this
+ * by using a cube map texture and a 2D array texture containing 6
+ * layers.
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 32;
+	config.supports_gl_core_version = 32;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+
+#define TEX_SIZE 32
+
+
+static const GLenum cube_map_faces[6] = {
+	GL_TEXTURE_CUBE_MAP_POSITIVE_X,
+	GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
+	GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
+	GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
+	GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
+	GL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
+};
+
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLuint textures[2];
+	GLuint fbo;
+	int i;
+	GLenum fbstatus;
+
+	glGenTextures(2, textures);
+	glBindTexture(GL_TEXTURE_CUBE_MAP, textures[0]);
+	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+	glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+	for (i = 0; i < 6; i++) {
+		glTexImage2D(cube_map_faces[i], 0 /* level */, GL_RGBA,
+			     TEX_SIZE, TEX_SIZE, 0 /* border */, GL_RGBA,
+			     GL_FLOAT, NULL);
+	}
+	glBindTexture(GL_TEXTURE_2D_ARRAY, textures[1]);
+	glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+	glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+	glTexImage3D(GL_TEXTURE_2D_ARRAY, 0 /* level */, GL_RGBA, TEX_SIZE,
+		     TEX_SIZE, 6, 0 /* border */, GL_RGBA, GL_FLOAT, NULL);
+	glGenFramebuffers(1, &fbo);
+	glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+	glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, textures[0],
+			     0 /* level */);
+	glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, textures[1],
+			     0 /* level */);
+	fbstatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
+	if (fbstatus != GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS) {
+		printf("Expected GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS, got "
+		       "%s\n", piglit_get_gl_enum_name(fbstatus));
+		piglit_report_result(PIGLIT_FAIL);
+	}
+	piglit_report_result(PIGLIT_PASS);
+}
+
+
+enum piglit_result
+piglit_display(void)
+{
+	/* Should never be reached */
+	return PIGLIT_FAIL;
+}
-- 
1.8.4.2



More information about the Piglit mailing list