diff options
author | Fredrik Höglund <fredrik@kde.org> | 2015-03-22 13:32:18 +0100 |
---|---|---|
committer | Fredrik Höglund <fredrik@kde.org> | 2015-04-03 00:51:14 +0200 |
commit | cba2c5c4680f205c884daf5a7af2608aca09408f (patch) | |
tree | 1a4f33533a56b2bebe67f1096c0504ef234013b8 | |
parent | 8970204d45940c17fa2f036f5f2ddbccf0fb55b0 (diff) |
arb_direct_state_access: Add a test for glVertexArrayAttribBinding
This test verifies that glVertexArrayAttribBinding works as expected.
v2: Update the page numbers to the current version of the GL 4.5 spec.
Reviewed-by: Laura Ekstrand <laura@jlekstrand.net>
-rwxr-xr-x | tests/all.py | 1 | ||||
-rw-r--r-- | tests/spec/arb_direct_state_access/CMakeLists.gl.txt | 1 | ||||
-rw-r--r-- | tests/spec/arb_direct_state_access/vao-attrib-binding.c | 133 |
3 files changed, 135 insertions, 0 deletions
diff --git a/tests/all.py b/tests/all.py index 9f2f3efe4..87077593a 100755 --- a/tests/all.py +++ b/tests/all.py @@ -4283,6 +4283,7 @@ with profile.group_manager( g(['arb_direct_state_access-vao-create'], 'vao-create') g(['arb_direct_state_access-vao-attrib-enabledisable'], 'vao-attrib-enabledisable') g(['arb_direct_state_access-vao-attrib-format'], 'vao-attrib-format') + g(['arb_direct_state_access-vao-attrib-binding'], 'vao-attrib-binding') 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 e5596be0c..a5d0a5567 100644 --- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt +++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt @@ -39,4 +39,5 @@ piglit_add_executable (arb_direct_state_access-create-queries create-queries.c) piglit_add_executable (arb_direct_state_access-vao-create vao-create.c) piglit_add_executable (arb_direct_state_access-vao-attrib-enabledisable vao-attrib-enabledisable.c dsa-utils.c) 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) # vim: ft=cmake: diff --git a/tests/spec/arb_direct_state_access/vao-attrib-binding.c b/tests/spec/arb_direct_state_access/vao-attrib-binding.c new file mode 100644 index 000000000..ac2498f23 --- /dev/null +++ b/tests/spec/arb_direct_state_access/vao-attrib-binding.c @@ -0,0 +1,133 @@ +/* + * 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-attrib-binding.c + * + * Verifies that glVertexArrayAttribBinding works as expected. + */ + +#include "piglit-util-gl.h" +#include "dsa-utils.h" + + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 20; + 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; +} + + +#define check_binding(vao, index, expected) \ + check_indexed_vao_param(vao, index, \ + GL_VERTEX_ATTRIB_BINDING, expected) + + +void +piglit_init(int argc, char *argv[]) +{ + GLuint vao; + bool pass = true; + GLint maxAttribs; + GLint maxAttribBindings; + GLuint *bindings; + int i; + + piglit_require_extension("GL_ARB_direct_state_access"); + piglit_require_extension("GL_ARB_vertex_array_object"); + piglit_require_extension("GL_ARB_vertex_attrib_binding"); + + glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxAttribs); + glGetIntegerv(GL_MAX_VERTEX_ATTRIB_BINDINGS, &maxAttribBindings); + + /* Create a VAO */ + glCreateVertexArrays(1, &vao); + + /* Check the default attrib bindings */ + for (i = 0; i < maxAttribs; i++) + pass = check_binding(vao, i, i) && pass; + + /* Change the bindings */ + bindings = (GLuint *) malloc(maxAttribs * sizeof(GLuint)); + + for (i = 0; i < maxAttribs; i++) { + bindings[i] = rand() % maxAttribBindings; + glVertexArrayAttribBinding(vao, i, bindings[i]); + } + + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + + /* Verify that the bindings were changed */ + for (i = 0; i < maxAttribs; i++) + pass = check_binding(vao, i, bindings[i]) && pass; + + free(bindings); + + /* Page 339 (page 361 of the PDF) of the OpenGL 4.5 (Core Profile) + * specification says: + * + * "An INVALID_VALUE error is generated if attribindex is greater + * than or equal to the value of MAX_VERTEX_ATTRIBS. + * An INVALID_VALUE error is generated if bindingindex is greater + * than or equal to the value of MAX_VERTEX_ATTRIB_BINDINGS. + * An INVALID_OPERATION error is generated if no vertex array + * object is bound." + * + * We assume that the last error is not meant to apply to + * VertexArrayAttribBinding. + */ + glVertexArrayAttribBinding(vao, maxAttribs, 0); + pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; + + glVertexArrayAttribBinding(vao, 0, maxAttribBindings); + pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; + + glDeleteVertexArrays(1, &vao); + + /* The ARB_direct_state_access spec says: + * + * "An INVALID_OPERATION error is generated by + * VertexArrayAttribBinding if <vaobj> is not + * [compatibility profile: zero or] the name of an existing + * vertex array object." + */ + glGenVertexArrays(1, &vao); + glVertexArrayAttribBinding(vao, 0, 0); + pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + + glDeleteVertexArrays(1, &vao); + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} + |