[Piglit] [PATCH 15/15] arb_direct_state_access: Testing glGetNamedBufferSubData.
Laura Ekstrand
laura at jlekstrand.net
Fri Jan 23 11:03:39 PST 2015
---
tests/all.py | 1 +
.../spec/arb_direct_state_access/CMakeLists.gl.txt | 1 +
.../getnamedbuffersubdata.c | 112 +++++++++++++++++++++
3 files changed, 114 insertions(+)
create mode 100644 tests/spec/arb_direct_state_access/getnamedbuffersubdata.c
diff --git a/tests/all.py b/tests/all.py
index 3d41046..a53e268 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4430,6 +4430,7 @@ spec['ARB_direct_state_access']['mapnamedbuffer-pbo-readpixels'] = PiglitGLTest(
spec['ARB_direct_state_access']['unmapnamedbuffer-vbo'] = PiglitGLTest(['arb_direct_state_access-unmapnamedbuffer-vbo'], run_concurrent=True)
spec['ARB_direct_state_access']['flushmappednamedbufferrange'] = PiglitGLTest(['arb_direct_state_access-flushmappednamedbufferrange'], run_concurrent=True)
spec['ARB_direct_state_access']['getnamedbufferparameter'] = PiglitGLTest(['arb_direct_state_access-getnamedbufferparameter'], run_concurrent=True)
+spec['ARB_direct_state_access']['getnamedbuffersubdata'] = PiglitGLTest(['arb_direct_state_access-getnamedbuffersubdata'], 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 cd14397..d839af7 100644
--- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
+++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
@@ -17,6 +17,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 0000000..2837c2e
--- /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 at 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);
+}
--
2.1.0
More information about the Piglit
mailing list