diff options
author | Fredrik Höglund <fredrik@kde.org> | 2015-03-22 13:52:06 +0100 |
---|---|---|
committer | Fredrik Höglund <fredrik@kde.org> | 2015-04-03 00:51:32 +0200 |
commit | 9d6f3c80d1860ccfda957dce518bbd69ff3eb0b0 (patch) | |
tree | 8cf24359584aeee561026d0d4b4bed769ea4dead | |
parent | 15a081f362fe91215a80d3efa50882a1e51dd8da (diff) |
arb_direct_state_access: Add a compatibility-profile test
This tests behavior specific to the compatibility profile.
v2: Fix compiler warnings.
Remove a double-negative in a comment.
Whitespace fixes.
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-compat.c | 199 |
3 files changed, 201 insertions, 0 deletions
diff --git a/tests/all.py b/tests/all.py index e85763e3a..0dbb59dc6 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 bc610b649..5dd4835a7 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 000000000..7d51b5010 --- /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 be a 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 GLsizei 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 GLsizei 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); +} + |