[Piglit] [PATCH] map_buffer_range_test: add tests to reproduce u_threaded & radeonsi bugs
Marek Olšák
maraeo at gmail.com
Wed Feb 6 21:12:23 UTC 2019
From: Marek Olšák <marek.olsak at amd.com>
---
.../map_buffer_range_test.c | 39 +++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/tests/spec/arb_map_buffer_range/map_buffer_range_test.c b/tests/spec/arb_map_buffer_range/map_buffer_range_test.c
index 2f5d2a39d..80d0afbdd 100644
--- a/tests/spec/arb_map_buffer_range/map_buffer_range_test.c
+++ b/tests/spec/arb_map_buffer_range/map_buffer_range_test.c
@@ -48,20 +48,33 @@ piglit_display(void)
static bool
verify_buffer(GLenum target, int offset, int length, void const *compare) {
int ret;
const void *ptr = glMapBufferRange(target, offset, length, GL_MAP_READ_BIT);
ret = memcmp(ptr, compare, length);
glUnmapBuffer(target);
return ret == 0;
}
+static void
+clear_buffer(GLenum target)
+{
+ if (piglit_is_extension_supported("GL_ARB_clear_buffer_object")) {
+ /* Clear the buffer just to make the device busy, so that
+ * the driver can't optimize MapBufferRange to unsychronized
+ * without explicit_flush.
+ */
+ int zero = 0;
+ glClearBufferData(target, GL_R32I, GL_RED_INTEGER, GL_INT, &zero);
+ }
+}
+
/* This test relies on simple patterns, so using offets which are multiples of
* 0x100 is bad
*/
void
piglit_init(int argc, char *argv[])
{
uint8_t *ptr;
uint8_t temp_data[100];
GLenum target = GL_ARRAY_BUFFER;
GLenum verify = GL_COPY_WRITE_BUFFER;
@@ -130,12 +143,38 @@ piglit_init(int argc, char *argv[])
GL_MAP_FLUSH_EXPLICIT_BIT |
GL_MAP_UNSYNCHRONIZED_BIT);
memcpy(ptr, temp_data, 100);
glFlushMappedBufferRange(target, 0x0, 100);
glUnmapBuffer(target);
glCopyBufferSubData(target, verify, 0xa002, 100, 100);
ret = verify_buffer(verify, 100, 100, temp_data);
if (!ret)
piglit_report_result(PIGLIT_FAIL);
+ /* 3c: test with flushed range, invalidate range */
+ clear_buffer(target);
+ ptr = glMapBufferRange(target, 0xa002, 100, GL_MAP_WRITE_BIT |
+ GL_MAP_FLUSH_EXPLICIT_BIT |
+ GL_MAP_INVALIDATE_RANGE_BIT);
+ memcpy(ptr, temp_data, 100);
+ glFlushMappedBufferRange(target, 0x0, 100);
+ glUnmapBuffer(target);
+ glCopyBufferSubData(target, verify, 0xa002, 100, 100);
+ ret = verify_buffer(verify, 100, 100, temp_data);
+ if (!ret)
+ piglit_report_result(PIGLIT_FAIL);
+
+ /* 3d: test with flushed range, invalidate range, non-zero flush offset */
+ clear_buffer(target);
+ ptr = glMapBufferRange(target, 0xa002 - 4, 104, GL_MAP_WRITE_BIT |
+ GL_MAP_FLUSH_EXPLICIT_BIT |
+ GL_MAP_INVALIDATE_RANGE_BIT);
+ memcpy(ptr + 4, temp_data, 100);
+ glFlushMappedBufferRange(target, 0x4, 100);
+ glUnmapBuffer(target);
+ glCopyBufferSubData(target, verify, 0xa002, 100, 100);
+ ret = verify_buffer(verify, 100, 100, temp_data);
+ if (!ret)
+ piglit_report_result(PIGLIT_FAIL);
+
piglit_report_result(PIGLIT_PASS);
}
--
2.17.1
More information about the Piglit
mailing list