diff options
author | Fredrik Höglund <fredrik@kde.org> | 2015-03-22 13:36:25 +0100 |
---|---|---|
committer | Fredrik Höglund <fredrik@kde.org> | 2015-04-03 00:51:31 +0200 |
commit | 317f2516cd1fa2e4c5b2fe52821e485364ec0d6d (patch) | |
tree | 42bfa56e491c69dc0b8e71da9b01d36a94db192b | |
parent | c31600c2a8cad5ae0c1bbf5c36325265e6838047 (diff) |
arb_direct_state_access: Add a test for glVertexArrayVertexBuffer
This test verifies that glVertexArrayVertexBuffer works as expected.
v2: Fix an off-by-one in the MAX_VERTEX_ATTRIB_STRIDE test.
-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-vertex-buffer.c | 141 |
3 files changed, 143 insertions, 0 deletions
diff --git a/tests/all.py b/tests/all.py index 6b440693a..b97261078 100755 --- a/tests/all.py +++ b/tests/all.py @@ -4286,6 +4286,7 @@ with profile.group_manager( 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') + g(['arb_direct_state_access-vao-vertex-buffer'], 'vao-vertex-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 fe1753085..820971f4e 100644 --- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt +++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt @@ -42,4 +42,5 @@ piglit_add_executable (arb_direct_state_access-vao-attrib-format vao-attrib-form 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) +piglit_add_executable (arb_direct_state_access-vao-vertex-buffer vao-vertex-buffer.c dsa-utils.c) # vim: ft=cmake: diff --git a/tests/spec/arb_direct_state_access/vao-vertex-buffer.c b/tests/spec/arb_direct_state_access/vao-vertex-buffer.c new file mode 100644 index 000000000..78eb10a89 --- /dev/null +++ b/tests/spec/arb_direct_state_access/vao-vertex-buffer.c @@ -0,0 +1,141 @@ +/* + * 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-vertex-buffer.c + * + * Verifies that glVertexArrayVertexBuffer works as expected. + */ + +#include "piglit-util-gl.h" +#include "dsa-utils.h" + +#include <limits.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; +} + + +void +piglit_init(int argc, char *argv[]) +{ + GLuint vao, buffers[4]; + bool pass = true; + int i; + + /* See table 23.55 in the OpenGL 4.5 (Core Profile) spec */ + GLuint maxStride = 2048; + GLuint maxBindings; + + 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_ATTRIB_BINDINGS, (GLint *) &maxBindings); + + if (piglit_get_gl_version() >= 44) + glGetIntegerv(GL_MAX_VERTEX_ATTRIB_STRIDE, (GLint *) &maxStride); + + /* Create a VAO */ + glCreateVertexArrays(1, &vao); + + /* Create a set of buffer objects */ + glCreateBuffers(ARRAY_SIZE(buffers), buffers); + + for (i = 0; i < maxBindings; i++) { + const GLintptr offset = rand() % INT_MAX; + const GLsizeiptr stride = rand() % (maxStride + 1); + const GLuint vbo = buffers[rand() % ARRAY_SIZE(buffers)]; + + /* Verify that no VBO is bound by default */ + pass = check_vbo_binding(vao, i, 0, 0, 16) && pass; + + /* Change the VBO binding and verify that it was changed */ + glVertexArrayVertexBuffer(vao, i, vbo, offset, stride); + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + pass = check_vbo_binding(vao, i, vbo, offset, stride) && pass; + } + + /* The ARB_direct_state_access specification says: + * + * "An INVALID_VALUE error is generated if <bindingindex> is greater + * than or equal to the value of MAX_VERTEX_ATTRIB_BINDINGS. + * + * An INVALID_VALUE error is generated if <stride> or <offset> is + * negative, or if <stride> is greater than the value of + * MAX_VERTEX_ATTRIB_STRIDE." + */ + + /* bindingindex >= MAX_VERTEX_ATTRIB_BINDINGS */ + glVertexArrayVertexBuffer(vao, maxBindings, buffers[0], 0, 0); + pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; + + /* Negative offset */ + glVertexArrayVertexBuffer(vao, 0, buffers[0], -1, 0); + pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; + + /* Negative stride */ + glVertexArrayVertexBuffer(vao, 0, buffers[0], 0, -1); + pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; + + if (piglit_get_gl_version() >= 44) { + /* Stride > MAX_VERTEX_ATTRIB_STRIDE */ + glVertexArrayVertexBuffer(vao, 0, buffers[0], 0, + maxStride + 1); + pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; + } + + glDeleteVertexArrays(1, &vao); + + /* The ARB_direct_state_access specification says: + * + * "An INVALID_OPERATION error is generated by + * VertexArrayVertexBuffer if <vaobj> is not + * [compatibility profile: zero or] the name of an + * existing vertex array object." + */ + glGenVertexArrays(1, &vao); + glVertexArrayVertexBuffer(vao, 0, buffers[0], 0, 0); + pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + glDeleteVertexArrays(1, &vao); + + glDeleteBuffers(ARRAY_SIZE(buffers), buffers); + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} + |