This looks good. Reviewed-by: Laura Ekstrand <[email protected]>
On Tue, Mar 31, 2015 at 10:26 AM, Fredrik Höglund <[email protected]> wrote: > This test verifies that changes to vaobj=0 are applied to the default > vertex array object, and not to the currently bound vertex array object. > --- > tests/all.py | 1 + > .../spec/arb_direct_state_access/CMakeLists.gl.txt | 1 + > .../spec/arb_direct_state_access/vao-compat-draw.c | 171 > +++++++++++++++++++++ > 3 files changed, 173 insertions(+) > create mode 100644 tests/spec/arb_direct_state_access/vao-compat-draw.c > > diff --git a/tests/all.py b/tests/all.py > index 0dbb59d..5d7bdab 100755 > --- a/tests/all.py > +++ b/tests/all.py > @@ -4291,6 +4291,7 @@ with profile.group_manager( > 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') > + g(['arb_direct_state_access-vao-compat-draw'], 'vao-compat-draw') > > 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 5dd4835..c0bdb51 100644 > --- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt > +++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt > @@ -47,4 +47,5 @@ piglit_add_executable > (arb_direct_state_access-vao-vertex-buffers vao-vertex-buf > 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) > +piglit_add_executable (arb_direct_state_access-vao-compat-draw > vao-compat-draw.c) > # vim: ft=cmake: > diff --git a/tests/spec/arb_direct_state_access/vao-compat-draw.c > b/tests/spec/arb_direct_state_access/vao-compat-draw.c > new file mode 100644 > index 0000000..31d73bd > --- /dev/null > +++ b/tests/spec/arb_direct_state_access/vao-compat-draw.c > @@ -0,0 +1,171 @@ > +/* > + * 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-draw.c > + * > + * This test verifies that changes made to vaobj=0 are applied to the > default > + * vertex array object, and not to the currently bound vertex array > object. > + */ > + > +#include "piglit-util-gl.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 > + > + > +#define VA_POSITION 0 > +#define VA_COLOR 1 > + > + > +const char *vs = > + "attribute vec4 vertex;\n" > + "attribute vec4 color;\n" > + "varying vec4 out_color;\n" > + "void main(void)\n{\n" > + " gl_Position = vertex;\n" > + " out_color = color;\n" > + "}"; > + > +const char *fs = > + "varying vec4 out_color;\n" > + "void main(void)\n{\n" > + " gl_FragColor = out_color;\n" > + "}"; > + > + > +enum piglit_result > +piglit_display(void) > +{ > + GLuint vao; > + float green[] = { 0.0, 1.0, 0.0, 1.0 }; > + > + float vertices[] = { > + /* Top half of the window */ > + -1.0, 0.0, > + -1.0, 1.0, > + 1.0, 0.0, > + 1.0, 1.0, > + > + /* Bottom half of the window */ > + -1.0, -1.0, > + -1.0, 0.0, > + 1.0, -1.0, > + 1.0, 0.0, > + }; > + > + bool pass = true; > + > + /* Create two VBO's. The first contains the vertex positions, > + * and the second contains the color. > + */ > + GLuint vbo[2]; > + glCreateBuffers(2, vbo); > + > + glNamedBufferData(vbo[0], sizeof(vertices), vertices, > GL_STATIC_DRAW); > + glNamedBufferData(vbo[1], sizeof(green), green, GL_STATIC_DRAW); > + > + /* Set up the non-default VAO */ > + glCreateVertexArrays(1, &vao); > + glVertexArrayAttribFormat(vao, VA_POSITION, 2, GL_FLOAT, GL_FALSE, > 0); > + glVertexArrayAttribBinding(vao, VA_POSITION, 0); > + glEnableVertexArrayAttrib(vao, VA_POSITION); > + > + glVertexArrayAttribFormat(vao, VA_COLOR, 4, GL_FLOAT, GL_FALSE, 0); > + glVertexArrayAttribBinding(vao, VA_COLOR, 1); > + glEnableVertexArrayAttrib(vao, VA_COLOR); > + > + /* Bind the VBO's. Set the offset of the first bind point > + * so we draw the top half of the window. Note that the stride > + * for the color bind point is set to zero. > + */ > + glVertexArrayVertexBuffer(vao, 0, vbo[0], 0, 2 * sizeof(float)); > + glVertexArrayVertexBuffer(vao, 1, vbo[1], 0, 0); > + > + /* Bind vao so a non-default VAO is bound while we're making > + * changes to the default VAO > + */ > + glBindVertexArray(vao); > + > + /* Set up the default VAO */ > + glVertexArrayAttribFormat(0, VA_POSITION, 2, GL_FLOAT, GL_FALSE, > 0); > + glVertexArrayAttribBinding(0, VA_POSITION, 0); > + glEnableVertexArrayAttrib(0, VA_POSITION); > + > + glVertexArrayAttribFormat(0, VA_COLOR, 4, GL_FLOAT, GL_FALSE, 0); > + glVertexArrayAttribBinding(0, VA_COLOR, 1); > + glEnableVertexArrayAttrib(0, VA_COLOR); > + > + /* Bind the VBO's and set the offset of the first bind point > + * so we draw the bottom half of the window. > + */ > + glVertexArrayVertexBuffer(0, 0, vbo[0], 8 * sizeof(float), > + 2 * sizeof(float)); > + glVertexArrayVertexBuffer(0, 1, vbo[1], 0, 0); > + > + /* Clear the back buffer to red */ > + glClearColor(1.0, 0.0, 0.0, 1.0); > + glClear(GL_COLOR_BUFFER_BIT); > + > + /* Draw the arrays in the non-default vao */ > + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); > + > + /* Draw the arrays in the default VAO */ > + glBindVertexArray(0); > + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); > + > + glDeleteVertexArrays(1, &vao); > + glDeleteBuffers(2, vbo); > + > + pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, > + green) && pass; > + > + piglit_present_results(); > + > + return pass ? PIGLIT_PASS : PIGLIT_FAIL; > +} > + > + > +void > +piglit_init(int argc, char *argv[]) > +{ > + GLuint program; > + > + piglit_require_extension("GL_ARB_direct_state_access"); > + piglit_require_extension("GL_ARB_vertex_array_object"); > + piglit_require_extension("GL_ARB_vertex_attrib_binding"); > + > + program = piglit_build_simple_program_unlinked(vs, fs); > + glBindAttribLocation(program, VA_POSITION, "vertex"); > + glBindAttribLocation(program, VA_COLOR, "color"); > + glLinkProgram(program); > + > + glUseProgram(program); > +} > + > -- > 2.1.4 > > _______________________________________________ > Piglit mailing list > [email protected] > http://lists.freedesktop.org/mailman/listinfo/piglit >
_______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
