summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaura Ekstrand <laura@jlekstrand.net>2015-01-20 15:23:40 -0800
committerLaura Ekstrand <laura@jlekstrand.net>2015-04-02 17:57:41 -0700
commitbf9c7a881f23ae5b270e710066b6d10f310c5293 (patch)
tree15de2ddb750dc18a438add6d2b58c3a7a0bc95d0
parent69a768fded126d1de75288d44921753c2110610f (diff)
arb_direct_state_access: Testing glGetNamedBufferSubData.
-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/getnamedbuffersubdata.c112
3 files changed, 114 insertions, 0 deletions
diff --git a/tests/all.py b/tests/all.py
index 917b87559..64e582746 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4248,6 +4248,7 @@ with profile.group_manager(
g(['arb_direct_state_access-unmapnamedbuffer-vbo'], 'unmapnamedbuffer-vbo')
g(['arb_direct_state_access-flushmappednamedbufferrange'], 'flushmappednamedbufferrange')
g(['arb_direct_state_access-getnamedbufferparameter'], 'getnamedbufferparameter')
+ g(['arb_direct_state_access-getnamedbuffersubdata'], 'getnamedbuffersubdata')
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 bfc62a8ea..ae79f8838 100644
--- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
+++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
@@ -24,6 +24,7 @@ piglit_add_executable (arb_direct_state_access-mapnamedbuffer-pbo-readpixels map
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-getnamedbuffersubdata getnamedbuffersubdata.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/getnamedbuffersubdata.c b/tests/spec/arb_direct_state_access/getnamedbuffersubdata.c
new file mode 100644
index 000000000..2837c2ef1
--- /dev/null
+++ b/tests/spec/arb_direct_state_access/getnamedbuffersubdata.c
@@ -0,0 +1,112 @@
+/*
+ * 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.
+ */
+
+/** @file getnamedbuffersubdata.c
+ *
+ * Tests that glBufferSubData() synchronizes correctly with
+ * glCopyBufferSubData().
+ *
+ * We make sure that a subdata over the read buffer after the copy has
+ * no effect, while a subdata over the write buffer after the copy
+ * does have an effect.
+ *
+ * Adapted to test glGetNamedBufferSubData by Laura Ekstrand
+ * <laura@jlekstrand.net>, January 2015.
+ */
+
+#include "piglit-util-gl.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_compat_version = 15;
+ config.supports_gl_core_version = 31;
+
+ 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_copy_buffer");
+}
+
+enum piglit_result
+piglit_display(void)
+{
+ bool pass = true;
+ uint32_t dummy_data_1[4], dummy_data_2[4];
+ uint32_t good_data[4] = {0, 1, 2, 3};
+ uint32_t result_data[4];
+ bool subtest_pass;
+ size_t size = sizeof(good_data);
+ GLuint read_buffer, write_buffer;
+
+ memset(dummy_data_1, 0xaa, size);
+ memset(dummy_data_2, 0xbb, size);
+
+ glCreateBuffers(1, &read_buffer);
+ glCreateBuffers(1, &write_buffer);
+
+ glNamedBufferData(read_buffer, 4096, NULL, GL_STREAM_COPY);
+ glNamedBufferData(write_buffer, 4096, NULL, GL_STREAM_COPY);
+ glNamedBufferSubData(read_buffer, 0, size, good_data);
+ glNamedBufferSubData(write_buffer, 0, size, dummy_data_1);
+
+ glCopyNamedBufferSubData(read_buffer, write_buffer, 0, 0, size);
+ glNamedBufferSubData(read_buffer, 0, size, dummy_data_2);
+ memset(result_data, 0xd0, size);
+ glGetNamedBufferSubData(write_buffer, 0, size, result_data);
+ subtest_pass = memcmp(good_data, result_data, size) == 0;
+ if (!subtest_pass) {
+ fprintf(stderr, "found 0x%08x 0x%08x 0x%08x 0x%08x\n",
+ result_data[0], result_data[1],
+ result_data[2], result_data[3]);
+ pass = false;
+ }
+ piglit_report_subtest_result(subtest_pass ? PIGLIT_PASS : PIGLIT_FAIL,
+ "overwrite source data");
+
+
+ glNamedBufferData(read_buffer, 4096, NULL, GL_STREAM_COPY);
+ glNamedBufferData(write_buffer, 4096, NULL, GL_STREAM_COPY);
+ glNamedBufferSubData(read_buffer, 0, size, dummy_data_1);
+ glNamedBufferSubData(write_buffer, 0, size, dummy_data_2);
+
+ glCopyNamedBufferSubData(read_buffer, write_buffer, 0, 0, size);
+ glNamedBufferSubData(write_buffer, 0, size, good_data);
+ memset(result_data, 0xd0, size);
+ glGetNamedBufferSubData(write_buffer, 0, size, result_data);
+ subtest_pass = memcmp(good_data, result_data, size) == 0;
+ if (!subtest_pass) {
+ fprintf(stderr, "found 0x%08x 0x%08x 0x%08x 0x%08x\n",
+ result_data[0], result_data[1],
+ result_data[2], result_data[3]);
+ pass = false;
+ }
+ piglit_report_subtest_result(subtest_pass ? PIGLIT_PASS : PIGLIT_FAIL,
+ "overwrite destination data");
+
+ piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}