Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t v8 15/16] tests/api_intel_bb: base64 dumping code
Date: Mon, 27 Jul 2020 13:44:11 +0200	[thread overview]
Message-ID: <20200727114412.5101-16-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20200727114412.5101-1-zbigniew.kempczynski@intel.com>

v2: back to 1024 px
v3: adding render-.*-reloc tests
v4: add igt_require for gen12 and relocation

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
---
 tests/i915/api_intel_bb.c | 87 +++++++++++++++++++++++++++++++++++----
 1 file changed, 80 insertions(+), 7 deletions(-)

diff --git a/tests/i915/api_intel_bb.c b/tests/i915/api_intel_bb.c
index ca4625d5..5d7d2326 100644
--- a/tests/i915/api_intel_bb.c
+++ b/tests/i915/api_intel_bb.c
@@ -32,6 +32,8 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
+#include <glib.h>
+#include <zlib.h>
 #include "intel_bufops.h"
 
 #define PAGE_SIZE 4096
@@ -495,6 +497,54 @@ static int compare_bufs(struct intel_buf *buf1, struct intel_buf *buf2,
 	return ret;
 }
 
+#define LINELEN 76
+static int dump_base64(const char *name, struct intel_buf *buf)
+{
+	void *ptr;
+	int fd, ret;
+	uLongf outsize = buf->surface[0].size * 3 / 2;
+	Bytef *destbuf = malloc(outsize);
+	gchar *str, *pos;
+
+	fd = buf_ops_get_fd(buf->bops);
+
+	ptr = gem_mmap__device_coherent(fd, buf->handle, 0,
+					buf->surface[0].size, PROT_READ);
+
+	ret = compress2(destbuf, &outsize, ptr, buf->surface[0].size,
+			Z_BEST_COMPRESSION);
+	if (ret != Z_OK) {
+		igt_warn("error compressing, ret: %d\n", ret);
+	} else {
+		igt_info("compressed %u -> %lu\n",
+			 buf->surface[0].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);
+	}
+
+	munmap(ptr, buf->surface[0].size);
+	free(destbuf);
+
+	return ret;
+}
+
+
 static int __do_intel_bb_blit(struct buf_ops *bops, uint32_t tiling)
 {
 	struct intel_bb *ibb;
@@ -673,7 +723,7 @@ static void full_batch(struct buf_ops *bops)
 	intel_bb_destroy(ibb);
 }
 
-static int render(struct buf_ops *bops, uint32_t tiling)
+static int render(struct buf_ops *bops, uint32_t tiling, bool do_reloc)
 {
 	struct intel_bb *ibb;
 	const int width = 1024;
@@ -685,9 +735,17 @@ static int render(struct buf_ops *bops, uint32_t tiling)
 	uint32_t devid = intel_get_drm_devid(i915);
 	igt_render_copyfunc_t render_copy = NULL;
 
-	ibb = intel_bb_create(i915, PAGE_SIZE);
-	if (debug_bb)
-		intel_bb_set_debug(ibb, true);
+	/* Don't use relocations on gen12+ */
+	igt_require((do_reloc && intel_gen(devid) < 12) ||
+		    !do_reloc);
+
+	if (do_reloc)
+		ibb = intel_bb_create_with_relocs(i915, PAGE_SIZE);
+	else
+		ibb = intel_bb_create(i915, PAGE_SIZE);
+
+	intel_bb_set_debug(ibb, true);
+	intel_bb_set_dump_base64(ibb, true);
 
 	scratch_buf_init(bops, &src, width, height, I915_TILING_NONE,
 			 I915_COMPRESSION_NONE);
@@ -737,6 +795,12 @@ static int render(struct buf_ops *bops, uint32_t tiling)
 
 	fails = compare_bufs(&src, &final, true);
 
+	if (fails) {
+		dump_base64("src", &src);
+		dump_base64("dst", &dst);
+		dump_base64("final", &final);
+	}
+
 	intel_buf_close(bops, &src);
 	intel_buf_close(bops, &dst);
 	intel_buf_close(bops, &final);
@@ -903,13 +967,22 @@ igt_main_args("dpi", NULL, help_str, opt_handler, NULL)
 		full_batch(bops);
 
 	igt_subtest("render-none")
-		render(bops, I915_TILING_NONE);
+		render(bops, I915_TILING_NONE, false);
 
 	igt_subtest("render-x")
-		render(bops, I915_TILING_X);
+		render(bops, I915_TILING_X, false);
 
 	igt_subtest("render-y")
-		render(bops, I915_TILING_Y);
+		render(bops, I915_TILING_Y, false);
+
+	igt_subtest("render-none-reloc")
+		render(bops, I915_TILING_NONE, true);
+
+	igt_subtest("render-x-reloc")
+		render(bops, I915_TILING_X, true);
+
+	igt_subtest("render-y-reloc")
+		render(bops, I915_TILING_Y, true);
 
 	igt_subtest("render-ccs")
 		render_ccs(bops);
-- 
2.26.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2020-07-27 11:44 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-27 11:43 [igt-dev] [PATCH i-g-t v8 00/16] Remove libdrm in rendercopy Zbigniew Kempczyński
2020-07-27 11:43 ` [igt-dev] [PATCH i-g-t v8 01/16] lib/intel_bufops: add mapping on cpu / device Zbigniew Kempczyński
2020-07-27 11:43 ` [igt-dev] [PATCH i-g-t v8 02/16] lib/intel_batchbuffer: add new functions to support rendercopy Zbigniew Kempczyński
2020-07-27 11:43 ` [igt-dev] [PATCH i-g-t v8 03/16] tests/gem_caching: adopt to batch flush function cleanup Zbigniew Kempczyński
2020-07-27 11:44 ` [igt-dev] [PATCH i-g-t v8 04/16] lib/rendercopy: remove libdrm dependency Zbigniew Kempczyński
2020-07-27 11:44 ` [igt-dev] [PATCH i-g-t v8 05/16] tests/api_intel_bb: add render tests Zbigniew Kempczyński
2020-07-27 11:44 ` [igt-dev] [PATCH i-g-t v8 06/16] lib/intel_batchbuffer: use canonical addresses for 48bit ppgtt Zbigniew Kempczyński
2020-07-27 11:44 ` [igt-dev] [PATCH i-g-t v8 07/16] lib/igt_draw: remove libdrm dependency Zbigniew Kempczyński
2020-07-27 11:44 ` [igt-dev] [PATCH i-g-t v8 08/16] lib/igt_fb: Removal of " Zbigniew Kempczyński
2020-07-27 11:44 ` [igt-dev] [PATCH i-g-t v8 09/16] tests/gem|kms: remove libdrm dependency (batch 1) Zbigniew Kempczyński
2020-07-27 11:44 ` [igt-dev] [PATCH i-g-t v8 10/16] tests/gem|kms: remove libdrm dependency (batch 2) Zbigniew Kempczyński
2020-07-27 11:44 ` [igt-dev] [PATCH i-g-t v8 11/16] tools/intel_residency: adopt intel_residency to use bufops Zbigniew Kempczyński
2020-07-27 11:44 ` [igt-dev] [PATCH i-g-t v8 12/16] tests/perf: remove libdrm dependency for rendercopy Zbigniew Kempczyński
2020-07-27 11:44 ` [igt-dev] [PATCH i-g-t v8 13/16] lib/intel_batchbuffer: dump bb to base64 Zbigniew Kempczyński
2020-07-27 11:44 ` [igt-dev] [PATCH i-g-t v8 14/16] lib/intel_batchbuffer: change alignment constraints on gen4 Zbigniew Kempczyński
2020-07-27 11:44 ` Zbigniew Kempczyński [this message]
2020-07-27 11:44 ` [igt-dev] [PATCH i-g-t v8 16/16] HAX: run rendercopy tests Zbigniew Kempczyński
2020-07-27 12:46 ` [igt-dev] ✗ Fi.CI.BAT: failure for Remove libdrm in rendercopy (rev8) Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200727114412.5101-16-zbigniew.kempczynski@intel.com \
    --to=zbigniew.kempczynski@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox