diff options
author | Fredrik Höglund <fredrik@kde.org> | 2015-03-22 13:35:39 +0100 |
---|---|---|
committer | Fredrik Höglund <fredrik@kde.org> | 2015-04-03 00:51:31 +0200 |
commit | c31600c2a8cad5ae0c1bbf5c36325265e6838047 (patch) | |
tree | 276c2c4a48483e0f3c9f2cf936d5cc01c1c78209 | |
parent | 03fa5f255ca301dee318322ab9799dee389ea770 (diff) |
arb_direct_state_access: Add a test for glVertexArrayElementBuffer
This test verifies that glVertexArrayElementBuffer works as expected.
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-element-array-buffer.c | 123 |
3 files changed, 125 insertions, 0 deletions
diff --git a/tests/all.py b/tests/all.py index 442f5b66c..6b440693a 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 e45da4646..fe1753085 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 000000000..8e0a9e11f --- /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); +} + |