[Piglit] [PATCH 5/9] GL 3.2: Test layered framebuffer status

Paul Berry stereotype441 at gmail.com
Tue Aug 27 11:30:47 PDT 2013


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

> ---
>  .../layered-rendering/framebuffer-layer-complete.c | 168
> +++++++++++++++++++++
>  1 file changed, 168 insertions(+)
>  create mode 100644
> tests/spec/gl-3.2/layered-rendering/framebuffer-layer-complete.c
>
> 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..fa36f42
> --- /dev/null
> +++ b/tests/spec/gl-3.2/layered-rendering/framebuffer-layer-complete.c
> @@ -0,0 +1,168 @@
> +/*
> + * 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.
>

It looks like this test only verifies the sentence starting
"Additionally...".  We really need to verify the other case too, by trying
to create a framebuffer in which one attachment is layered and another
attachment isn't.


> + */
> +
> +#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;
> +
> +void
> +create_bind_texture(GLenum textureType, GLuint *texture) {
>

As in patch 3, the texture should be returned in a return value rather than
using a pointer.


> +       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:
> +               glDeleteTextures(1, texture);
> +               *texture = 0;
> +               break;
>

It looks like we never expect the default case of this switch statement to
be taken (i.e. it would only happen if there were a bug elsewhere in the
test).  Usually when that's the case it's better to do something like this:

default:
   printf("Unexpected textureType in create_bind_texture()\n");
   piglit_report_result(PIGLIT_FAIL);
   break;

That way, if anyone ever modifies the test in a way that causes the default
case to be taken, they'll find out their mistake by getting an obvious
piglit failure.


> +       }
> +}
> +
> +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_fb_incomplete_layer_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 */
> +       create_bind_texture(texOneType, &texture[0]);
> +       attach_texture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
> +                      texOneType, texture[0]);
> +
> +       /* Setup texture two */
> +       create_bind_texture(texTwoType, &texture[1]);
> +       attach_texture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1,
> +                      texTwoType, texture[1]);
> +
> +       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +
> +       /* 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_fb_incomplete_layer_targets(GL_TEXTURE_2D,
> GL_TEXTURE_2D,
> +                       GL_FRAMEBUFFER_COMPLETE)
> +                       && pass;
> +
> +       pass = test_fb_incomplete_layer_targets(GL_TEXTURE_3D,
> GL_TEXTURE_2D,
> +                       GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS)
> +                       && pass;
> +
> +       pass = test_fb_incomplete_layer_targets(GL_TEXTURE_2D,
>  GL_TEXTURE_3D,
> +                       GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS)
> +                       && pass;
> +
> +       pass = test_fb_incomplete_layer_targets(GL_TEXTURE_3D,
>  GL_TEXTURE_3D,
> +                       GL_FRAMEBUFFER_COMPLETE)
> +                       && pass;
>

I don't think we need all four of the above test cases.  It should be
sufficient to do one 2D/2D test and one 3D/2D test.

(Then, as I mentioned above, we should add a third test case to verify that
mixing layered and unlayered attachments causes the framebuffer to be
incomplete).


> +
> +       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/e803fc88/attachment-0001.html>


More information about the Piglit mailing list