[Piglit] [PATCH 8/9] GL 3.2: Test FramebufferTexture() with layered framebuffer attachments

Jacob Penner jkpenner91 at gmail.com
Mon Aug 26 11:53:17 PDT 2013


Currently tests fail, using glGetFramebufferAttachmentParameteriv to check that
the attachment is layered. The glError GL_INVALID_ENUM is returned from
glGetFramebufferAttachmentParameteriv. It appears that
GL_FRAMEBUFFER_ATTACHMENT_LAYERED may not be correctly working with the function
---
 .../gl-3.2/layered-rendering/framebuffertexture.c  | 190 +++++++++++++++++++++
 1 file changed, 190 insertions(+)
 create mode 100644 tests/spec/gl-3.2/layered-rendering/framebuffertexture.c

diff --git a/tests/spec/gl-3.2/layered-rendering/framebuffertexture.c b/tests/spec/gl-3.2/layered-rendering/framebuffertexture.c
new file mode 100644
index 0000000..788ac6d
--- /dev/null
+++ b/tests/spec/gl-3.2/layered-rendering/framebuffertexture.c
@@ -0,0 +1,190 @@
+/*
+ * 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 framebuffertexture-layered-attachment.c
+ *
+ * Section 4.4.2(Framebuffer Objects) From GL spec 3.2 core:
+ *
+ * void FramebufferTexture( enum target, enum attachment, uint texture,
+ *                          int level );
+ *
+ * If texture is the name of a three-dimensional texture, cube map texture,
+ * one-or two-dimensional array texture, or two-dimensional multisample array
+ * texture, the texture level attached to the framebuffer attachment point is
+ * an array of images, and the framebuffer attachment is considered layered.
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 31;
+	config.supports_gl_core_version = 31;
+
+	config.window_width  = 128;
+	config.window_height = 128;
+	config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+const int texWidth  = 10;
+const int texHeight = 10;
+const int texDepth  = 2;
+
+GLenum testTargets [] = {
+	GL_TEXTURE_3D,
+	GL_TEXTURE_CUBE_MAP,
+	GL_TEXTURE_1D_ARRAY,
+	GL_TEXTURE_2D_ARRAY,
+	GL_TEXTURE_2D_MULTISAMPLE_ARRAY
+};
+
+void
+create_texture(GLenum textureType, GLuint *texture) {
+	int i;
+	glGenTextures(1, texture);
+	glBindTexture(textureType, *texture);
+
+	switch(textureType) {
+	case GL_TEXTURE_2D:
+	case GL_TEXTURE_1D_ARRAY:
+		glTexParameteri(textureType, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+		glTexParameteri(textureType, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+		glTexParameteri(textureType, GL_TEXTURE_WRAP_S, GL_REPEAT);
+		glTexParameteri(textureType, GL_TEXTURE_WRAP_T, GL_REPEAT);
+		glTexImage2D(textureType, 0, GL_RGB, texWidth, texHeight,
+			     0, GL_RGB, GL_FLOAT, NULL);
+		break;
+	case GL_TEXTURE_3D:
+	case GL_TEXTURE_2D_ARRAY:
+		glTexParameteri(textureType, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+		glTexParameteri(textureType, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+		glTexParameteri(textureType, GL_TEXTURE_WRAP_S, GL_REPEAT);
+		glTexParameteri(textureType, GL_TEXTURE_WRAP_T, GL_REPEAT);
+		glTexParameteri(textureType, GL_TEXTURE_WRAP_R, GL_REPEAT);
+		glTexImage3D(textureType, 0, GL_RGB, texWidth, texHeight,
+			     texDepth, 0, GL_RGB, GL_FLOAT, NULL);
+		break;
+	case GL_TEXTURE_CUBE_MAP:
+		/* loop through each cube map face */
+		for(i = 0; i < 6; i++) {
+			glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0,
+				     GL_RGB, texWidth, texHeight, 0, GL_RGB,
+				     GL_FLOAT, NULL);
+		}
+		break;
+	case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+		glTexImage3DMultisample(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, 4,
+					GL_RGB, texWidth, texHeight, texDepth,
+					GL_FALSE);
+		break;
+	}
+
+}
+
+void
+attach_texture(GLenum target, GLenum textureType, GLuint texture) {
+	switch(textureType) {
+	case GL_TEXTURE_2D:
+		glFramebufferTexture2D(target, GL_COLOR_ATTACHMENT0,
+				       textureType, texture, 0);
+		break;
+	case GL_TEXTURE_1D_ARRAY:
+	case GL_TEXTURE_3D:
+	case GL_TEXTURE_2D_ARRAY:
+	case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+		glFramebufferTexture(target, GL_COLOR_ATTACHMENT0, texture, 0);
+		break;
+	case GL_TEXTURE_CUBE_MAP:
+		glFramebufferTexture2D(target, GL_COLOR_ATTACHMENT0,
+				       GL_TEXTURE_CUBE_MAP_POSITIVE_X,
+				       texture, 0);
+		break;
+	}
+}
+
+bool
+testFramebufferTexture(GLenum textureType) {
+	bool pass = true;
+	GLuint fbo, texture;
+	GLint attachmentLayeredStatus = GL_FALSE;
+
+	glGenFramebuffers(1, &fbo);
+	glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+
+	/* creates and binds the texture of textureType */
+	create_texture(textureType, &texture);
+	piglit_check_gl_error(GL_NO_ERROR);
+
+	/* Attach the texture to the framebuffer */
+	attach_texture(GL_FRAMEBUFFER, textureType, texture);
+	piglit_check_gl_error(GL_NO_ERROR);
+
+	/* Check if the color attachment 0 is layered */
+	glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,
+					      GL_COLOR_ATTACHMENT0,
+					      GL_FRAMEBUFFER_ATTACHMENT_LAYERED,
+					      &attachmentLayeredStatus);
+
+	piglit_check_gl_error(GL_NO_ERROR);
+
+	glBindFramebuffer(GL_FRAMEBUFFER, 0);
+	glDeleteFramebuffers(1, &fbo);
+	glDeleteTextures(1, &texture);
+
+	switch (attachmentLayeredStatus){
+	case GL_TRUE:
+		break;
+	case GL_FALSE:
+		pass = false;
+		break;
+	default:
+		printf("Recieved incorrect data from "
+		       "glFramebufferAttachmentParameteriv\n");
+		pass =  false;
+		break;
+	}
+
+	return pass;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	int i;
+	bool pass = true;
+
+	for(i = 0; i < ARRAY_SIZE(testTargets); i++) {
+		pass = testFramebufferTexture(testTargets[i]) && pass;
+	}
+
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+	/* UNREACHABLE */
+	return PIGLIT_FAIL;
+}
-- 
1.8.3.1



More information about the Piglit mailing list