map_buffer_range_test: add tests to reproduce u_threaded & radeonsi bugs

Submitted by Marek Olšák on Feb. 6, 2019, 9:12 p.m.

Details

Message ID 20190206211223.3950-1-maraeo@gmail.com
State New
Headers show
Series "map_buffer_range_test: add tests to reproduce u_threaded & radeonsi bugs" ( rev: 1 ) in Piglit

Not browsing as part of any series.

Commit Message

Marek Olšák Feb. 6, 2019, 9:12 p.m.
From: Marek Olšák <marek.olsak@amd.com>

---
 .../map_buffer_range_test.c                   | 39 +++++++++++++++++++
 1 file changed, 39 insertions(+)

Patch hide | download patch | download mbox

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);
 }

Comments

On Wed, Feb 6, 2019 at 4:19 PM Marek Olšák <maraeo@gmail.com> wrote:
>
> From: Marek Olšák <marek.olsak@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);

NULL instead of &zero would be simpler -- same effect.

> +       }
> +}
> +
>  /* 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);
> +

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>

>         piglit_report_result(PIGLIT_PASS);
>  }
> --
> 2.17.1
>
> _______________________________________________
> Piglit mailing list
> Piglit@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit