[13/14] arb_direct_state_access: Add a compatibility-profile test

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

Details

Message ID 1427822806-18528-14-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 compatibility profile.
---
 tests/all.py                                       |   1 +
 .../spec/arb_direct_state_access/CMakeLists.gl.txt |   1 +
 tests/spec/arb_direct_state_access/vao-compat.c    | 199 +++++++++++++++++++++
 3 files changed, 201 insertions(+)
 create mode 100644 tests/spec/arb_direct_state_access/vao-compat.c

Patch hide | download patch | download mbox

diff --git a/tests/all.py b/tests/all.py
index e85763e..0dbb59d 100755
--- a/tests/all.py
+++ b/tests/all.py
@@ -4290,6 +4290,7 @@  with profile.group_manager(
     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')
+    g(['arb_direct_state_access-vao-compat'], 'vao-compat')
 
 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 bc610b6..5dd4835 100644
--- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
+++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
@@ -46,4 +46,5 @@  piglit_add_executable (arb_direct_state_access-vao-vertex-buffer vao-vertex-buff
 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)
+piglit_add_executable (arb_direct_state_access-vao-compat vao-compat.c dsa-utils.c)
 # vim: ft=cmake:
diff --git a/tests/spec/arb_direct_state_access/vao-compat.c b/tests/spec/arb_direct_state_access/vao-compat.c
new file mode 100644
index 0000000..92f94c1
--- /dev/null
+++ b/tests/spec/arb_direct_state_access/vao-compat.c
@@ -0,0 +1,199 @@ 
+/*
+ * 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-compat.c
+ *
+ * Tests behavior specific to the compatibility profile.
+ */
+
+#include "piglit-util-gl.h"
+#include "dsa-utils.h"
+
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	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;
+}
+
+
+/**
+ * Calls all DSA functions on the given vaobj, with valid parameters
+ * and checks that expected_error is generated.
+ */
+static bool
+test_all_functions(GLuint vaobj, GLenum expected_error)
+{
+	GLint value;
+	GLint64 value64;
+	bool pass = true;
+
+	glDisableVertexArrayAttrib(vaobj, 0);
+	pass = piglit_check_gl_error(expected_error) && pass;
+
+	glEnableVertexArrayAttrib(vaobj, 0);
+	pass = piglit_check_gl_error(expected_error) && pass;
+
+	glVertexArrayElementBuffer(vaobj, 0);
+	pass = piglit_check_gl_error(expected_error) && pass;
+
+	glVertexArrayVertexBuffer(vaobj, 0, 0, 0, 0);
+	pass = piglit_check_gl_error(expected_error) && pass;
+
+	glVertexArrayVertexBuffers(vaobj, 0, 1, NULL, NULL, NULL);
+	pass = piglit_check_gl_error(expected_error) && pass;
+
+	glVertexArrayAttribFormat(vaobj, 0, 4, GL_FLOAT, GL_FALSE, 0);
+	pass = piglit_check_gl_error(expected_error) && pass;
+
+	if (piglit_get_gl_version() >= 30) {
+	    glVertexArrayAttribIFormat(vaobj, 0, 4, GL_INT, 0);
+	    pass = piglit_check_gl_error(expected_error) && pass;
+	}
+
+	if (piglit_is_extension_supported("GL_ARB_vertex_attrib_64bit")) {
+		glVertexArrayAttribLFormat(vaobj, 0, 4, GL_DOUBLE, 0);
+		pass = piglit_check_gl_error(expected_error) && pass;
+	}
+
+	glVertexArrayAttribBinding(vaobj, 0, 4);
+	pass = piglit_check_gl_error(expected_error) && pass;
+
+	if (piglit_is_extension_supported("GL_ARB_instanced_arrays")) {
+		glVertexArrayBindingDivisor(vaobj, 0, 1);
+		pass = piglit_check_gl_error(expected_error) && pass;
+	}
+
+	glGetVertexArrayiv(vaobj, GL_ELEMENT_ARRAY_BUFFER_BINDING, &value);
+	pass = piglit_check_gl_error(expected_error) && pass;
+
+	glGetVertexArrayIndexediv(vaobj, 0, GL_VERTEX_ATTRIB_ARRAY_ENABLED,
+	                          &value);
+	pass = piglit_check_gl_error(expected_error) && pass;
+
+	glGetVertexArrayIndexed64iv(vaobj, 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_array_object");
+	piglit_require_extension("GL_ARB_vertex_attrib_binding");
+
+	/* 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;
+
+	/* vaobj is allowed to be zero in the compatibility profile */
+	pass = test_all_functions(0, GL_NO_ERROR) && pass;
+
+	/* Create the VAO */
+	glBindVertexArray(vao);
+
+	/* VertexArrayElementBuffer and VertexArrayVertexBuffers
+	 * do not accept non-generated buffer names...
+	 */
+	buffer = 1;
+	glVertexArrayElementBuffer(vao, buffer);
+	pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
+	pass = !glIsBuffer(buffer) && pass;
+
+        buffer = 2;
+	{
+		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;
+	}
+
+	/* ...but VertexArrayVertexBuffer does. */
+        buffer = 3;
+	glVertexArrayVertexBuffer(vao, 0, buffer, 0, 0);
+	pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
+	pass = check_vbo_binding(vao, 0, buffer, 0, 0) && pass;
+	pass = glIsBuffer(buffer) && pass;
+	glDeleteBuffers(1, &buffer);
+
+	/* 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 compatibility profile.
> ---
>  tests/all.py                                       |   1 +
>  .../spec/arb_direct_state_access/CMakeLists.gl.txt |   1 +
>  tests/spec/arb_direct_state_access/vao-compat.c    | 199
> +++++++++++++++++++++
>  3 files changed, 201 insertions(+)
>  create mode 100644 tests/spec/arb_direct_state_access/vao-compat.c
>
> diff --git a/tests/all.py b/tests/all.py
> index e85763e..0dbb59d 100755
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -4290,6 +4290,7 @@ with profile.group_manager(
>      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')
> +    g(['arb_direct_state_access-vao-compat'], 'vao-compat')
>
>  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 bc610b6..5dd4835 100644
> --- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
> +++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
> @@ -46,4 +46,5 @@ piglit_add_executable
> (arb_direct_state_access-vao-vertex-buffer vao-vertex-buff
>  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)
> +piglit_add_executable (arb_direct_state_access-vao-compat vao-compat.c
> dsa-utils.c)
>  # vim: ft=cmake:
> diff --git a/tests/spec/arb_direct_state_access/vao-compat.c
> b/tests/spec/arb_direct_state_access/vao-compat.c
> new file mode 100644
> index 0000000..92f94c1
> --- /dev/null
> +++ b/tests/spec/arb_direct_state_access/vao-compat.c
> @@ -0,0 +1,199 @@
> +/*
> + * 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-compat.c
> + *
> + * Tests behavior specific to the compatibility profile.
> + */
> +
> +#include "piglit-util-gl.h"
> +#include "dsa-utils.h"
> +
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +       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;
> +}
> +
> +
> +/**
> + * Calls all DSA functions on the given vaobj, with valid parameters
> + * and checks that expected_error is generated.
> + */
> +static bool
> +test_all_functions(GLuint vaobj, GLenum expected_error)
> +{
> +       GLint value;
> +       GLint64 value64;
> +       bool pass = true;
> +
> +       glDisableVertexArrayAttrib(vaobj, 0);
> +       pass = piglit_check_gl_error(expected_error) && pass;
> +
> +       glEnableVertexArrayAttrib(vaobj, 0);
> +       pass = piglit_check_gl_error(expected_error) && pass;
> +
> +       glVertexArrayElementBuffer(vaobj, 0);
> +       pass = piglit_check_gl_error(expected_error) && pass;
> +
> +       glVertexArrayVertexBuffer(vaobj, 0, 0, 0, 0);
> +       pass = piglit_check_gl_error(expected_error) && pass;
> +
> +       glVertexArrayVertexBuffers(vaobj, 0, 1, NULL, NULL, NULL);
> +       pass = piglit_check_gl_error(expected_error) && pass;
> +
> +       glVertexArrayAttribFormat(vaobj, 0, 4, GL_FLOAT, GL_FALSE, 0);
> +       pass = piglit_check_gl_error(expected_error) && pass;
> +
> +       if (piglit_get_gl_version() >= 30) {
> +           glVertexArrayAttribIFormat(vaobj, 0, 4, GL_INT, 0);
> +           pass = piglit_check_gl_error(expected_error) && pass;
> +       }
> +
> +       if (piglit_is_extension_supported("GL_ARB_vertex_attrib_64bit")) {
> +               glVertexArrayAttribLFormat(vaobj, 0, 4, GL_DOUBLE, 0);
> +               pass = piglit_check_gl_error(expected_error) && pass;
> +       }
> +
> +       glVertexArrayAttribBinding(vaobj, 0, 4);
> +       pass = piglit_check_gl_error(expected_error) && pass;
> +
> +       if (piglit_is_extension_supported("GL_ARB_instanced_arrays")) {
> +               glVertexArrayBindingDivisor(vaobj, 0, 1);
> +               pass = piglit_check_gl_error(expected_error) && pass;
> +       }
> +
> +       glGetVertexArrayiv(vaobj, GL_ELEMENT_ARRAY_BUFFER_BINDING, &value);
> +       pass = piglit_check_gl_error(expected_error) && pass;
> +
> +       glGetVertexArrayIndexediv(vaobj, 0, GL_VERTEX_ATTRIB_ARRAY_ENABLED,
> +                                 &value);
> +       pass = piglit_check_gl_error(expected_error) && pass;
> +
> +       glGetVertexArrayIndexed64iv(vaobj, 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_array_object");
> +       piglit_require_extension("GL_ARB_vertex_attrib_binding");
> +
> +       /* vaobj must not be a non-generated name */
>
Again, remove the double negative (it's confusing).

> +       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;
> +
> +       /* vaobj is allowed to be zero in the compatibility profile */
> +       pass = test_all_functions(0, GL_NO_ERROR) && pass;
> +
> +       /* Create the VAO */
> +       glBindVertexArray(vao);
> +
> +       /* VertexArrayElementBuffer and VertexArrayVertexBuffers
> +        * do not accept non-generated buffer names...
> +        */
> +       buffer = 1;
> +       glVertexArrayElementBuffer(vao, buffer);
> +       pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass;
> +       pass = !glIsBuffer(buffer) && pass;
> +
> +        buffer = 2;
>
Remove extra space ^^^^

> +       {
> +               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;
> +       }
> +
> +       /* ...but VertexArrayVertexBuffer does. */
> +        buffer = 3;
>
Remove extra space ^^^^^

> +       glVertexArrayVertexBuffer(vao, 0, buffer, 0, 0);
> +       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +       pass = check_vbo_binding(vao, 0, buffer, 0, 0) && pass;
> +       pass = glIsBuffer(buffer) && pass;
> +       glDeleteBuffers(1, &buffer);
> +
> +       /* 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
>
With those fixed,

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