[igt-dev] [PATCH i-g-t v15 14/14] tests/gem_render_tiled_blits: dump gen3 surfaces
Zbigniew Kempczyński
zbigniew.kempczynski at intel.com
Wed Jul 29 19:30:53 UTC 2020
Experimental to find out what makes reading via gtt incoherent.
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
---
tests/i915/gem_render_tiled_blits.c | 79 ++++++++++++++++++++++++++---
1 file changed, 73 insertions(+), 6 deletions(-)
diff --git a/tests/i915/gem_render_tiled_blits.c b/tests/i915/gem_render_tiled_blits.c
index 0d83a43e..dbf4a336 100644
--- a/tests/i915/gem_render_tiled_blits.c
+++ b/tests/i915/gem_render_tiled_blits.c
@@ -43,6 +43,8 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/mman.h>
+#include <glib.h>
+#include <zlib.h>
#include <drm.h>
@@ -59,20 +61,76 @@ static struct intel_buf linear;
static uint32_t data[WIDTH*HEIGHT];
static int snoop;
+#define DUMPGEN 3
+#define LINELEN 76
+static int dump_base64(const char *name, void *ptr, uint32_t size)
+{
+ int ret;
+ uLongf outsize = size * 3 / 2;
+ Bytef *destbuf = malloc(outsize);
+ gchar *str, *pos;
+
+ ret = compress2(destbuf, &outsize, ptr, size, Z_BEST_COMPRESSION);
+ if (ret != Z_OK) {
+ igt_warn("error compressing, ret: %d\n", ret);
+ } else {
+ igt_info("compressed %u -> %lu\n", size, outsize);
+
+ igt_info("--- %s ---\n", name);
+ pos = str = g_base64_encode(destbuf, outsize);
+ outsize = strlen(str);
+ while (pos) {
+ char line[LINELEN + 1];
+ int to_copy = min(LINELEN, outsize);
+
+ memcpy(line, pos, to_copy);
+ line[to_copy] = 0;
+ igt_info("%s\n", line);
+ pos += LINELEN;
+ outsize -= to_copy;
+
+ if (outsize == 0)
+ break;
+ }
+ free(str);
+ }
+
+ free(destbuf);
+
+ return ret;
+}
+
static void
-check_buf(struct intel_bb *ibb, struct intel_buf *buf, uint32_t val)
+check_buf(struct intel_bb *ibb, struct intel_buf *buf, uint32_t val, bool dump)
{
int i915 = buf_ops_get_fd(linear.bops);
uint32_t *ptr;
+ char name[32];
int i;
render_copy(ibb, 0, buf, 0, 0, WIDTH, HEIGHT, &linear, 0, 0);
intel_bb_sync(ibb);
if (snoop) {
+ if (ibb->gen == DUMPGEN && dump) {
+ ptr = gem_mmap__device_coherent(ibb->i915, buf->handle, 0,
+ buf->surface[0].size, PROT_READ);
+ gem_set_domain(i915, buf->handle, I915_GEM_DOMAIN_WC, 0);
+ snprintf(name, sizeof(name) - 1, "wc-tiling-%d",
+ buf->tiling);
+ dump_base64(name, ptr, buf->surface[0].size);
+ munmap(ptr, linear.surface[0].size);
+ }
+
ptr = gem_mmap__cpu_coherent(i915, linear.handle, 0,
linear.surface[0].size, PROT_READ);
gem_set_domain(i915, linear.handle, I915_GEM_DOMAIN_CPU, 0);
+
+ if (ibb->gen == DUMPGEN && dump) {
+ snprintf(name, sizeof(name) - 1, "linear-tiling-%d",
+ buf->tiling);
+ dump_base64(name, ptr, buf->surface[0].size);
+ }
} else {
gem_read(i915, linear.handle, 0, data, sizeof(data));
ptr = data;
@@ -97,6 +155,7 @@ static void run_test (int fd, int count)
uint32_t start = 0;
int i, j;
uint32_t devid;
+ char name[32];
devid = intel_get_drm_devid(fd);
@@ -123,12 +182,14 @@ static void run_test (int fd, int count)
start_val = malloc(sizeof(*start_val)*count);
for (i = 0; i < count; i++) {
- uint32_t tiling = I915_TILING_X + (random() & 1);
+ uint32_t tiling = I915_TILING_X + (i & 1);
uint32_t *ptr;
intel_buf_init(bops, &bufs[i], WIDTH, HEIGHT, 32, 0,
tiling, I915_COMPRESSION_NONE);
start_val[i] = start;
+ igt_debug("buf init: [w: %u, h: %u, tiling: %u, start val: %u]\n",
+ WIDTH, HEIGHT, tiling, start);
ptr = gem_mmap__gtt(fd, bufs[i].handle,
bufs[i].surface[0].size, PROT_WRITE);
@@ -137,12 +198,18 @@ static void run_test (int fd, int count)
for (j = 0; j < WIDTH*HEIGHT; j++)
ptr[j] = start++;
+ if (ibb->gen == DUMPGEN && count == 2) {
+ snprintf(name, sizeof(name) - 1, "gtt-%d-tiling-%d",
+ i, bufs[i].tiling);
+ dump_base64(name, ptr, bufs[i].surface[0].size);
+ }
+
munmap(ptr, bufs[i].surface[0].size);
}
igt_info("Verifying initialisation...\n");
for (i = 0; i < count; i++)
- check_buf(ibb, &bufs[i], start_val[i]);
+ check_buf(ibb, &bufs[i], start_val[i], true);
igt_info("Cyclic blits, forward...\n");
for (i = 0; i < count * 4; i++) {
@@ -156,7 +223,7 @@ static void run_test (int fd, int count)
intel_bb_sync(ibb);
for (i = 0; i < count; i++)
- check_buf(ibb, &bufs[i], start_val[i]);
+ check_buf(ibb, &bufs[i], start_val[i], false);
igt_info("Cyclic blits, backward...\n");
for (i = 0; i < count * 4; i++) {
@@ -169,7 +236,7 @@ static void run_test (int fd, int count)
}
intel_bb_sync(ibb);
for (i = 0; i < count; i++)
- check_buf(ibb, &bufs[i], start_val[i]);
+ check_buf(ibb, &bufs[i], start_val[i], false);
igt_info("Random blits...\n");
for (i = 0; i < count * 4; i++) {
@@ -186,7 +253,7 @@ static void run_test (int fd, int count)
intel_bb_sync(ibb);
for (i = 0; i < count; i++)
- check_buf(ibb, &bufs[i], start_val[i]);
+ check_buf(ibb, &bufs[i], start_val[i], false);
/* release resources */
intel_buf_close(bops, &linear);
--
2.26.0
More information about the igt-dev
mailing list