diff options
author | Laura Ekstrand <laura@jlekstrand.net> | 2015-01-13 11:58:47 -0800 |
---|---|---|
committer | Laura Ekstrand <laura@jlekstrand.net> | 2015-03-09 16:20:43 -0700 |
commit | c7b33b873868d4cd5cdac1f1f7c7ee81b1cc9103 (patch) | |
tree | 19c22ef85d3519e4393c9ab63f1ffa18cb9ba035 | |
parent | d2abbe8d8ee5bc197eb2df92e19bbf978caa9191 (diff) |
arb_direct_state_access: Testing NamedBufferSubData.
-rw-r--r-- | 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/namedbuffersubdata-vbo-sync.c | 106 |
3 files changed, 108 insertions, 0 deletions
diff --git a/tests/all.py b/tests/all.py index 9adf38d8c..733c17c53 100644 --- a/tests/all.py +++ b/tests/all.py @@ -4240,6 +4240,7 @@ with profile.group_manager( g(['arb_direct_state_access-create-queries'], 'create-queries') g(['arb_direct_state_access-texture-buffer-range'], 'texture-buffer-range') g(['arb_direct_state_access-namedbufferstorage-persistent'], 'namedbufferstorage-persistent') + g(['arb_direct_state_access-namedbuffersubdata-vbo-sync'], 'namedbuffersubdata-vbo-sync') 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 a8ae726ab..fef404987 100644 --- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt +++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt @@ -16,6 +16,7 @@ piglit_add_executable (arb_direct_state_access-gettransformfeedback gettransform piglit_add_executable (arb_direct_state_access-create-renderbuffers create-renderbuffers.c) piglit_add_executable (arb_direct_state_access-namedrenderbuffer namedrenderbuffer.c) piglit_add_executable (arb_direct_state_access-namedbufferstorage-persistent namedbufferstorage.c) +piglit_add_executable (arb_direct_state_access-namedbuffersubdata-vbo-sync namedbuffersubdata-vbo-sync.c) piglit_add_executable (arb_direct_state_access-dsa-textures dsa-textures.c dsa-utils.c) piglit_add_executable (arb_direct_state_access-texturesubimage texturesubimage.c) piglit_add_executable (arb_direct_state_access-bind-texture-unit bind-texture-unit.c) diff --git a/tests/spec/arb_direct_state_access/namedbuffersubdata-vbo-sync.c b/tests/spec/arb_direct_state_access/namedbuffersubdata-vbo-sync.c new file mode 100644 index 000000000..6e2f5ecad --- /dev/null +++ b/tests/spec/arb_direct_state_access/namedbuffersubdata-vbo-sync.c @@ -0,0 +1,106 @@ +/* + * Copyright © 2009, 2015 Intel Corporation + * + * 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 + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * 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 NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS 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. + * + * Authors: + * Ben Holmes <shranzel@hotmail.com> + * Eric Anholt <eric@anholt.net> + * + * Adapted by Laura Ekstrand <laura@jlekstrand.net> to test + * NamedBufferSubData, January 2015. + */ + +/** @file namedbuffersubdata-vbo-sync.c + * + * Test for synchronizing behavior of glNamedBufferSubData. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 10; + + config.window_width = 400; + config.window_height = 300; + config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE; + +PIGLIT_GL_TEST_CONFIG_END + +static GLuint vbo; + +void +piglit_init(int argc, char **argv) +{ + piglit_require_extension("GL_ARB_vertex_buffer_object"); + piglit_require_extension("GL_ARB_direct_state_access"); + + piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); + + glCreateBuffers(1, &vbo); +} + +enum piglit_result +piglit_display(void) +{ + GLfloat white[4] = {1.0, 1.0, 1.0, 0.0}; + GLboolean pass = GL_TRUE; + GLfloat varray1[12] = {175, 125, 0, + 175, 175, 0, + 125, 125, 0, + 125, 175, 0}; + GLfloat varray2[12] = {275, 125, 0, + 275, 175, 0, + 225, 125, 0, + 225, 175, 0}; + GLenum err; + + glNamedBufferData(vbo, 12 * sizeof(GLfloat), varray1, + GL_DYNAMIC_DRAW); + + glBindBuffer(GL_ARRAY_BUFFER, vbo); + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(3, GL_FLOAT, 0, 0); + + glClear(GL_COLOR_BUFFER_BIT); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + /* Demonstrate inserting data while not bound */ + glBindBuffer(GL_ARRAY_BUFFER, 0); + glNamedBufferSubData(vbo, 0, 12 * sizeof(GLfloat), varray2); + glBindBuffer(GL_ARRAY_BUFFER, vbo); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + if ((err = glGetError()) != 0) { + printf("gl error: 0x%08x\n", err); + pass = GL_FALSE; + } + + pass = piglit_probe_pixel_rgb(250, 150, white) && pass; + pass = piglit_probe_pixel_rgb(150, 150, white) && pass; + + piglit_present_results(); + + glDisableClientState(GL_VERTEX_ARRAY); + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} |