--- tests/all.py | 1 + .../spec/arb_direct_state_access/CMakeLists.gl.txt | 1 + .../mapnamedbuffer-pbo-readpixels.c | 120 +++++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 tests/spec/arb_direct_state_access/mapnamedbuffer-pbo-readpixels.c
diff --git a/tests/all.py b/tests/all.py index dee8b3b..76c4070 100644 --- a/tests/all.py +++ b/tests/all.py @@ -4426,6 +4426,7 @@ spec['ARB_direct_state_access']['namedbufferstorage-persistent'] = PiglitGLTest( spec['ARB_direct_state_access']['namedbuffersubdata-vbo-sync'] = PiglitGLTest(['arb_direct_state_access-namedbuffersubdata-vbo-sync'], run_concurrent=True) spec['ARB_direct_state_access']['clearnamedbufferdata-invalid-internal-format'] = PiglitGLTest(['arb_direct_state_access-clearnamedbufferdata-invalid-internal-format'], run_concurrent=True) spec['ARB_direct_state_access']['clearnamedbuffersubdata-invalid-size'] = PiglitGLTest(['arb_direct_state_access-clearnamedbuffersubdata-invalid-size'], run_concurrent=True) +spec['ARB_direct_state_access']['mapnamedbuffer-pbo-readpixels'] = PiglitGLTest(['arb_direct_state_access-mapnamedbuffer-pbo-readpixels'], run_concurrent=True) profile.tests['hiz'] = hiz profile.tests['fast_color_clear'] = fast_color_clear diff --git a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt index 3afd698..37396e4 100644 --- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt +++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt @@ -13,6 +13,7 @@ piglit_add_executable (arb_direct_state_access-namedbufferstorage-persistent nam piglit_add_executable (arb_direct_state_access-namedbuffersubdata-vbo-sync namedbuffersubdata-vbo-sync.c) 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-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 new file mode 100644 index 0000000..6e94a96 --- /dev/null +++ b/tests/spec/arb_direct_state_access/mapnamedbuffer-pbo-readpixels.c @@ -0,0 +1,120 @@ +/* + * 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: + * Eric Anholt <[email protected]> + * + * Adapted to test MapNamedBuffer by Laura Ekstrand <[email protected]>, + * January 2015. + */ + +/** @file mapnamedbuffer-pbo-readpixels.c + * + * Tests that reading 2x2 BGRA UNSIGNED_BYTE buffers work correctly. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 10; + config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE; + +PIGLIT_GL_TEST_CONFIG_END + +static GLboolean +probe(int x, int y, uint32_t expected, uint32_t observed) +{ + if ((expected & 0xffffff) != (observed & 0xffffff)) { + printf("Probe color at (%i,%i)\n", x, y); + printf(" Expected: 0x%08x\n", expected); + printf(" Observed: 0x%08x\n", observed); + + return GL_FALSE; + } else { + return GL_TRUE; + } +} + +enum piglit_result +piglit_display(void) +{ + GLboolean pass = GL_TRUE; + uint32_t *addr; + GLuint pbo; + + glClearColor(0.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + glCreateBuffers(1, &pbo); + glNamedBufferData(pbo, 4 * 4, NULL, GL_STREAM_DRAW); + glPixelStorei(GL_PACK_ALIGNMENT, 1); + + glViewport(0, 0, 2, 2); + piglit_ortho_projection(2, 2, GL_FALSE); + glBindBuffer(GL_PIXEL_PACK_BUFFER, pbo); + + /* bottom: green. top: blue. */ + glColor4f(0.0, 1.0, 0.0, 0.0); + piglit_draw_rect(0, 0, 2, 1); + glColor4f(0.0, 0.0, 1.0, 0.0); + piglit_draw_rect(0, 1, 2, 1); + + /* Read the whole buffer. */ + glReadPixels(0, 0, 2, 2, + GL_BGRA, GL_UNSIGNED_BYTE, (void *)(uintptr_t)0); + addr = glMapNamedBuffer(pbo, GL_READ_ONLY); + pass &= probe(0, 0, 0x0000ff00, addr[0]); + 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); + + /* 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); + + /* 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); + + piglit_present_results(); + + glDeleteBuffers(1, &pbo); + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} + + +void +piglit_init(int argc, char **argv) +{ + piglit_require_extension("GL_ARB_pixel_buffer_object"); + piglit_require_extension("GL_ARB_direct_state_access"); + piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); +} -- 2.1.0 _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
