summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaura Ekstrand <laura@jlekstrand.net>2015-01-14 17:00:45 -0800
committerLaura Ekstrand <laura@jlekstrand.net>2015-03-09 16:20:43 -0700
commitb5e24db6c4353e6cc10fd317164fa7c960bf3765 (patch)
treecd67cf2ab3550733f8e65840ee17b9896b89c3f0
parent88844e81da2201add17af20421bb1cc9b02cc29c (diff)
arb_direct_state_access: Testing FlushMappedNamedBufferRange.
-rw-r--r--tests/all.py1
-rw-r--r--tests/spec/arb_direct_state_access/CMakeLists.gl.txt1
-rw-r--r--tests/spec/arb_direct_state_access/flushmappednamedbufferrange.c146
3 files changed, 148 insertions, 0 deletions
diff --git a/tests/all.py b/tests/all.py
index fed3846d5..f134f03ab 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4245,6 +4245,7 @@ with profile.group_manager(
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')
+ g(['arb_direct_state_access-flushmappednamedbufferrange'], 'flushmappednamedbufferrange')
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 a6a2eb38c..5b166d89b 100644
--- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
+++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
@@ -21,6 +21,7 @@ piglit_add_executable (arb_direct_state_access-clearnamedbufferdata-invalid-inte
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-flushmappednamedbufferrange flushmappednamedbufferrange.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/flushmappednamedbufferrange.c b/tests/spec/arb_direct_state_access/flushmappednamedbufferrange.c
new file mode 100644
index 000000000..4c8300a35
--- /dev/null
+++ b/tests/spec/arb_direct_state_access/flushmappednamedbufferrange.c
@@ -0,0 +1,146 @@
+/*
+ * Copyright © 2011, 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 Widawsky <ben@bwidawsk.net>
+ *
+ * Adapted to test glFlushMappedNamedBufferRange 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
+
+uint8_t data[1 << 20];
+
+enum piglit_result
+piglit_display(void)
+{
+ return PIGLIT_FAIL;
+}
+
+static bool
+verify_buffer(GLuint buffer, int offset, int length, void const *compare)
+{
+ int ret;
+ const void *ptr = glMapNamedBufferRange(buffer, offset, length,
+ GL_MAP_READ_BIT);
+ ret = memcmp(ptr, compare, length);
+ glUnmapNamedBuffer(buffer);
+
+ return ret == 0;
+}
+
+/*
+ * This test relies on simple patterns, so using offsets which are multiples
+ * of 0x100 is bad.
+ */
+void
+piglit_init(int argc, char *argv[])
+{
+ uint8_t *ptr;
+ uint8_t temp_data[100];
+ GLuint target, verify;
+ int i;
+ bool ret;
+
+ piglit_require_gl_version(15);
+
+ piglit_require_extension("GL_ARB_map_buffer_range");
+ piglit_require_extension("GL_ARB_direct_state_access");
+
+ for (i = 0; i < sizeof(data); i++) {
+ data[i] = i & 0xff;
+ }
+
+ for (i = 0; i < 100; i++) {
+ temp_data[i] = i;
+ }
+
+ glCreateBuffers(1, &target);
+ glCreateBuffers(1, &verify);
+ glNamedBufferData(target, sizeof(data), data, GL_STATIC_DRAW);
+ glNamedBufferData(verify, 0x1000, NULL, GL_STREAM_READ);
+
+ glGetError();
+
+ /* Validate that reads work, this is required for remaining ops */
+ ret = verify_buffer(target, 0x201, 100, &data[0x201]);
+ if (!ret)
+ piglit_report_result(PIGLIT_FAIL);
+
+ /* Test 1: test the invalidate range */
+ ptr = glMapNamedBufferRange(target, 0x10004, 100,
+ GL_MAP_WRITE_BIT |
+ GL_MAP_INVALIDATE_RANGE_BIT);
+ memcpy(ptr, temp_data, 100);
+ glUnmapNamedBuffer(target);
+ ret = verify_buffer(target, 0x10004, 100, temp_data);
+ if (!ret)
+ piglit_report_result(PIGLIT_FAIL);
+
+ /* Test 2: test unsynchronized writes */
+ ptr = glMapNamedBufferRange(target, 0x50f, 100,
+ GL_MAP_WRITE_BIT |
+ GL_MAP_UNSYNCHRONIZED_BIT);
+ memcpy(ptr, temp_data, 100);
+ glUnmapNamedBuffer(target);
+ ret = verify_buffer(target, 0x50f, 100, temp_data);
+ if (!ret)
+ piglit_report_result(PIGLIT_FAIL);
+
+ /* Test 3: test explicitly flushed unsynchronized writes
+ * 3a: Check if things are magically coherent (unmap doing more than it
+ * should */
+ ptr = glMapNamedBufferRange(target, 0xa002, 100,
+ GL_MAP_WRITE_BIT |
+ GL_MAP_FLUSH_EXPLICIT_BIT |
+ GL_MAP_UNSYNCHRONIZED_BIT);
+ memcpy(ptr, temp_data, 100);
+ glUnmapNamedBuffer(target);
+ glCopyNamedBufferSubData(target, verify, 0xa002, 0, 100);
+ ret = verify_buffer(verify, 0, 100, temp_data);
+ if (ret)
+ fprintf(stderr, "Coherent without flush\n");
+
+ /* 3b: test with flushed range */
+ ptr = glMapNamedBufferRange(target, 0xb002, 100,
+ GL_MAP_WRITE_BIT |
+ GL_MAP_FLUSH_EXPLICIT_BIT |
+ GL_MAP_UNSYNCHRONIZED_BIT);
+ memcpy(ptr, temp_data, 100);
+ glFlushMappedNamedBufferRange(target, 0xb002, 100);
+ glUnmapNamedBuffer(target);
+ glCopyNamedBufferSubData(target, verify, 0xb002, 100, 100);
+ ret = verify_buffer(verify, 100, 100, temp_data);
+ if (!ret)
+ piglit_report_result(PIGLIT_FAIL);
+
+ piglit_report_result(PIGLIT_PASS);
+}