[Piglit] [PATCH 6/9] GL 3.2: Test FRAMEBUFFER_ATTACHMENT_LAYERED was added.
Jacob Penner
jkpenner91 at gmail.com
Mon Aug 26 11:51:00 PDT 2013
Currently test fails. The glError GL_INVALID_ENUM is returned from
glGetFramebufferAttachmentParameteriv. It appears that
GL_FRAMEBUFFER_ATTACHMENT_LAYERED may not be correctly working with the function
---
.../get-framebuffer-attachment-parameter.c | 210 +++++++++++++++++++++
1 file changed, 210 insertions(+)
create mode 100644 tests/spec/gl-3.2/layered-rendering/get-framebuffer-attachment-parameter.c
diff --git a/tests/spec/gl-3.2/layered-rendering/get-framebuffer-attachment-parameter.c b/tests/spec/gl-3.2/layered-rendering/get-framebuffer-attachment-parameter.c
new file mode 100644
index 0000000..88c9ad9
--- /dev/null
+++ b/tests/spec/gl-3.2/layered-rendering/get-framebuffer-attachment-parameter.c
@@ -0,0 +1,210 @@
+/*
+ * 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 get-framebuffer-attachment-parameter.c
+ *
+ * Section 6.1.11(Querying GL State) From GL spec 3.2 core:
+ *
+ * void GetFramebufferAttachmentParameteriv( enum target, enum attachment,
+ * enum pname, int *params );
+ *
+ * If pname is FRAMEBUFFER_ATTACHMENT_LAYERED, then params will contain
+ * TRUE if an entire level of a three-dimesional texture, cube map texture,
+ * or one-or two-dimensional array texture is attached. Otherwise, params will
+ * contain FALSE.
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_compat_version = 31;
+ config.supports_gl_core_version = 31;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+GLenum testTargets [] = {
+ GL_TEXTURE_3D,
+ GL_TEXTURE_CUBE_MAP,
+ GL_TEXTURE_1D_ARRAY,
+ GL_TEXTURE_2D_ARRAY,
+ GL_TEXTURE_2D_MULTISAMPLE_ARRAY
+};
+
+static const int texWidth = 20;
+static const int texHeight = 20;
+static const int texDepth = 2;
+
+/* Create a new texture with set values based on passed
+ * texture type.
+ */
+void
+create_bind_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_2D_MULTISAMPLE_ARRAY:
+ glTexImage3DMultisample(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, 4,
+ GL_RGB, texWidth, texHeight, texDepth,
+ GL_FALSE);
+ 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;
+ }
+}
+
+/* Get the expected value for is the texture type is layered */
+void
+tex_is_layered(GLenum textureType, GLint *isLayered) {
+ switch(textureType) {
+ case GL_TEXTURE_2D:
+ *isLayered = GL_FALSE;
+ break;
+ case GL_TEXTURE_3D:
+ case GL_TEXTURE_2D_ARRAY:
+ case GL_TEXTURE_1D_ARRAY:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ case GL_TEXTURE_CUBE_MAP:
+ *isLayered = GL_TRUE;
+ break;
+ }
+}
+
+/* Attach the texture to the passed target. */
+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
+test_framebuffer_attachment_layered(GLenum textureType) {
+ GLuint fbo, texture;
+ GLint isTextureLayered = GL_FALSE;
+ GLint attachmentLayered = -1;
+
+ glGenFramebuffers(1, &fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+
+ create_bind_texture(textureType, &texture);
+ attach_texture(GL_FRAMEBUFFER, textureType, texture);
+
+ tex_is_layered(textureType, &isTextureLayered);
+
+ attach_texture(GL_FRAMEBUFFER, textureType, texture);
+
+ if(!piglit_check_gl_error(GL_NO_ERROR)) {
+ printf("Error creating texture and framebuffer setup\n"
+ "texture type: %s\n",
+ piglit_get_gl_enum_name(textureType));
+ return false;
+ }
+
+ /* Ask for if the attachment is layered */
+ glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,
+ GL_COLOR_ATTACHMENT0,
+ GL_FRAMEBUFFER_ATTACHMENT_LAYERED,
+ &attachmentLayered);
+
+ if(!piglit_check_gl_error(GL_NO_ERROR)) {
+ printf("Error with GetFramebufferAttachmentParameteriv\n");
+ return false;
+ }
+
+ if(attachmentLayered != isTextureLayered) {
+ printf("Expected framebuffer status '%s', but recieved '%s'\n",
+ piglit_get_prim_name(isTextureLayered),
+ piglit_get_gl_enum_name(attachmentLayered));
+ return false;
+ }
+
+ /* Clean up */
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ glDeleteFramebuffers(1, &fbo);
+ glDeleteTextures(1, &texture);
+
+ return true;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ int i;
+ bool pass = true;
+
+ for(i = 0; i < ARRAY_SIZE(testTargets); i++) {
+ pass = test_framebuffer_attachment_layered(testTargets[i]) && pass;
+ }
+
+ piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+ /* UNREACHALBE! */
+ return PIGLIT_FAIL;
+}
--
1.8.3.1
More information about the Piglit
mailing list