[Piglit] [PATCH 2/3] GL 3.2: Test layered framebuffer status
Jacob Penner
jkpenner91 at gmail.com
Mon Sep 16 10:31:25 PDT 2013
---
tests/all.tests | 1 +
.../gl-3.2/layered-rendering/CMakeLists.gl.txt | 1 +
.../layered-rendering/framebuffer-layer-complete.c | 197 +++++++++++++++++++++
3 files changed, 199 insertions(+)
create mode 100644 tests/spec/gl-3.2/layered-rendering/framebuffer-layer-complete.c
diff --git a/tests/all.tests b/tests/all.tests
index 8c657c5..6d099f5 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -754,6 +754,7 @@ spec['!OpenGL 3.2/layered-rendering/clear-color'] = concurrent_test('gl-3.2-laye
spec['!OpenGL 3.2/layered-rendering/clear-depth'] = concurrent_test('gl-3.2-layered-rendering-clear-depth')
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/readpixels'] = concurrent_test('gl-3.2-layered-rendering-readpixels')
+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.3/minmax'] = concurrent_test('gl-3.3-minmax')
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 494cc99..c864be1 100644
--- a/tests/spec/gl-3.2/layered-rendering/CMakeLists.gl.txt
+++ b/tests/spec/gl-3.2/layered-rendering/CMakeLists.gl.txt
@@ -13,6 +13,7 @@ piglit_add_executable (gl-3.2-layered-rendering-blit blit.c)
piglit_add_executable (gl-3.2-layered-rendering-clear-color clear-color.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-complete framebuffer-layer-complete.c)
piglit_add_executable (gl-3.2-layered-rendering-framebuffertexture-buffer-textures framebuffertexture-buffer-textures.c)
piglit_add_executable (gl-3.2-layered-rendering-readpixels readpixels.c)
# vim: ft=cmake:
diff --git a/tests/spec/gl-3.2/layered-rendering/framebuffer-layer-complete.c b/tests/spec/gl-3.2/layered-rendering/framebuffer-layer-complete.c
new file mode 100644
index 0000000..3825d88
--- /dev/null
+++ b/tests/spec/gl-3.2/layered-rendering/framebuffer-layer-complete.c
@@ -0,0 +1,197 @@
+/*
+ * 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 framebuffer-layer-complete.c
+ *
+ * Section 4.4.4(FRAMEBUFFER OBJECTS) From GL spec 3.2 core:
+ * 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.
+ */
+
+#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
+
+const int texWidth = 30;
+const int texHeight = 30;
+const int texDepth = 2;
+
+GLuint
+create_bind_texture(GLenum textureType) {
+ GLuint texture;
+ glGenTextures(1, &texture);
+ glBindTexture(textureType, texture);
+
+ switch(textureType) {
+ case GL_TEXTURE_2D:
+ 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:
+ 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;
+ default:
+ printf("Unexpected textureType in create_bind_texture()\n");
+ piglit_report_result(PIGLIT_FAIL);
+ break;
+ }
+
+ return texture;
+}
+
+void
+attach_texture(GLenum framebuffer, GLenum attachment, GLenum textureType,
+ GLuint texture)
+{
+ switch(textureType) {
+ case GL_TEXTURE_2D:
+ glFramebufferTexture2D(framebuffer, attachment,
+ textureType, texture, 0);
+ break;
+ case GL_TEXTURE_3D:
+ glFramebufferTexture(framebuffer, attachment,
+ texture, 0);
+ break;
+ }
+}
+
+bool
+CheckFramebufferStatus(GLenum expected) {
+ GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
+ if(status != expected) {
+ printf("Expected Framebuffer status '%s', got '%s'\n",
+ piglit_get_gl_enum_name(expected),
+ piglit_get_gl_enum_name(status));
+ return false;
+ }
+ return true;
+}
+
+bool
+test_fbo_attachments_layered()
+{
+ bool pass = true;
+ GLuint fbo, texture[2];
+
+ glGenFramebuffers(1, &fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+
+ /* Attach first texture as a layered texture */
+ texture[0] = create_bind_texture(GL_TEXTURE_3D);
+ glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ texture[0], 0);
+
+ /* Attach a single layer of the second texture.(Non layered) */
+ texture[1] = create_bind_texture(GL_TEXTURE_3D);
+ glFramebufferTexture3D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1,
+ GL_TEXTURE_3D, texture[1], 0, 0);
+
+ if(!piglit_check_gl_error(GL_NO_ERROR))
+ piglit_report_result(PIGLIT_FAIL);
+
+ pass = CheckFramebufferStatus(GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS)
+ && pass;
+
+ glDeleteFramebuffers(1, &fbo);
+ glDeleteTextures(2, texture);
+
+ return pass;
+}
+
+bool
+test_fbo_attachment_targets(GLenum texOneType, GLenum texTwoType,
+ GLenum expectedFbStatus)
+{
+ bool pass = true;
+ GLuint fbo, texture[2];
+
+ glGenTextures(2, texture);
+
+ glGenFramebuffers(1, &fbo);
+ glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+
+ /* Setup texture one */
+ texture[0] = create_bind_texture(texOneType);
+ attach_texture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ texOneType, texture[0]);
+
+ /* Setup texture two */
+ texture[1] = create_bind_texture(texTwoType);
+ attach_texture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1,
+ texTwoType, texture[1]);
+
+ if(!piglit_check_gl_error(GL_NO_ERROR))
+ piglit_report_result(PIGLIT_FAIL);
+
+ /* Check for expected fb status */
+ pass = CheckFramebufferStatus(expectedFbStatus) && pass;
+
+ /* Clean up */
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ glDeleteFramebuffers(1, &fbo);
+ glDeleteTextures(2, texture);
+
+ return pass;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ bool pass = true;
+
+ pass = test_fbo_attachment_targets(GL_TEXTURE_2D, GL_TEXTURE_2D,
+ GL_FRAMEBUFFER_COMPLETE)
+ && pass;
+
+ pass = test_fbo_attachment_targets(GL_TEXTURE_2D, GL_TEXTURE_3D,
+ GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS)
+ && pass;
+
+ pass = test_fbo_attachments_layered() && 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