[Piglit] [PATCH 12/15] arb_direct_state_access: Testing FlushMappedNamedBufferRange.

Laura Ekstrand laura at jlekstrand.net
Fri Jan 23 11:03:36 PST 2015


---
 tests/all.py                                       |   1 +
 .../spec/arb_direct_state_access/CMakeLists.gl.txt |   1 +
 .../flushmappednamedbufferrange.c                  | 112 +++++++++++++++++++++
 3 files changed, 114 insertions(+)
 create mode 100644 tests/spec/arb_direct_state_access/flushmappednamedbufferrange.c

diff --git a/tests/all.py b/tests/all.py
index e7d0843..c146bff 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4428,6 +4428,7 @@ spec['ARB_direct_state_access']['clearnamedbufferdata-invalid-internal-format']
 spec['ARB_direct_state_access']['clearnamedbuffersubdata-invalid-size'] = PiglitGLTest(['arb_direct_state_access-clearnamedbuffersubdata-invalid-size'], run_concurrent=True)
 spec['ARB_direct_state_access']['mapnamedbuffer-pbo-readpixels'] = PiglitGLTest(['arb_direct_state_access-mapnamedbuffer-pbo-readpixels'], run_concurrent=True)
 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)
 
 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 d0b92aa..3523e5d 100644
--- a/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
+++ b/tests/spec/arb_direct_state_access/CMakeLists.gl.txt
@@ -15,6 +15,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 0000000..39ef0b6
--- /dev/null
+++ b/tests/spec/arb_direct_state_access/flushmappednamedbufferrange.c
@@ -0,0 +1,112 @@
+/*
+ * 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 at bwidawsk.net>
+ *
+ * Adapted to test glFlushMappedNamedBufferRange by Laura Ekstrand
+ * <laura at 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);
+
+	/* 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);
+}
-- 
2.1.0



More information about the Piglit mailing list