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

Paul Berry stereotype441 at gmail.com
Tue Aug 27 13:55:49 PDT 2013


On 26 August 2013 11:53, Jacob Penner <jkpenner91 at gmail.com> wrote:

> 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
>

Same comment as before about the commit message.


> ---
>  .../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.
> + */
>

Is this test redundant with the test from patch 6?  It seems like both
tests operate by creating a framebuffer and then checking that
TEST_FRAMEBUFFER_ATTACHMENT_LAYERED returns the correct result.

There seems to be a fair amount of duplicate code between the patches in
this series, so it seems like it might be nice to merge these two tests
into one if it's possible to do so without losing anything of value.


> +
> +#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
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20130827/a5f8550b/attachment-0001.html>


More information about the Piglit mailing list