[03/14] arb_direct_state_access: Add a test for glCreateVertexArrays

Submitted by Fredrik Höglund on March 31, 2015, 5:26 p.m.

Details

Message ID 1427822806-18528-4-git-send-email-fredrik@kde.org
State New
Headers show

Not browsing as part of any series.

Commit Message

Fredrik Höglund March 31, 2015, 5:26 p.m.
This test verifies that glCreateVertexArrays works as expected.
---
 tests/all.py                                       |   1 +
 .../spec/arb_direct_state_access/CMakeLists.gl.txt |   1 +
 tests/spec/arb_direct_state_access/vao-create.c    | 143 +++++++++++++++++++++
 3 files changed, 145 insertions(+)
 create mode 100644 tests/spec/arb_direct_state_access/vao-create.c

Patch hide | download patch | download mbox

diff --git a/tests/all.py b/tests/all.py
index d0815da..441ea77 100755
--- a/tests/all.py
+++ b/tests/all.py
@@ -4280,6 +4280,7 @@  with profile.group_manager(
     g(['arb_direct_state_access-create-programpipelines'],
       'create-programpipelines')
     g(['arb_direct_state_access-create-queries'], 'create-queries')
+    g(['arb_direct_state_access-vao-create'], 'vao-create')
 
 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 a5ae423..9fcbf7e 100644
--- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
+++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
@@ -36,4 +36,5 @@  piglit_add_executable (arb_direct_state_access-texture-buffer texture-buffer.c)
 piglit_add_executable (arb_direct_state_access-create-samplers create-samplers.c)
 piglit_add_executable (arb_direct_state_access-create-programpipelines create-programpipelines.c)
 piglit_add_executable (arb_direct_state_access-create-queries create-queries.c)
+piglit_add_executable (arb_direct_state_access-vao-create vao-create.c)
 # vim: ft=cmake:
diff --git a/tests/spec/arb_direct_state_access/vao-create.c b/tests/spec/arb_direct_state_access/vao-create.c
new file mode 100644
index 0000000..1a124e7
--- /dev/null
+++ b/tests/spec/arb_direct_state_access/vao-create.c
@@ -0,0 +1,143 @@ 
+/*
+ * 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-create.c
+ *
+ * Verifies that glCreateVertexArrays works as expected.
+ */
+
+#include "piglit-util-gl.h"
+
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_core_version = 32;
+	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;
+}
+
+
+/**
+ * Returns true if expected is bound as the current VAO,
+ * and false otherwise.
+ */
+static bool
+check_vao_binding_(GLuint expected, int line)
+{
+	GLuint binding;
+	glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint *) &binding);
+
+	if (binding != expected) {
+		fprintf(stderr, "GL_VERTEX_ARRAY_BINDING "
+		        "was %u, expected %u (%s:%d)\n",
+		        binding, expected, __FILE__, line);
+		return false;
+	}
+
+	return true;
+}
+
+
+#define check_vao_binding(expected) \
+	check_vao_binding_(expected, __LINE__)
+
+
+void
+piglit_init(int argc, char *argv[])
+{
+	GLuint vaos[4];
+	bool pass = true;
+	int i;
+
+	piglit_require_extension("GL_ARB_direct_state_access");
+	piglit_require_extension("GL_ARB_vertex_array_object");
+
+	/* Page 332 of the PDF of the OpenGL 4.5 (Core Profile) spec says:
+	 *
+	 * "CreateVertexArrays returns n previously unused vertex array object
+	 *  names in arrays, each representing a state vector comprising all
+	 *  the state and with the same initial values listed in tables 23.3
+	 *  and 23.4."
+	 */
+	glCreateVertexArrays(4, vaos);
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+
+	/* Verify that the arrays were created */
+	for (i = 0; i < 4; i++)
+		pass = glIsVertexArray(vaos[i]) && pass;
+
+	/* Bind the first vao and verify that it was bound */
+	glBindVertexArray(vaos[0]);
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+	pass = check_vao_binding(vaos[0]) && pass;
+
+	/* Page 331 of the PDF of the OpenGL 4.5 (Core Profile) spec says:
+	 *
+	 * "If a vertex array object that is currently bound is deleted,
+	 *  the binding for that object reverts to zero and no vertex array
+	 *  object is bound."
+	 */
+	glDeleteVertexArrays(4, vaos);
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+	pass = check_vao_binding(0) && pass;
+
+	/* Verify that the arrays are no longer valid */
+	for (i = 0; i < 4; i++)
+		pass = !glIsVertexArray(vaos[i]) && pass;
+
+	/* Page 331 of the PDF of the OpenGL 4.5 (Core Profile) spec says:
+	 *
+	 * "Unused names in arrays are silently ignored, as is the value zero."
+	 */
+	vaos[0] = 0;
+	glDeleteVertexArrays(4, vaos);
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+
+	/* Page 332 of the PDF of the OpenGL 4.5 (Core Profile) spec says:
+	 *
+	 * "An INVALID_VALUE error is generated if n is negative."
+	 */
+	glCreateVertexArrays(-1, vaos);
+	pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;
+
+	/* Page 331 of the PDF of the OpenGL 4.5 (Core Profile) spec says:
+	 *
+	 * "An INVALID_VALUE error is generated if n is negative."
+	 */
+	glDeleteVertexArrays(-1, vaos);
+	pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;
+
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
+

Comments

LGTM.

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

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

> This test verifies that glCreateVertexArrays works as expected.
> ---
>  tests/all.py                                       |   1 +
>  .../spec/arb_direct_state_access/CMakeLists.gl.txt |   1 +
>  tests/spec/arb_direct_state_access/vao-create.c    | 143
> +++++++++++++++++++++
>  3 files changed, 145 insertions(+)
>  create mode 100644 tests/spec/arb_direct_state_access/vao-create.c
>
> diff --git a/tests/all.py b/tests/all.py
> index d0815da..441ea77 100755
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -4280,6 +4280,7 @@ with profile.group_manager(
>      g(['arb_direct_state_access-create-programpipelines'],
>        'create-programpipelines')
>      g(['arb_direct_state_access-create-queries'], 'create-queries')
> +    g(['arb_direct_state_access-vao-create'], 'vao-create')
>
>  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 a5ae423..9fcbf7e 100644
> --- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
> +++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
> @@ -36,4 +36,5 @@ piglit_add_executable
> (arb_direct_state_access-texture-buffer texture-buffer.c)
>  piglit_add_executable (arb_direct_state_access-create-samplers
> create-samplers.c)
>  piglit_add_executable (arb_direct_state_access-create-programpipelines
> create-programpipelines.c)
>  piglit_add_executable (arb_direct_state_access-create-queries
> create-queries.c)
> +piglit_add_executable (arb_direct_state_access-vao-create vao-create.c)
>  # vim: ft=cmake:
> diff --git a/tests/spec/arb_direct_state_access/vao-create.c
> b/tests/spec/arb_direct_state_access/vao-create.c
> new file mode 100644
> index 0000000..1a124e7
> --- /dev/null
> +++ b/tests/spec/arb_direct_state_access/vao-create.c
> @@ -0,0 +1,143 @@
> +/*
> + * 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-create.c
> + *
> + * Verifies that glCreateVertexArrays works as expected.
> + */
> +
> +#include "piglit-util-gl.h"
> +
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +       config.supports_gl_core_version = 32;
> +       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;
> +}
> +
> +
> +/**
> + * Returns true if expected is bound as the current VAO,
> + * and false otherwise.
> + */
> +static bool
> +check_vao_binding_(GLuint expected, int line)
> +{
> +       GLuint binding;
> +       glGetIntegerv(GL_VERTEX_ARRAY_BINDING, (GLint *) &binding);
> +
> +       if (binding != expected) {
> +               fprintf(stderr, "GL_VERTEX_ARRAY_BINDING "
> +                       "was %u, expected %u (%s:%d)\n",
> +                       binding, expected, __FILE__, line);
> +               return false;
> +       }
> +
> +       return true;
> +}
> +
> +
> +#define check_vao_binding(expected) \
> +       check_vao_binding_(expected, __LINE__)
> +
> +
> +void
> +piglit_init(int argc, char *argv[])
> +{
> +       GLuint vaos[4];
> +       bool pass = true;
> +       int i;
> +
> +       piglit_require_extension("GL_ARB_direct_state_access");
> +       piglit_require_extension("GL_ARB_vertex_array_object");
> +
> +       /* Page 332 of the PDF of the OpenGL 4.5 (Core Profile) spec says:
> +        *
> +        * "CreateVertexArrays returns n previously unused vertex array
> object
> +        *  names in arrays, each representing a state vector comprising
> all
> +        *  the state and with the same initial values listed in tables
> 23.3
> +        *  and 23.4."
> +        */
> +       glCreateVertexArrays(4, vaos);
> +       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +
> +       /* Verify that the arrays were created */
> +       for (i = 0; i < 4; i++)
> +               pass = glIsVertexArray(vaos[i]) && pass;
> +
> +       /* Bind the first vao and verify that it was bound */
> +       glBindVertexArray(vaos[0]);
> +       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +       pass = check_vao_binding(vaos[0]) && pass;
> +
> +       /* Page 331 of the PDF of the OpenGL 4.5 (Core Profile) spec says:
> +        *
> +        * "If a vertex array object that is currently bound is deleted,
> +        *  the binding for that object reverts to zero and no vertex array
> +        *  object is bound."
> +        */
> +       glDeleteVertexArrays(4, vaos);
> +       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +       pass = check_vao_binding(0) && pass;
> +
> +       /* Verify that the arrays are no longer valid */
> +       for (i = 0; i < 4; i++)
> +               pass = !glIsVertexArray(vaos[i]) && pass;
> +
> +       /* Page 331 of the PDF of the OpenGL 4.5 (Core Profile) spec says:
> +        *
> +        * "Unused names in arrays are silently ignored, as is the value
> zero."
> +        */
> +       vaos[0] = 0;
> +       glDeleteVertexArrays(4, vaos);
> +       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +
> +       /* Page 332 of the PDF of the OpenGL 4.5 (Core Profile) spec says:
> +        *
> +        * "An INVALID_VALUE error is generated if n is negative."
> +        */
> +       glCreateVertexArrays(-1, vaos);
> +       pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;
> +
> +       /* Page 331 of the PDF of the OpenGL 4.5 (Core Profile) spec says:
> +        *
> +        * "An INVALID_VALUE error is generated if n is negative."
> +        */
> +       glDeleteVertexArrays(-1, vaos);
> +       pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass;
> +
> +       piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
> +}
> +
> --
> 2.1.4
>
> _______________________________________________
> Piglit mailing list
> Piglit@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
>