From 65817719ef6726019d7c536b7dd5269ceb2361af Mon Sep 17 00:00:00 2001 From: Fredrik Höglund Date: Sun, 22 Mar 2015 13:26:15 +0100 Subject: arb_direct_state_access: Add a test for glEnable/DisableVertexArrayAttrib This test verifies that glEnableVertexArrayAttrib() and glDisableVertexArrayAttrib() work as expected. Reviewed-by: Laura Ekstrand --- tests/all.py | 1 + .../spec/arb_direct_state_access/CMakeLists.gl.txt | 1 + .../vao-attrib-enabledisable.c | 127 +++++++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100644 tests/spec/arb_direct_state_access/vao-attrib-enabledisable.c diff --git a/tests/all.py b/tests/all.py index 441ea77c6..cfa2a9614 100755 --- a/tests/all.py +++ b/tests/all.py @@ -4281,6 +4281,7 @@ with profile.group_manager( 'create-programpipelines') g(['arb_direct_state_access-create-queries'], 'create-queries') g(['arb_direct_state_access-vao-create'], 'vao-create') + g(['arb_direct_state_access-vao-attrib-enabledisable'], 'vao-attrib-enabledisable') 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 9fcbf7ea4..4ee9c0ce8 100644 --- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt +++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt @@ -37,4 +37,5 @@ piglit_add_executable (arb_direct_state_access-create-samplers create-samplers.c piglit_add_executable (arb_direct_state_access-create-programpipelines create-programpipelines.c) 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) # vim: ft=cmake: diff --git a/tests/spec/arb_direct_state_access/vao-attrib-enabledisable.c b/tests/spec/arb_direct_state_access/vao-attrib-enabledisable.c new file mode 100644 index 000000000..98db400f0 --- /dev/null +++ b/tests/spec/arb_direct_state_access/vao-attrib-enabledisable.c @@ -0,0 +1,127 @@ +/* + * 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-enabledisable.c + * + * Verifies that glEnableVertexArrayAttrib and glDisableVertexArrayAttrib + * work as expected. + */ + +#include "piglit-util-gl.h" +#include "dsa-utils.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; +} + + +#define check_enabled(vao, index) \ + check_indexed_vao_param(vao, index, \ + GL_VERTEX_ATTRIB_ARRAY_ENABLED, GL_TRUE) + + +#define check_disabled(vao, index) \ + check_indexed_vao_param(vao, index, \ + GL_VERTEX_ATTRIB_ARRAY_ENABLED, GL_FALSE) + + +void +piglit_init(int argc, char *argv[]) +{ + GLuint vao; + GLint maxAttribs; + bool pass = true; + int i; + + piglit_require_extension("GL_ARB_direct_state_access"); + piglit_require_extension("GL_ARB_vertex_array_object"); + + glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxAttribs); + + /* Create a VAO */ + glCreateVertexArrays(1, &vao); + + /* Enable and disable each array in turn */ + for (i = 0; i < maxAttribs; i++) { + /* Check that the array is disabled by default */ + pass = check_disabled(vao, i) && pass; + + /* Enable the array and verify that it was enabled */ + glEnableVertexArrayAttrib(vao, i); + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + pass = check_enabled(vao, i) && pass; + + /* Disable the array again and verify that it was disabled */ + glDisableVertexArrayAttrib(vao, i); + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + pass = check_disabled(vao, i) && pass; + } + + /* The ARB_direct_state_access spec says: + * + * "An INVALID_VALUE error is generated if is greater than + * or equal to the value of MAX_VERTEX_ATTRIBS." + */ + glEnableVertexArrayAttrib(vao, maxAttribs); + pass = piglit_check_gl_error(GL_INVALID_VALUE) && pass; + + glDisableVertexArrayAttrib(vao, maxAttribs); + 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 + * EnableVertexArrayAttrib and DisableVertexArrayAttrib if + * is not [compatibility profile: zero or] the name of an existing + * vertex array object." + */ + glGenVertexArrays(1, &vao); + + glEnableVertexArrayAttrib(vao, 0); + pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + + glDisableVertexArrayAttrib(vao, 0); + pass = piglit_check_gl_error(GL_INVALID_OPERATION) && pass; + + glDeleteVertexArrays(1, &vao); + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} + -- cgit v1.2.3