[Piglit] [PATCH] Test that a layered fbo can have attachments with different layer counts.

Paul Berry stereotype441 at gmail.com
Tue Jan 7 07:29:23 PST 2014


---
 tests/all.tests                                    |   1 +
 .../gl-3.2/layered-rendering/CMakeLists.gl.txt     |   1 +
 .../framebuffer-layer-count-mismatch.c             | 107 +++++++++++++++++++++
 3 files changed, 109 insertions(+)
 create mode 100644 tests/spec/gl-3.2/layered-rendering/framebuffer-layer-count-mismatch.c

diff --git a/tests/all.tests b/tests/all.tests
index edf066b..70ab814 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -755,6 +755,7 @@ spec['!OpenGL 3.2/layered-rendering/framebuffertexture-defaults'] = concurrent_t
 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-layer-count-mismatch'] = concurrent_test('gl-3.2-layered-rendering-framebuffer-layer-count-mismatch')
 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')
 spec['!OpenGL 3.2/layered-rendering/gl-layer-cube-map'] = concurrent_test('gl-3.2-layered-rendering-gl-layer-cube-map')
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 a24ed8f..496b5a1 100644
--- a/tests/spec/gl-3.2/layered-rendering/CMakeLists.gl.txt
+++ b/tests/spec/gl-3.2/layered-rendering/CMakeLists.gl.txt
@@ -16,6 +16,7 @@ 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-framebuffer-layer-count-mismatch framebuffer-layer-count-mismatch.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)
 piglit_add_executable (gl-3.2-layered-rendering-framebuffertexture-defaults framebuffertexture-defaults.c)
diff --git a/tests/spec/gl-3.2/layered-rendering/framebuffer-layer-count-mismatch.c b/tests/spec/gl-3.2/layered-rendering/framebuffer-layer-count-mismatch.c
new file mode 100644
index 0000000..05cb8ec
--- /dev/null
+++ b/tests/spec/gl-3.2/layered-rendering/framebuffer-layer-count-mismatch.c
@@ -0,0 +1,107 @@
+/*
+ * 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
+ *
+ * ARB_geometry_shader4 doesn't permit layered framebuffers to have
+ * mismatched layer counts.  From ARB_geometry_shader4, under the
+ * heading "add to the list of conditions necessary for completeness":
+ *
+ *     * If any framebuffer attachment is layered, all attachments
+ *       must have the same layer count.  For three-dimensional
+ *       textures, the layer count is the depth of the attached
+ *       volume.  For cube map textures, the layer count is always
+ *       six.  For one- and two-dimensional array textures, the layer
+ *       count is simply the number of layers in the array texture.
+ *       { FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB }
+ *
+ * However, this restriction was lifted when geometry shaders were
+ * adopted into OpenGL 3.2.  Instead, OpenGL 3.2 states, in section
+ * 4.4.7 (Layered Framebuffers):
+ *
+ *     When fragments are written to a layered framebuffer, the
+ *     fragment’s layer number selects an image from the array of
+ *     images at each attachment point to use for the stencil test
+ *     (see section 4.1.5), depth buffer test (see section 4.1.6), and
+ *     for blending and color buffer writes (see section 4.1.8).  If
+ *     the fragment’s layer number is negative, or greater than the
+ *     minimum number of layers of any attachment, the effects of the
+ *     fragment on the framebuffer contents are undefined.
+ *
+ * This test verifies that a framebuffer is considered complete even
+ * if two different attachments have different layer counts.
+ */
+
+#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
+
+
+void
+piglit_init(int argc, char **argv)
+{
+	GLuint textures[2];
+	GLuint fbo;
+	GLenum fbstatus;
+
+	glGenTextures(2, textures);
+	glBindTexture(GL_TEXTURE_2D_ARRAY, textures[0]);
+	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, 2, 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, 4, 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_COMPLETE) {
+		printf("Framebuffer incomplete: %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.5.2



More information about the Piglit mailing list