[12/14] arb_direct_state_access: Add a core-profile test

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

Details

Message ID 1427822806-18528-13-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 tests behavior specific to the core profile.
---
 tests/all.py                                       |   1 +
 .../spec/arb_direct_state_access/CMakeLists.gl.txt |   1 +
 tests/spec/arb_direct_state_access/vao-core.c      | 186 +++++++++++++++++++++
 3 files changed, 188 insertions(+)
 create mode 100644 tests/spec/arb_direct_state_access/vao-core.c

Patch hide | download patch | download mbox

diff --git a/tests/all.py b/tests/all.py
index 3affcf9..e85763e 100755
--- a/tests/all.py
+++ b/tests/all.py
@@ -4289,6 +4289,7 @@  with profile.group_manager(
     g(['arb_direct_state_access-vao-vertex-buffer'], 'vao-vertex-buffer')
     g(['arb_direct_state_access-vao-vertex-buffers'], 'vao-vertex-buffers')
     g(['arb_direct_state_access-vao-get'], 'vao-get')
+    g(['arb_direct_state_access-vao-core'], 'vao-core')
 
 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 c855797..bc610b6 100644
--- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
+++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
@@ -45,4 +45,5 @@  piglit_add_executable (arb_direct_state_access-vao-element-array-buffer vao-elem
 piglit_add_executable (arb_direct_state_access-vao-vertex-buffer vao-vertex-buffer.c dsa-utils.c)
 piglit_add_executable (arb_direct_state_access-vao-vertex-buffers vao-vertex-buffers.c dsa-utils.c)
 piglit_add_executable (arb_direct_state_access-vao-get vao-get.c)
+piglit_add_executable (arb_direct_state_access-vao-core vao-core.c dsa-utils.c)
 # vim: ft=cmake:
diff --git a/tests/spec/arb_direct_state_access/vao-core.c b/tests/spec/arb_direct_state_access/vao-core.c
new file mode 100644
index 0000000..9bb2ad7
--- /dev/null
+++ b/tests/spec/arb_direct_state_access/vao-core.c
@@ -0,0 +1,186 @@ 
+/*
+ * 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-core.c
+ *
+ * Tests behavior specific to the core profile.
+ */
+
+#include "piglit-util-gl.h"
+#include "dsa-utils.h"
+
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_core_version = 31;
+
+	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;
+}
+
+
+/**
+ * Calls all DSA functions on the given vao, with valid parameters,
+ * and checks that expected_error is generated.
+ */
+static bool
+test_all_functions(GLuint vao, GLenum expected_error)
+{
+	GLint value;
+	GLint64 value64;
+	bool pass = true;
+
+	glDisableVertexArrayAttrib(vao, 0);
+	pass = piglit_check_gl_error(expected_error) && pass;
+
+	glEnableVertexArrayAttrib(vao, 0);
+	pass = piglit_check_gl_error(expected_error) && pass;
+
+	glVertexArrayElementBuffer(vao, 0);
+	pass = piglit_check_gl_error(expected_error) && pass;
+
+	glVertexArrayVertexBuffer(vao, 0, 0, 0, 0);
+	pass = piglit_check_gl_error(expected_error) && pass;
+
+	glVertexArrayVertexBuffers(vao, 0, 1, NULL, NULL, NULL);
+	pass = piglit_check_gl_error(expected_error) && pass;
+
+	glVertexArrayAttribFormat(vao, 0, 4, GL_FLOAT, GL_FALSE, 0);
+	pass = piglit_check_gl_error(expected_error) && pass;
+
+	glVertexArrayAttribIFormat(vao, 0, 4, GL_INT, 0);
+	pass = piglit_check_gl_error(expected_error) && pass;
+
+	if (piglit_is_extension_supported("GL_ARB_vertex_attrib_64bit")) {
+		glVertexArrayAttribLFormat(vao, 0, 4, GL_DOUBLE, 0);
+		pass = piglit_check_gl_error(expected_error) && pass;
+	}
+
+	glVertexArrayAttribBinding(vao, 0, 4);
+	pass = piglit_check_gl_error(expected_error) && pass;
+
+	if (piglit_is_extension_supported("GL_ARB_instanced_arrays")) {
+		glVertexArrayBindingDivisor(vao, 0, 1);
+		pass = piglit_check_gl_error(expected_error) && pass;
+	}
+
+	glGetVertexArrayiv(vao, GL_ELEMENT_ARRAY_BUFFER_BINDING, &value);
+	pass = piglit_check_gl_error(expected_error) && pass;
+
+	glGetVertexArrayIndexediv(vao, 0, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &value);
+	pass = piglit_check_gl_error(expected_error) && pass;
+
+	glGetVertexArrayIndexed64iv(vao, 0, GL_VERTEX_BINDING_OFFSET, &value64);
+	pass = piglit_check_gl_error(expected_error) && pass;
+
+	return pass;
+}
+
+
+void
+piglit_init(int argc, char *argv[])
+{
+	GLuint vao;
+	GLuint buffer;
+	bool pass = true;
+
+	piglit_require_extension("GL_ARB_direct_state_access");
+	piglit_require_extension("GL_ARB_vertex_attrib_binding");
+
+	/* vaobj must not be zero in the core profile */
+	pass = test_all_functions(0, GL_INVALID_OPERATION) && pass;
+
+	/* vaobj must not be a non-generated name */
+	pass = test_all_functions(1, GL_INVALID_OPERATION) && pass;
+
+	/* vaobj must be an existing vertex array object */
+	glGenVertexArrays(1, &vao);
+	pass = test_all_functions(vao, GL_INVALID_OPERATION) && pass;
+
+	/* Create the VAO */
+	glBindVertexArray(vao);
+
+	/* Non-generated buffer names are not supported */
+	buffer = 1;
+	glVertexArrayElementBuffer(vao, buffer);
+	pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
+
+	buffer = 2;
+	glVertexArrayVertexBuffer(vao, 0, buffer, 0, 0);
+	pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
+
+	buffer = 3;
+	{
+		const GLuint     buffers[] = { buffer };
+		const GLintptr   offsets[] = { 0 };
+		const GLsizeiptr strides[] = { 0 };
+
+		glVertexArrayVertexBuffers(vao, 0, 1,
+		                           buffers, offsets, strides);
+		pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
+	}
+
+	/* VertexArrayElementBuffer and VertexArrayVertexBuffers do not
+	 * create buffer objects...
+	 */
+	glGenBuffers(1, &buffer);
+	glVertexArrayElementBuffer(vao, buffer);
+	pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
+	pass = !glIsBuffer(buffer) && pass;
+	glDeleteBuffers(1, &buffer);
+
+	glGenBuffers(1, &buffer);
+	{
+		const GLuint     buffers[] = { buffer };
+		const GLintptr   offsets[] = { 0 };
+		const GLsizeiptr strides[] = { 0 };
+
+		glVertexArrayVertexBuffers(vao, 0, 1,
+		                           buffers, offsets, strides);
+		pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
+		pass = !glIsBuffer(buffer) && pass;
+	}
+	glDeleteBuffers(1, &buffer);
+
+	/* ...but VertexArrayVertexBuffer does */
+	glGenBuffers(1, &buffer);
+	glVertexArrayVertexBuffer(vao, 0, buffer, 16, 32);
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+	pass = check_vbo_binding(vao, 0, buffer, 16, 32) && pass;
+	pass = glIsBuffer(buffer) && pass;
+	glDeleteBuffers(1, &buffer);
+
+	glDeleteVertexArrays(1, &vao);
+
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
+

Comments

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

> This tests behavior specific to the core profile.
> ---
>  tests/all.py                                       |   1 +
>  .../spec/arb_direct_state_access/CMakeLists.gl.txt |   1 +
>  tests/spec/arb_direct_state_access/vao-core.c      | 186
> +++++++++++++++++++++
>  3 files changed, 188 insertions(+)
>  create mode 100644 tests/spec/arb_direct_state_access/vao-core.c
>
> diff --git a/tests/all.py b/tests/all.py
> index 3affcf9..e85763e 100755
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -4289,6 +4289,7 @@ with profile.group_manager(
>      g(['arb_direct_state_access-vao-vertex-buffer'], 'vao-vertex-buffer')
>      g(['arb_direct_state_access-vao-vertex-buffers'],
> 'vao-vertex-buffers')
>      g(['arb_direct_state_access-vao-get'], 'vao-get')
> +    g(['arb_direct_state_access-vao-core'], 'vao-core')
>
>  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 c855797..bc610b6 100644
> --- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
> +++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
> @@ -45,4 +45,5 @@ piglit_add_executable
> (arb_direct_state_access-vao-element-array-buffer vao-elem
>  piglit_add_executable (arb_direct_state_access-vao-vertex-buffer
> vao-vertex-buffer.c dsa-utils.c)
>  piglit_add_executable (arb_direct_state_access-vao-vertex-buffers
> vao-vertex-buffers.c dsa-utils.c)
>  piglit_add_executable (arb_direct_state_access-vao-get vao-get.c)
> +piglit_add_executable (arb_direct_state_access-vao-core vao-core.c
> dsa-utils.c)
>  # vim: ft=cmake:
> diff --git a/tests/spec/arb_direct_state_access/vao-core.c
> b/tests/spec/arb_direct_state_access/vao-core.c
> new file mode 100644
> index 0000000..9bb2ad7
> --- /dev/null
> +++ b/tests/spec/arb_direct_state_access/vao-core.c
> @@ -0,0 +1,186 @@
> +/*
> + * 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-core.c
> + *
> + * Tests behavior specific to the core profile.
> + */
> +
> +#include "piglit-util-gl.h"
> +#include "dsa-utils.h"
> +
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +       config.supports_gl_core_version = 31;
> +
> +       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;
> +}
> +
> +
> +/**
> + * Calls all DSA functions on the given vao, with valid parameters,
> + * and checks that expected_error is generated.
> + */
> +static bool
> +test_all_functions(GLuint vao, GLenum expected_error)
> +{
> +       GLint value;
> +       GLint64 value64;
> +       bool pass = true;
> +
> +       glDisableVertexArrayAttrib(vao, 0);
> +       pass = piglit_check_gl_error(expected_error) && pass;
> +
> +       glEnableVertexArrayAttrib(vao, 0);
> +       pass = piglit_check_gl_error(expected_error) && pass;
> +
> +       glVertexArrayElementBuffer(vao, 0);
> +       pass = piglit_check_gl_error(expected_error) && pass;
> +
> +       glVertexArrayVertexBuffer(vao, 0, 0, 0, 0);
> +       pass = piglit_check_gl_error(expected_error) && pass;
> +
> +       glVertexArrayVertexBuffers(vao, 0, 1, NULL, NULL, NULL);
> +       pass = piglit_check_gl_error(expected_error) && pass;
> +
> +       glVertexArrayAttribFormat(vao, 0, 4, GL_FLOAT, GL_FALSE, 0);
> +       pass = piglit_check_gl_error(expected_error) && pass;
> +
> +       glVertexArrayAttribIFormat(vao, 0, 4, GL_INT, 0);
> +       pass = piglit_check_gl_error(expected_error) && pass;
> +
> +       if (piglit_is_extension_supported("GL_ARB_vertex_attrib_64bit")) {
> +               glVertexArrayAttribLFormat(vao, 0, 4, GL_DOUBLE, 0);
> +               pass = piglit_check_gl_error(expected_error) && pass;
> +       }
> +
> +       glVertexArrayAttribBinding(vao, 0, 4);
> +       pass = piglit_check_gl_error(expected_error) && pass;
> +
> +       if (piglit_is_extension_supported("GL_ARB_instanced_arrays")) {
> +               glVertexArrayBindingDivisor(vao, 0, 1);
> +               pass = piglit_check_gl_error(expected_error) && pass;
> +       }
> +
> +       glGetVertexArrayiv(vao, GL_ELEMENT_ARRAY_BUFFER_BINDING, &value);
> +       pass = piglit_check_gl_error(expected_error) && pass;
> +
> +       glGetVertexArrayIndexediv(vao, 0, GL_VERTEX_ATTRIB_ARRAY_ENABLED,
> &value);
> +       pass = piglit_check_gl_error(expected_error) && pass;
> +
> +       glGetVertexArrayIndexed64iv(vao, 0, GL_VERTEX_BINDING_OFFSET,
> &value64);
> +       pass = piglit_check_gl_error(expected_error) && pass;
> +
> +       return pass;
> +}
> +
> +
> +void
> +piglit_init(int argc, char *argv[])
> +{
> +       GLuint vao;
> +       GLuint buffer;
> +       bool pass = true;
> +
> +       piglit_require_extension("GL_ARB_direct_state_access");
> +       piglit_require_extension("GL_ARB_vertex_attrib_binding");
> +
> +       /* vaobj must not be zero in the core profile */
> +       pass = test_all_functions(0, GL_INVALID_OPERATION) && pass;
> +
> +       /* vaobj must not be a non-generated name */
>
Maybe say "vaobj must be a generated name."  The double negative is hard to
see in the comment.

> +       pass = test_all_functions(1, GL_INVALID_OPERATION) && pass;
> +
> +       /* vaobj must be an existing vertex array object */
> +       glGenVertexArrays(1, &vao);
> +       pass = test_all_functions(vao, GL_INVALID_OPERATION) && pass;
> +
> +       /* Create the VAO */
> +       glBindVertexArray(vao);
> +
> +       /* Non-generated buffer names are not supported */
> +       buffer = 1;
> +       glVertexArrayElementBuffer(vao, buffer);
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +
> +       buffer = 2;
> +       glVertexArrayVertexBuffer(vao, 0, buffer, 0, 0);
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +
> +       buffer = 3;
> +       {
> +               const GLuint     buffers[] = { buffer };
> +               const GLintptr   offsets[] = { 0 };
> +               const GLsizeiptr strides[] = { 0 };
> +
> +               glVertexArrayVertexBuffers(vao, 0, 1,
> +                                          buffers, offsets, strides);
> +               pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +       }
> +
> +       /* VertexArrayElementBuffer and VertexArrayVertexBuffers do not
> +        * create buffer objects...
> +        */
> +       glGenBuffers(1, &buffer);
> +       glVertexArrayElementBuffer(vao, buffer);
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +       pass = !glIsBuffer(buffer) && pass;
> +       glDeleteBuffers(1, &buffer);
> +
> +       glGenBuffers(1, &buffer);
> +       {
> +               const GLuint     buffers[] = { buffer };
> +               const GLintptr   offsets[] = { 0 };
> +               const GLsizeiptr strides[] = { 0 };
> +
> +               glVertexArrayVertexBuffers(vao, 0, 1,
> +                                          buffers, offsets, strides);
> +               pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +               pass = !glIsBuffer(buffer) && pass;
> +       }
> +       glDeleteBuffers(1, &buffer);
> +
> +       /* ...but VertexArrayVertexBuffer does */
> +       glGenBuffers(1, &buffer);
> +       glVertexArrayVertexBuffer(vao, 0, buffer, 16, 32);
> +       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +       pass = check_vbo_binding(vao, 0, buffer, 16, 32) && pass;
> +       pass = glIsBuffer(buffer) && pass;
> +       glDeleteBuffers(1, &buffer);
> +
> +       glDeleteVertexArrays(1, &vao);
> +
> +       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
>
Otherwise,

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