From: Marek Olšák <marek.ol...@amd.com> I hacked up the glapi support, because spec files with this extension don't exist. --- glapi/enumext.spec | 5 + glapi/gl.spec | 19 ++ tests/all.py | 11 ++ tests/spec/CMakeLists.txt | 1 + tests/spec/arb_buffer_storage/CMakeLists.gl.txt | 12 ++ tests/spec/arb_buffer_storage/CMakeLists.txt | 1 + tests/spec/arb_buffer_storage/bufferstorage.c | 228 ++++++++++++++++++++++++ 7 files changed, 277 insertions(+) create mode 100644 tests/spec/arb_buffer_storage/CMakeLists.gl.txt create mode 100644 tests/spec/arb_buffer_storage/CMakeLists.txt create mode 100644 tests/spec/arb_buffer_storage/bufferstorage.c
diff --git a/glapi/enumext.spec b/glapi/enumext.spec index c08024f..d1ae5ea 100644 --- a/glapi/enumext.spec +++ b/glapi/enumext.spec @@ -2909,6 +2909,10 @@ ARB_map_buffer_range enum: MAP_INVALIDATE_BUFFER_BIT = 0x0008 MAP_FLUSH_EXPLICIT_BIT = 0x0010 MAP_UNSYNCHRONIZED_BIT = 0x0020 + MAP_PERSISTENT_BIT = 0x0040 + MAP_COHERENT_BIT = 0x0080 + DYNAMIC_STORAGE_BIT = 0x0100 + CLIENT_STORAGE_BIT = 0x0200 ############################################################################### @@ -3603,6 +3607,7 @@ ARB_shader_image_load_store enum: FRAMEBUFFER_BARRIER_BIT = 0x00000400 TRANSFORM_FEEDBACK_BARRIER_BIT = 0x00000800 ATOMIC_COUNTER_BARRIER_BIT = 0x00001000 + CLIENT_MAPPED_BUFFER_BARRIER_BIT = 0x00004000 ALL_BARRIER_BITS = 0xFFFFFFFF MAX_IMAGE_UNITS = 0x8F38 MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS = 0x8F39 diff --git a/glapi/gl.spec b/glapi/gl.spec index 25d0ba7..a8fcc44 100644 --- a/glapi/gl.spec +++ b/glapi/gl.spec @@ -35888,3 +35888,22 @@ DrawTextureNV(texture, sampler, x0, y0, x1, y1, z, s0, t0, s1, t1) glxropcode ? glxflags ignore offset ? + +############################################################################### +# +# ARB_buffer_storage commands +# +############################################################################### + +BufferStorage(target, size, data, flags) + return void + param target BufferTargetARB in value + param size BufferSize in value + param data ConstVoid in array [size] + param flags GLbitfield in value + category ARB_buffer_storage + version 4.4 + extension + glxropcode ? + glxflags ignore + offset ? diff --git a/tests/all.py b/tests/all.py index 2070f35..7408c43 100644 --- a/tests/all.py +++ b/tests/all.py @@ -3077,6 +3077,17 @@ arb_base_instance = Group() spec['ARB_base_instance'] = arb_base_instance add_plain_test(arb_base_instance, 'arb_base_instance-baseinstance-doesnt-affect-gl-instance-id') +arb_buffer_storage = Group() +spec['ARB_buffer_storage'] = arb_buffer_storage +add_concurrent_test(arb_buffer_storage, 'bufferstorage-persistent draw') +add_concurrent_test(arb_buffer_storage, 'bufferstorage-persistent draw coherent') +add_concurrent_test(arb_buffer_storage, 'bufferstorage-persistent draw client-storage') +add_concurrent_test(arb_buffer_storage, 'bufferstorage-persistent draw coherent client-storage') +add_concurrent_test(arb_buffer_storage, 'bufferstorage-persistent read') +add_concurrent_test(arb_buffer_storage, 'bufferstorage-persistent read coherent') +add_concurrent_test(arb_buffer_storage, 'bufferstorage-persistent read client-storage') +add_concurrent_test(arb_buffer_storage, 'bufferstorage-persistent read coherent client-storage') + apple_object_purgeable = Group() spec['APPLE_object_purgeable'] = apple_object_purgeable add_plain_test(apple_object_purgeable, 'object_purgeable-api-pbo') diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt index 8a8ec90..c83a64b 100644 --- a/tests/spec/CMakeLists.txt +++ b/tests/spec/CMakeLists.txt @@ -1,5 +1,6 @@ add_subdirectory (amd_performance_monitor) add_subdirectory (arb_base_instance) +add_subdirectory (arb_buffer_storage) add_subdirectory (arb_color_buffer_float) add_subdirectory (arb_compute_shader) add_subdirectory (arb_debug_output) diff --git a/tests/spec/arb_buffer_storage/CMakeLists.gl.txt b/tests/spec/arb_buffer_storage/CMakeLists.gl.txt new file mode 100644 index 0000000..9579cce --- /dev/null +++ b/tests/spec/arb_buffer_storage/CMakeLists.gl.txt @@ -0,0 +1,12 @@ +include_directories( + ${GLEXT_INCLUDE_DIR} + ${OPENGL_INCLUDE_PATH} +) + +link_libraries ( + piglitutil_${piglit_target_api} + ${OPENGL_gl_LIBRARY} + ${OPENGL_glu_LIBRARY} +) + +piglit_add_executable (bufferstorage-persistent bufferstorage.c) diff --git a/tests/spec/arb_buffer_storage/CMakeLists.txt b/tests/spec/arb_buffer_storage/CMakeLists.txt new file mode 100644 index 0000000..144a306 --- /dev/null +++ b/tests/spec/arb_buffer_storage/CMakeLists.txt @@ -0,0 +1 @@ +piglit_include_target_api() diff --git a/tests/spec/arb_buffer_storage/bufferstorage.c b/tests/spec/arb_buffer_storage/bufferstorage.c new file mode 100644 index 0000000..f054f17 --- /dev/null +++ b/tests/spec/arb_buffer_storage/bufferstorage.c @@ -0,0 +1,228 @@ +/* + * Copyright © 2014 Advanced Micro Devices, Inc. + * All rights reserved. + * + * 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: + * Marek Olšák <marek.ol...@amd.com> + */ + +/** + * This tests GL_MAP_PERSISTENT_BIT and glBufferStorage + * from ARB_buffer_storage. + */ + +#include "piglit-util-gl-common.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 + +enum test_flag { + NONE, + READ, + DRAW +}; + +static GLuint buffer; +static GLfloat *map; +static GLboolean coherent, client_storage; +static enum test_flag test = NONE; + +#define BUF_SIZE (12 * 4 * sizeof(float)) + +void +piglit_init(int argc, char **argv) +{ + int i; + + for (i = 1; i < argc; i++) { + if (!strcmp(argv[i], "coherent")) { + coherent = GL_TRUE; + continue; + } + if (!strcmp(argv[i], "read")) { + test = READ; + continue; + } + if (!strcmp(argv[i], "draw")) { + test = DRAW; + continue; + } + if (!strcmp(argv[i], "client-storage")) { + client_storage = GL_TRUE; + continue; + } + + printf("Unknown param: %s\n", argv[i]); + piglit_report_result(PIGLIT_FAIL); + } + + if (test == NONE) { + puts("Wrong parameters."); + piglit_report_result(PIGLIT_FAIL); + } + + piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE); + + piglit_require_gl_version(15); + piglit_require_extension("GL_ARB_buffer_storage"); + piglit_require_extension("GL_ARB_map_buffer_range"); + if (test == READ) { + piglit_require_extension("GL_ARB_copy_buffer"); + piglit_require_extension("GL_ARB_sync"); + } + if (!coherent) { /* for MemoryBarrier */ + piglit_require_extension("GL_ARB_shader_image_load_store"); + } + + glGenBuffers(1, &buffer); + glBindBuffer(GL_ARRAY_BUFFER, buffer); + glBufferStorage(GL_ARRAY_BUFFER, BUF_SIZE, NULL, + GL_MAP_WRITE_BIT | + GL_MAP_PERSISTENT_BIT | + (coherent ? GL_MAP_COHERENT_BIT : 0) | + GL_DYNAMIC_STORAGE_BIT | + (client_storage ? GL_CLIENT_STORAGE_BIT : 0)); + + piglit_check_gl_error(GL_NO_ERROR); + + map = glMapBufferRange(GL_ARRAY_BUFFER, 0, BUF_SIZE, + GL_MAP_WRITE_BIT | + GL_MAP_PERSISTENT_BIT | + (coherent ? GL_MAP_COHERENT_BIT : 0)); + + piglit_check_gl_error(GL_NO_ERROR); + + if (!map) + piglit_report_result(PIGLIT_FAIL); + + glBindBuffer(GL_ARRAY_BUFFER, 0); +} + +enum piglit_result +piglit_display(void) +{ + float white[4] = {1.0, 1.0, 1.0, 0.0}; + GLboolean pass = GL_TRUE; + int i; + float array[] = { + 17, 13, 0, + 17, 18, 0, + 12, 13, 0, + 12, 18, 0, + 27, 13, 0, + 27, 18, 0, + 22, 13, 0, + 22, 18, 0, + 37, 13, 0, + 37, 18, 0, + 32, 13, 0, + 32, 18, 0, + 47, 13, 0, + 47, 18, 0, + 42, 13, 0, + 42, 18, 0 + }; + + glClear(GL_COLOR_BUFFER_BIT); + + if (test == DRAW) { + glEnableClientState(GL_VERTEX_ARRAY); + glBindBuffer(GL_ARRAY_BUFFER, buffer); + glVertexPointer(3, GL_FLOAT, 0, 0); + glBindBuffer(GL_ARRAY_BUFFER, 0); + + memcpy(map, array, 12 * sizeof(float)); + if (!coherent) + glMemoryBarrier(GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + + memcpy(map+12, array+12, 12 * sizeof(float)); + if (!coherent) + glMemoryBarrier(GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT); + + glDrawArrays(GL_TRIANGLE_STRIP, 4, 4); + + memcpy(map+12*2, array+12*2, 12 * sizeof(float)); + if (!coherent) + glMemoryBarrier(GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT); + + glDrawArrays(GL_TRIANGLE_STRIP, 8, 4); + + memcpy(map+12*3, array+12*3, 12 * sizeof(float)); + if (!coherent) + glMemoryBarrier(GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT); + + glDrawArrays(GL_TRIANGLE_STRIP, 12, 4); + + piglit_check_gl_error(0); + + pass = pass && piglit_probe_pixel_rgb(15, 15, white); + pass = pass && piglit_probe_pixel_rgb(25, 15, white); + pass = pass && piglit_probe_pixel_rgb(35, 15, white); + pass = pass && piglit_probe_pixel_rgb(45, 15, white); + + glDisableClientState(GL_VERTEX_ARRAY); + } + else if (test == READ) { + GLuint srcbuf; + GLsync fence; + + glGenBuffers(1, &srcbuf); + glBindBuffer(GL_COPY_READ_BUFFER, srcbuf); + glBufferData(GL_COPY_READ_BUFFER, BUF_SIZE, array, GL_STATIC_DRAW); + + /* Copy some data to the mapped buffer and check if the CPU can see it. */ + glBindBuffer(GL_COPY_WRITE_BUFFER, buffer); + glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, + 0, 0, BUF_SIZE); + + glBindBuffer(GL_COPY_READ_BUFFER, 0); + glBindBuffer(GL_COPY_WRITE_BUFFER, 0); + glDeleteBuffers(1, &srcbuf); + + if (!coherent) + glMemoryBarrier(GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT); + + fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + glClientWaitSync(fence, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED); + + for (i = 0; i < ARRAY_SIZE(array); i++) { + if (map[i] != array[i]) { + printf("Probe [%i] failed. Expected: %f Observed: %f\n", + i, array[i], map[i]); + pass = GL_FALSE; + } + } + } + else { + assert(0); + } + + piglit_present_results(); + + return pass ? PIGLIT_PASS : PIGLIT_FAIL; +} -- 1.8.3.2 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit