[Piglit] [PATCH 1/3] GL 3.2: Test framebuffer with layered attachments

Jordan Justen jljusten at gmail.com
Thu Oct 3 15:46:03 PDT 2013


Series Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>
and pushed to master.

On Mon, Sep 16, 2013 at 10:31 AM, Jacob Penner <jkpenner91 at gmail.com> wrote:
> ---
>  tests/all.tests                                    |   1 +
>  .../gl-3.2/layered-rendering/CMakeLists.gl.txt     |   1 +
>  .../framebuffer-layered-attachments.c              | 166 +++++++++++++++++++++
>  3 files changed, 168 insertions(+)
>  create mode 100644 tests/spec/gl-3.2/layered-rendering/framebuffer-layered-attachments.c
>
> diff --git a/tests/all.tests b/tests/all.tests
> index 7057134..8c657c5 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-layered-attachments'] = concurrent_test('gl-3.2-layered-rendering-framebuffer-layered-attachments')
>
>  spec['!OpenGL 3.3/minmax'] = concurrent_test('gl-3.3-minmax')
>  spec['!OpenGL 3.3/required-renderbuffer-attachment-formats'] = concurrent_test('gl-3.0-required-renderbuffer-attachment-formats 33')
> 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 068f0a9..494cc99 100644
> --- a/tests/spec/gl-3.2/layered-rendering/CMakeLists.gl.txt
> +++ b/tests/spec/gl-3.2/layered-rendering/CMakeLists.gl.txt
> @@ -12,6 +12,7 @@ link_libraries (
>  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-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-layered-attachments.c b/tests/spec/gl-3.2/layered-rendering/framebuffer-layered-attachments.c
> new file mode 100644
> index 0000000..d6e5b46
> --- /dev/null
> +++ b/tests/spec/gl-3.2/layered-rendering/framebuffer-layered-attachments.c
> @@ -0,0 +1,166 @@
> +/*
> + * 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-layered-attachments.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.
> + *
> + *
> + * 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 = 32;
> +       config.supports_gl_core_version   = 32;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +GLenum textureType[] = {
> +       GL_TEXTURE_3D,
> +       GL_TEXTURE_CUBE_MAP,
> +       GL_TEXTURE_1D_ARRAY,
> +       GL_TEXTURE_2D_ARRAY,
> +       GL_TEXTURE_2D_MULTISAMPLE_ARRAY
> +};
> +
> +GLuint
> +create_bind_texture(GLenum textureType) {
> +       int i;
> +       GLuint texture;
> +       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, 10, 10,
> +                            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, 10, 10, 6, 0, GL_RGB,
> +                            GL_FLOAT, NULL);
> +               break;
> +       case GL_TEXTURE_CUBE_MAP:
> +               for(i = 0; i < 6; i++) {
> +                       glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0,
> +                                    GL_RGB, 10, 10, 0, GL_RGB, GL_FLOAT, NULL);
> +               }
> +               break;
> +       case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
> +               glTexImage3DMultisample(GL_TEXTURE_2D_MULTISAMPLE_ARRAY, 4,
> +                                       GL_RGB, 10, 10, 2, GL_FALSE);
> +               break;
> +       }
> +
> +       return texture;
> +}
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +       int i;
> +       bool pass = true;
> +       GLenum fbStatus;
> +       GLuint fbo, texture;
> +       GLint attachmentLayeredStatus;
> +
> +       for(i = 0; i < ARRAY_SIZE(textureType); i++) {
> +               glGenFramebuffers(1, &fbo);
> +               glBindFramebuffer(GL_FRAMEBUFFER, fbo);
> +
> +               texture = create_bind_texture(textureType[i]);
> +               glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
> +                                    texture, 0);
> +
> +               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[i]));
> +                       glDeleteFramebuffers(1, &fbo);
> +                       glDeleteTextures(1, &texture);
> +                       piglit_report_result(PIGLIT_FAIL);
> +               }
> +
> +               fbStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
> +               if(fbStatus != GL_FRAMEBUFFER_COMPLETE) {
> +                       printf("Framebuffer Status: %s\n",
> +                               piglit_get_gl_enum_name(fbStatus));
> +                       glDeleteFramebuffers(1, &fbo);
> +                       glDeleteTextures(1, &texture);
> +                       piglit_report_result(PIGLIT_FAIL);
> +               }
> +
> +               /* Check if the attachment is layered */
> +               glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER,
> +                                                     GL_COLOR_ATTACHMENT0,
> +                                                     GL_FRAMEBUFFER_ATTACHMENT_LAYERED,
> +                                                     &attachmentLayeredStatus);
> +
> +               pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +
> +               if(attachmentLayeredStatus != GL_TRUE) {
> +                       pass = false;
> +               }
> +
> +               glDeleteFramebuffers(1, &fbo);
> +               glDeleteTextures(1, &texture);
> +       }
> +
> +       piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
> +}
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +       /* UNREACHABLE */
> +       return PIGLIT_FAIL;
> +}
> --
> 1.8.3.1
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list