[Piglit] [PATCH 08/14] arb_direct_state_access: Add a test for glVertexArrayElementBuffer

Laura Ekstrand laura at jlekstrand.net
Wed Apr 1 16:50:55 PDT 2015


LGTM.

Reviewed-by: Laura Ekstrand <laura at jlekstrand.net>

On Tue, Mar 31, 2015 at 10:26 AM, Fredrik Höglund <fredrik at kde.org> wrote:

> This test verifies that glVertexArrayElementBuffer works as expected.
> ---
>  tests/all.py                                       |   1 +
>  .../spec/arb_direct_state_access/CMakeLists.gl.txt |   1 +
>  .../vao-element-array-buffer.c                     | 123
> +++++++++++++++++++++
>  3 files changed, 125 insertions(+)
>  create mode 100644
> tests/spec/arb_direct_state_access/vao-element-array-buffer.c
>
> diff --git a/tests/all.py b/tests/all.py
> index 442f5b6..6b44069 100755
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -4285,6 +4285,7 @@ with profile.group_manager(
>      g(['arb_direct_state_access-vao-attrib-format'], 'vao-attrib-format')
>      g(['arb_direct_state_access-vao-attrib-binding'],
> 'vao-attrib-binding')
>      g(['arb_direct_state_access-vao-binding-divisor'],
> 'vao-binding-divisor')
> +    g(['arb_direct_state_access-vao-element-array-buffer'],
> 'vao-element-array-buffer')
>
>  with profile.group_manager(
>          PiglitGLTest,
> diff --git a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
> b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
> index e45da46..fe17530 100644
> --- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
> +++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
> @@ -41,4 +41,5 @@ piglit_add_executable
> (arb_direct_state_access-vao-attrib-enabledisable vao-attr
>  piglit_add_executable (arb_direct_state_access-vao-attrib-format
> vao-attrib-format.c dsa-utils.c)
>  piglit_add_executable (arb_direct_state_access-vao-attrib-binding
> vao-attrib-binding.c dsa-utils.c)
>  piglit_add_executable (arb_direct_state_access-vao-binding-divisor
> vao-binding-divisor.c dsa-utils.c)
> +piglit_add_executable (arb_direct_state_access-vao-element-array-buffer
> vao-element-array-buffer.c)
>  # vim: ft=cmake:
> diff --git a/tests/spec/arb_direct_state_access/vao-element-array-buffer.c
> b/tests/spec/arb_direct_state_access/vao-element-array-buffer.c
> new file mode 100644
> index 0000000..8e0a9e1
> --- /dev/null
> +++ b/tests/spec/arb_direct_state_access/vao-element-array-buffer.c
> @@ -0,0 +1,123 @@
> +/*
> + * Copyright (C) 2015 Fredrik Höglund
> + *
> + * 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
> + * on the rights to use, copy, modify, merge, publish, distribute, sub
> + * license, 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 NON-INFRINGEMENT.  IN NO EVENT
> SHALL
> + * THE AUTHORS AND/OR THEIR SUPPLIERS 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 vao-element-array-buffer.c
> + *
> + * Verifies that glVertexArrayElementBuffer works as expected.
> + */
> +
> +#include "piglit-util-gl.h"
> +
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +       config.supports_gl_core_version = 31;
> +       config.supports_gl_compat_version = 20;
> +
> +       config.window_visual = PIGLIT_GL_VISUAL_RGB |
> PIGLIT_GL_VISUAL_DOUBLE;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +       /* unreached */
> +       return PIGLIT_FAIL;
> +}
> +
> +
> +static bool
> +check_ibo_binding_(GLuint vao, GLuint expected, int line)
> +{
> +       GLuint value;
> +       glGetVertexArrayiv(vao, GL_ELEMENT_ARRAY_BUFFER_BINDING,
> +                          (GLint *) &value);
> +
> +       if (value != expected) {
> +               fprintf(stderr, "GL_ELEMENT_ARRAY_BUFFER_BINDING was %u, "
> +                               "expected %u (%s:%d)\n",
> +                       value, expected, __FILE__, line);
> +               return false;
> +       }
> +
> +       return true;
> +}
> +
> +
> +#define check_ibo_binding(vao, expected) \
> +       check_ibo_binding_(vao, expected, __LINE__)
> +
> +
> +void
> +piglit_init(int argc, char *argv[])
> +{
> +       GLuint vao, ibo;
> +       bool pass = true;
> +
> +       piglit_require_extension("GL_ARB_direct_state_access");
> +       piglit_require_extension("GL_ARB_vertex_array_object");
> +
> +       /* Create a buffer object */
> +       glCreateBuffers(1, &ibo);
> +
> +       /* Create a VAO and verify that no element array buffer is
> +        * bound by default
> +        */
> +       glCreateVertexArrays(1, &vao);
> +       pass = check_ibo_binding(vao, 0) && pass;
> +
> +       /* Bind the buffer object as an element array buffer and verify
> +        * that it was successfully bound
> +        */
> +       glVertexArrayElementBuffer(vao, ibo);
> +       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +       pass = check_ibo_binding(vao, ibo) && pass;
> +
> +       /* Unbind the buffer object from the VAO and verify that it was
> +        * successfully unbound
> +        */
> +       glVertexArrayElementBuffer(vao, 0);
> +       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +       pass = check_ibo_binding(vao, 0) && pass;
> +
> +       glDeleteVertexArrays(1, &vao);
> +
> +       /* The ARB_direct_state_access spec says:
> +        *
> +        *    "An INVALID_OPERATION error is generated by
> +        *     VertexArrayElementBuffer if <vaobj> is not
> +        *     [compatibility profile: zero or] the name of an existing
> +        *     vertex array object."
> +        */
> +       glGenVertexArrays(1, &vao);
> +       glVertexArrayElementBuffer(vao, ibo);
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +       glDeleteVertexArrays(1, &vao);
> +
> +       glDeleteBuffers(1, &ibo);
> +
> +       piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
> +}
> +
> --
> 2.1.4
>
> _______________________________________________
> 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/20150401/c4a3c5bb/attachment-0001.html>


More information about the Piglit mailing list