All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Subject: [igt-dev] [PATCH i-g-t v6 05/14] tests/api_intel_bb: add render tests
Date: Fri, 24 Jul 2020 22:22:24 +0200	[thread overview]
Message-ID: <20200724202233.14952-6-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20200724202233.14952-1-zbigniew.kempczynski@intel.com>

Check render / render-ccs tests works fine on all supported gens.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Dominik Grzegorzek <dominik.grzegorzek@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/i915/api_intel_bb.c | 168 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 168 insertions(+)

diff --git a/tests/i915/api_intel_bb.c b/tests/i915/api_intel_bb.c
index 6967fc5d..df0eb933 100644
--- a/tests/i915/api_intel_bb.c
+++ b/tests/i915/api_intel_bb.c
@@ -632,6 +632,162 @@ static void full_batch(struct buf_ops *bops)
 	intel_bb_destroy(ibb);
 }
 
+static int render(struct buf_ops *bops, uint32_t tiling)
+{
+	struct intel_bb *ibb;
+	const int width = 1024;
+	const int height = 1024;
+	struct intel_buf src, dst, final;
+	int i915 = buf_ops_get_fd(bops);
+	uint32_t fails = 0;
+	char name[128];
+	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);
+
+	scratch_buf_init(bops, &src, width, height, I915_TILING_NONE,
+			 I915_COMPRESSION_NONE);
+	scratch_buf_init(bops, &dst, width, height, tiling,
+			 I915_COMPRESSION_NONE);
+	scratch_buf_init(bops, &final, width, height, I915_TILING_NONE,
+			 I915_COMPRESSION_NONE);
+
+	scratch_buf_draw_pattern(bops, &src,
+				 0, 0, width, height,
+				 0, 0, width, height, 0);
+
+	render_copy = igt_get_render_copyfunc(devid);
+	igt_assert(render_copy);
+
+	render_copy(ibb, 0,
+		    &src,
+		    0, 0, width, height,
+		    &dst,
+		    0, 0);
+
+	render_copy(ibb, 0,
+		    &dst,
+		    0, 0, width, height,
+		    &final,
+		    0, 0);
+
+	intel_bb_sync(ibb);
+	intel_bb_destroy(ibb);
+
+	if (write_png) {
+		snprintf(name, sizeof(name) - 1,
+			 "render_dst_tiling_%d.png", tiling);
+		intel_buf_write_to_png(&src, "render_src_tiling_none.png");
+		intel_buf_write_to_png(&dst, name);
+		intel_buf_write_to_png(&final, "render_final_tiling_none.png");
+	}
+
+	/* We'll fail on src <-> final compare so just warn */
+	if (tiling == I915_TILING_NONE) {
+		if (compare_bufs(&src, &dst, false) > 0)
+			igt_warn("%s: none->none failed!\n", __func__);
+	} else {
+		if (compare_bufs(&src, &dst, false) == 0)
+			igt_warn("%s: none->tiled failed!\n", __func__);
+	}
+
+	fails = compare_bufs(&src, &final, true);
+
+	intel_buf_close(bops, &src);
+	intel_buf_close(bops, &dst);
+	intel_buf_close(bops, &final);
+
+	igt_assert_f(fails == 0, "%s: (tiling: %d) fails: %d\n",
+		     __func__, tiling, fails);
+
+	return fails;
+}
+
+static uint32_t count_compressed(int gen, struct intel_buf *buf)
+{
+	int ccs_size = intel_buf_ccs_width(gen, buf) * intel_buf_ccs_height(gen, buf);
+	uint8_t *ptr = intel_buf_device_map(buf, false);
+	uint32_t compressed = 0;
+	int i;
+
+	for (i = 0; i < ccs_size; i++)
+		if (ptr[buf->ccs[0].offset + i])
+			compressed++;
+
+	intel_buf_unmap(buf);
+
+	return compressed;
+}
+
+#define IMGSIZE (512 * 512 * 4)
+#define CCSIMGSIZE (IMGSIZE + 4096)
+static void render_ccs(struct buf_ops *bops)
+{
+	struct intel_bb *ibb;
+	const int width = 1024;
+	const int height = 1024;
+	struct intel_buf src, dst, final;
+	int i915 = buf_ops_get_fd(bops);
+	uint32_t fails = 0;
+	uint32_t compressed = 0;
+	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);
+
+	scratch_buf_init(bops, &src, width, height, I915_TILING_NONE,
+			 I915_COMPRESSION_NONE);
+	scratch_buf_init(bops, &dst, width, height, I915_TILING_Y,
+			 I915_COMPRESSION_RENDER);
+	scratch_buf_init(bops, &final, width, height, I915_TILING_NONE,
+			 I915_COMPRESSION_NONE);
+
+	render_copy = igt_get_render_copyfunc(devid);
+	igt_assert(render_copy);
+
+	scratch_buf_draw_pattern(bops, &src,
+				 0, 0, width, height,
+				 0, 0, width, height, 0);
+
+	render_copy(ibb, 0,
+		    &src,
+		    0, 0, width, height,
+		    &dst,
+		    0, 0);
+
+	render_copy(ibb, 0,
+		    &dst,
+		    0, 0, width, height,
+		    &final,
+		    0, 0);
+
+	intel_bb_sync(ibb);
+	intel_bb_destroy(ibb);
+
+	fails = compare_bufs(&src, &final, true);
+	compressed = count_compressed(ibb->gen, &dst);
+
+	igt_debug("fails: %u, compressed: %u\n", fails, compressed);
+
+	if (write_png) {
+		intel_buf_write_to_png(&src, "render-ccs-src.png");
+		intel_buf_write_to_png(&dst, "render-ccs-dst.png");
+		intel_buf_write_aux_to_png(&dst, "render-ccs-dst-aux.png");
+		intel_buf_write_to_png(&final, "render-ccs-final.png");
+	}
+
+	intel_buf_close(bops, &src);
+	intel_buf_close(bops, &dst);
+	intel_buf_close(bops, &final);
+
+	igt_assert_f(fails == 0, "render-ccs fails: %d\n", fails);
+}
+
 static int opt_handler(int opt, int opt_index, void *data)
 {
 	switch (opt) {
@@ -702,6 +858,18 @@ igt_main_args("dpi", NULL, help_str, opt_handler, NULL)
 	igt_subtest("full-batch")
 		full_batch(bops);
 
+	igt_subtest("render-none")
+		render(bops, I915_TILING_NONE);
+
+	igt_subtest("render-x")
+		render(bops, I915_TILING_X);
+
+	igt_subtest("render-y")
+		render(bops, I915_TILING_Y);
+
+	igt_subtest("render-ccs")
+		render_ccs(bops);
+
 	igt_fixture {
 		buf_ops_destroy(bops);
 		close(i915);
-- 
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-24 20:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-24 20:22 [igt-dev] [PATCH i-g-t v6 00/14] Remove libdrm in rendercopy Zbigniew Kempczyński
2020-07-24 20:22 ` [igt-dev] [PATCH i-g-t v6 01/14] lib/intel_bufops: add mapping on cpu / device Zbigniew Kempczyński
2020-07-24 20:22 ` [igt-dev] [PATCH i-g-t v6 02/14] lib/intel_batchbuffer: add new functions to support rendercopy Zbigniew Kempczyński
2020-07-24 20:22 ` [igt-dev] [PATCH i-g-t v6 03/14] tests/gem_caching: adopt to batch flush function cleanup Zbigniew Kempczyński
2020-07-24 20:22 ` [igt-dev] [PATCH i-g-t v6 04/14] lib/rendercopy: remove libdrm dependency Zbigniew Kempczyński
2020-07-24 20:22 ` Zbigniew Kempczyński [this message]
2020-07-24 20:22 ` [igt-dev] [PATCH i-g-t v6 06/14] lib/intel_batchbuffer: use canonical addresses for 48bit ppgtt Zbigniew Kempczyński
2020-07-24 20:22 ` [igt-dev] [PATCH i-g-t v6 07/14] lib/igt_draw: remove libdrm dependency Zbigniew Kempczyński
2020-07-24 20:22 ` [igt-dev] [PATCH i-g-t v6 08/14] lib/igt_fb: Removal of " Zbigniew Kempczyński
2020-07-24 20:22 ` [igt-dev] [PATCH i-g-t v6 09/14] tests/gem|kms: remove libdrm dependency (batch 1) Zbigniew Kempczyński
2020-07-24 20:22 ` [igt-dev] [PATCH i-g-t v6 10/14] tests/gem|kms: remove libdrm dependency (batch 2) Zbigniew Kempczyński
2020-07-24 20:22 ` [igt-dev] [PATCH i-g-t v6 11/14] tools/intel_residency: adopt intel_residency to use bufops Zbigniew Kempczyński
2020-07-24 20:22 ` [igt-dev] [PATCH i-g-t v6 12/14] tests/perf: remove libdrm dependency for rendercopy Zbigniew Kempczyński
2020-07-24 20:22 ` [igt-dev] [PATCH i-g-t v6 13/14] tests/api_intel_bb: base64 dumping code Zbigniew Kempczyński
2020-07-24 20:22 ` [igt-dev] [PATCH i-g-t v6 14/14] HAX: run rendercopy tests Zbigniew Kempczyński
2020-07-24 21:09 ` [igt-dev] ✗ Fi.CI.BAT: failure for Remove libdrm in rendercopy (rev6) 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=20200724202233.14952-6-zbigniew.kempczynski@intel.com \
    --to=zbigniew.kempczynski@intel.com \
    --cc=chris@chris-wilson.co.uk \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.