From 88844e81da2201add17af20421bb1cc9b02cc29c Mon Sep 17 00:00:00 2001 From: Laura Ekstrand Date: Wed, 14 Jan 2015 15:16:04 -0800 Subject: arb_direct_state_access: Testing UnmapNamedBuffer. --- tests/all.py | 1 + .../spec/arb_direct_state_access/CMakeLists.gl.txt | 1 + .../mapnamedbuffer-pbo-readpixels.c | 6 +- .../arb_direct_state_access/unmapnamedbuffer-vbo.c | 115 +++++++++++++++++++++ 4 files changed, 120 insertions(+), 3 deletions(-) create mode 100644 tests/spec/arb_direct_state_access/unmapnamedbuffer-vbo.c diff --git a/tests/all.py b/tests/all.py index f398afe82..fed3846d5 100644 --- a/tests/all.py +++ b/tests/all.py @@ -4244,6 +4244,7 @@ with profile.group_manager( g(['arb_direct_state_access-clearnamedbufferdata-invalid-internal-format'], 'clearnamedbufferdata-invalid-internal-format') g(['arb_direct_state_access-clearnamedbuffersubdata-invalid-size'], 'clearnamedbuffersubdata-invalid-size') g(['arb_direct_state_access-mapnamedbuffer-pbo-readpixels'], 'mapnamedbuffer-pbo-readpixels') + g(['arb_direct_state_access-unmapnamedbuffer-vbo'], 'unmapnamedbuffer-vbo') 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 b762b4fdf..a6a2eb38c 100644 --- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt +++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt @@ -20,6 +20,7 @@ piglit_add_executable (arb_direct_state_access-namedbuffersubdata-vbo-sync named piglit_add_executable (arb_direct_state_access-clearnamedbufferdata-invalid-internal-format clearnamedbufferdata-invalid-internal-format.c) piglit_add_executable (arb_direct_state_access-clearnamedbuffersubdata-invalid-size clearnamedbuffersubdata-invalid-size.c) piglit_add_executable (arb_direct_state_access-mapnamedbuffer-pbo-readpixels mapnamedbuffer-pbo-readpixels.c) +piglit_add_executable (arb_direct_state_access-unmapnamedbuffer-vbo unmapnamedbuffer-vbo.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/mapnamedbuffer-pbo-readpixels.c b/tests/spec/arb_direct_state_access/mapnamedbuffer-pbo-readpixels.c index 8d1a852a3..1d83eabe2 100644 --- a/tests/spec/arb_direct_state_access/mapnamedbuffer-pbo-readpixels.c +++ b/tests/spec/arb_direct_state_access/mapnamedbuffer-pbo-readpixels.c @@ -87,21 +87,21 @@ piglit_display(void) pass &= probe(1, 0, 0x0000ff00, addr[1]); pass &= probe(0, 1, 0x000000ff, addr[2]); pass &= probe(1, 1, 0x000000ff, addr[3]); - glUnmapBuffer(GL_PIXEL_PACK_BUFFER); + glUnmapNamedBuffer(pbo); /* Read with an offset. */ glReadPixels(1, 0, 1, 1, GL_BGRA, GL_UNSIGNED_BYTE, (void *)(uintptr_t)4); addr = glMapNamedBuffer(pbo, GL_READ_ONLY); pass &= probe(1, 0, 0x0000ff00, addr[1]); - glUnmapBuffer(GL_PIXEL_PACK_BUFFER); + glUnmapNamedBuffer(pbo); /* Read with an offset. */ glReadPixels(1, 1, 1, 1, GL_BGRA, GL_UNSIGNED_BYTE, (void *)(uintptr_t)4); addr = glMapNamedBuffer(pbo, GL_READ_ONLY); pass &= probe(1, 1, 0x000000ff, addr[1]); - glUnmapBuffer(GL_PIXEL_PACK_BUFFER); + glUnmapNamedBuffer(pbo); piglit_present_results(); diff --git a/tests/spec/arb_direct_state_access/unmapnamedbuffer-vbo.c b/tests/spec/arb_direct_state_access/unmapnamedbuffer-vbo.c new file mode 100644 index 000000000..8108ddaa4 --- /dev/null +++ b/tests/spec/arb_direct_state_access/unmapnamedbuffer-vbo.c @@ -0,0 +1,115 @@ +/* + * 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 + * + * Adapted to test glUnmapNamedBuffer by Laura Ekstrand + * , January 2015 + */ + +#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_ortho_projection(piglit_width, piglit_height, GL_FALSE); + + piglit_require_extension("GL_ARB_vertex_buffer_object"); + piglit_require_extension("GL_ARB_direct_state_access"); + + glCreateBuffers(1, &vbo); + glNamedBufferData(vbo, 12 * sizeof(GLfloat), NULL, GL_DYNAMIC_DRAW); +} + +static void +vbo_write_floats_mapped(const float *varray, size_t count) +{ + float *ptr = glMapNamedBuffer(vbo, GL_WRITE_ONLY); + + if (ptr == NULL) + piglit_report_result(PIGLIT_FAIL); + + memcpy(ptr, varray, count * sizeof(GLfloat)); + + if (!glUnmapNamedBuffer(vbo)) + piglit_report_result(PIGLIT_FAIL); +} + +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; + + glBindBuffer(GL_ARRAY_BUFFER, vbo); + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(3, GL_FLOAT, 0, 0); + + glBindBuffer(GL_ARRAY_BUFFER, 0); + vbo_write_floats_mapped(varray1, 12); + glBindBuffer(GL_ARRAY_BUFFER, vbo); + + glClear(GL_COLOR_BUFFER_BIT); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + glBindBuffer(GL_ARRAY_BUFFER, 0); + vbo_write_floats_mapped(varray2, 12); + 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; +} -- cgit v1.2.3