diff options
author | Laura Ekstrand <laura@jlekstrand.net> | 2015-01-20 13:50:48 -0800 |
---|---|---|
committer | Laura Ekstrand <laura@jlekstrand.net> | 2015-04-02 17:57:41 -0700 |
commit | 69a768fded126d1de75288d44921753c2110610f (patch) | |
tree | 22a1e5fcb78c8b8853261fa36b15d624803531c8 | |
parent | 022881cc1b58512575782cad552259075ab76e97 (diff) |
arb_direct_state_access: Testing glGetNamedBufferParameteri[64]v and
GetNamedBufferPointerv.
-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/getnamedbufferparameter.c | 223 |
3 files changed, 225 insertions, 0 deletions
diff --git a/tests/all.py b/tests/all.py index 06b1ee3ee..917b87559 100644 --- a/tests/all.py +++ b/tests/all.py @@ -4247,6 +4247,7 @@ with profile.group_manager( g(['arb_direct_state_access-mapnamedbuffer-pbo-readpixels'], 'mapnamedbuffer-pbo-readpixels') g(['arb_direct_state_access-unmapnamedbuffer-vbo'], 'unmapnamedbuffer-vbo') g(['arb_direct_state_access-flushmappednamedbufferrange'], 'flushmappednamedbufferrange') + g(['arb_direct_state_access-getnamedbufferparameter'], 'getnamedbufferparameter') 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 dcb2c81ee..bfc62a8ea 100644 --- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt +++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt @@ -23,6 +23,7 @@ piglit_add_executable (arb_direct_state_access-clearnamedbuffersubdata-invalid-s 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-flushmappednamedbufferrange flushmappednamedbufferrange.c) +piglit_add_executable (arb_direct_state_access-getnamedbufferparameter getnamedbufferparameter.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/getnamedbufferparameter.c b/tests/spec/arb_direct_state_access/getnamedbufferparameter.c new file mode 100644 index 000000000..45fc021cb --- /dev/null +++ b/tests/spec/arb_direct_state_access/getnamedbufferparameter.c @@ -0,0 +1,223 @@ +/** + * Copyright © 2013, 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. + */ + +/** + * Adapted to test glGetNamedBufferParameteri[64]v and + * glGetNamedBufferPointerv by Laura Ekstrand <laura@jlekstrand.net>, January + * 2015. + */ + +#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 + +void +piglit_init(int argc, char **argv) +{ + piglit_require_extension("GL_ARB_direct_state_access"); + piglit_require_extension("GL_ARB_map_buffer_range"); +} + +static bool +storage_test(void) +{ + GLuint buffer; + bool pass = true; + GLint64 data = -2; + + glCreateBuffers(1, &buffer); + + /* Is it mutable? */ + glGetNamedBufferParameteri64v(buffer, GL_BUFFER_IMMUTABLE_STORAGE, + &data); + if (data == GL_TRUE) { + printf("GL_BUFFER_IMMUTABLE_STORAGE: expected mutable, " + "got immutable.\n"); + pass = false; + } + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + + glNamedBufferStorage(buffer, 12 * 4 * sizeof(float), NULL, + GL_MAP_READ_BIT | + GL_MAP_PERSISTENT_BIT | + GL_MAP_COHERENT_BIT); + + /* Is it immutable? */ + glGetNamedBufferParameteri64v(buffer, GL_BUFFER_IMMUTABLE_STORAGE, + &data); + if (data == GL_FALSE) { + printf("GL_BUFFER_IMMUTABLE_STORAGE: expected immutable, " + "got mutable.\n"); + pass = false; + } + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + + /* What are the storage flags? */ + glGetNamedBufferParameteri64v(buffer, GL_BUFFER_STORAGE_FLAGS, + &data); + if (!(data & GL_MAP_READ_BIT)) { + printf("GL_BUFFER_STORAGE_FLAGS: No map read bit.\n"); + pass = false; + } + if (!(data & GL_MAP_PERSISTENT_BIT)) { + printf("GL_BUFFER_STORAGE_FLAGS: No map persistent bit.\n"); + pass = false; + } + if (!(data & GL_MAP_COHERENT_BIT)) { + printf("GL_BUFFER_STORAGE_FLAGS: No map coherent bit.\n"); + pass = false; + } + + if (data & ~(GL_MAP_READ_BIT | + GL_MAP_PERSISTENT_BIT | + GL_MAP_COHERENT_BIT)) { + printf("GL_BUFFER_STORAGE_FLAGS: Extra bits set.\n"); + pass = false; + } + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + + return pass; +} + +enum piglit_result +piglit_display(void) +{ + bool pass = true; + GLuint bufname; + GLint64 data = -2; + void *dataptr = NULL; + GLint dataint = -2; + + int stuff[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + int size = sizeof(stuff); + int offset = 1; + int range = 5; + + glCreateBuffers(1, &bufname); + glNamedBufferData(bufname, size, stuff, GL_STATIC_READ); + + /* What size is it? */ + glGetNamedBufferParameteri64v(bufname, GL_BUFFER_SIZE, &data); + if (data != size) { + printf("GL_BUFFER_SIZE: expected %d, got %d.\n", + size, (int) data); + pass = false; + } + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + + /* What is the usage? */ + glGetNamedBufferParameteri64v(bufname, GL_BUFFER_USAGE, &data); + if (data != GL_STATIC_READ) { + printf("GL_BUFFER_USAGE: expected GL_STATIC_READ, got %s.\n", + piglit_get_gl_enum_name((int) data)); + pass = false; + } + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + + + glMapNamedBufferRange(bufname, offset, range, + GL_MAP_READ_BIT); + + /* What is the access? */ + glGetNamedBufferParameteri64v(bufname, GL_BUFFER_ACCESS, &data); + if (data != GL_READ_ONLY) { + printf("GL_BUFFER_ACCESS: expected GL_READ_ONLY, got %s.\n", + piglit_get_gl_enum_name((int) data)); + pass = false; + } + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + + /* What are the access flags? */ + glGetNamedBufferParameteri64v(bufname, GL_BUFFER_ACCESS_FLAGS, &data); + if (!(data & GL_MAP_READ_BIT)) { /* Map read bit not set */ + printf("GL_BUFFER_ACCESS_FLAGS: expected GL_MAP_READ_BIT, " + "but it was not set.\n"); + pass = false; + } + if (data & ~GL_MAP_READ_BIT) { /* Other bits set */ + printf("GL_BUFFER_ACCESS: expected only GL_MAP_READ_BIT, " + "but other flags were set.\n"); + pass = false; + } + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + + /* Is it mapped? */ + glGetNamedBufferParameteri64v(bufname, GL_BUFFER_MAPPED, &data); + if (data != GL_TRUE) { + printf("GL_BUFFER_MAPPED: expected GL_TRUE, got GL_FALSE.\n"); + pass = false; + } + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + + /* Check the pointer. */ + glGetNamedBufferPointerv(bufname, GL_BUFFER_MAP_POINTER, &dataptr); + if (!dataptr) { + printf("GL_BUFFER_MAP_POINTER: Got NULL.\n"); + pass = false; + } + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + + /* What is the offset? */ + glGetNamedBufferParameteri64v(bufname, GL_BUFFER_MAP_OFFSET, + &data); + if (data != offset) { + printf("GL_BUFFER_MAP_OFFSET: expected %d, got %d.\n", + offset, (int) data); + pass = false; + } + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + + /* What is the length? */ + glGetNamedBufferParameteri64v(bufname, GL_BUFFER_MAP_LENGTH, + &data); + if (data != range) { + printf("GL_BUFFER_MAP_LENGTH: expected %d, got %d.\n", + range, (int) data); + pass = false; + } + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + + glUnmapNamedBuffer(bufname); + + if (piglit_is_extension_supported("GL_ARB_buffer_storage")) + pass = storage_test() && pass; + + + /* Make sure 32-bit version works. */ + glGetNamedBufferParameteriv(bufname, GL_BUFFER_SIZE, &dataint); + if (dataint != size) { + printf("GL_BUFFER_SIZE: expected %d, got %d.\n", + size, (int) dataint); + pass = false; + } + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; + + + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); +} |