[i-g-t] XE: Add blitter support

Bhanuprakash Modem bhanuprakash.modem at intel.com
Mon Jun 12 15:26:12 UTC 2023


Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem at intel.com>
---
 lib/igt_fb.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 50 insertions(+), 5 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 9be312a28..8ec301a43 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -2472,7 +2472,7 @@ static bool fast_blit_ok(const struct igt_fb *fb)
 
 static bool blitter_ok(const struct igt_fb *fb)
 {
-	if (!is_i915_device(fb->fd))
+	if (!is_intel_device(fb->fd))
 		return false;
 
 	if (is_ccs_modifier(fb->modifier))
@@ -2506,12 +2506,11 @@ static bool blitter_ok(const struct igt_fb *fb)
 
 static bool use_enginecopy(const struct igt_fb *fb)
 {
-	if (!is_xe_device(fb->fd) && blitter_ok(fb))
+	if (blitter_ok(fb))
 		return false;
 
 	return fb->modifier == I915_FORMAT_MOD_Yf_TILED ||
 	       is_ccs_modifier(fb->modifier) ||
-	       (is_xe_device(fb->fd) && fb->modifier == DRM_FORMAT_MOD_LINEAR) ||
 	       (is_i915_device(fb->fd) && !gem_has_mappable_ggtt(fb->fd));
 }
 
@@ -2712,6 +2711,46 @@ static void copy_with_engine(struct fb_blit_upload *blit,
 	fini_buf(src);
 }
 
+static void copy_with_blitter(struct fb_blit_upload *blit,
+			      const struct igt_fb *dst_fb,
+			      const struct igt_fb *src_fb)
+{
+	struct intel_buf *dst;
+	int blt_cmd_depth;
+	int pitch;
+
+	dst = create_buf(blit, dst_fb, "cairo blitcopy dst");
+	intel_bb_add_intel_buf(blit->ibb, dst, true);
+
+	switch (src_fb->plane_bpp[0]) {
+	case 8:
+		blt_cmd_depth = 0;
+		break;
+	case 16: /* we're assuming 565 */
+		blt_cmd_depth = 1 << 24;
+		break;
+	case 32:
+		blt_cmd_depth = 3 << 24;
+		break;
+	default:
+		igt_assert(false);
+	}
+
+	pitch = igt_fb_mod_to_tiling(src_fb->modifier) ? src_fb->strides[0] / 4 :
+							 src_fb->strides[0];
+
+	intel_bb_out(blit->ibb, XY_COLOR_BLT_CMD_NOLEN | XY_COLOR_BLT_WRITE_ALPHA |
+		     XY_COLOR_BLT_WRITE_RGB | 0x5);
+	intel_bb_out(blit->ibb, blt_cmd_depth | (0xF0 << 16) | pitch);
+	intel_bb_out(blit->ibb, 0);
+	intel_bb_out(blit->ibb, (src_fb->height << 16) | src_fb->width);
+	intel_bb_emit_reloc_fenced(blit->ibb, dst->handle, 0, I915_GEM_DOMAIN_RENDER,
+				   0, dst->addr.offset);
+
+	intel_bb_flush_blit(blit->ibb);
+	intel_buf_destroy(dst);
+}
+
 static void blitcopy(const struct igt_fb *dst_fb,
 		     const struct igt_fb *src_fb)
 {
@@ -2807,7 +2846,10 @@ static void free_linear_mapping(struct fb_blit_upload *blit)
 		igt_nouveau_delete_bo(&linear->fb);
 	} else if (is_xe_device(fd)) {
 		gem_munmap(linear->map, linear->fb.size);
-		copy_with_engine(blit, fb, &linear->fb);
+		if (blit->ibb)
+			copy_with_engine(blit, &linear->fb, fb);
+		else
+			copy_with_blitter(blit, &linear->fb, fb);
 
 		syncobj_wait(fd, &blit->ibb->engine_syncobj, 1, INT64_MAX, 0, NULL);
 		gem_close(fd, linear->fb.gem_handle);
@@ -2889,7 +2931,10 @@ static void setup_linear_mapping(struct fb_blit_upload *blit)
 
 		linear->map = igt_nouveau_mmap_bo(&linear->fb, PROT_READ | PROT_WRITE);
 	} else if (is_xe_device(fd)) {
-		copy_with_engine(blit, &linear->fb, fb);
+		if (blit->ibb)
+			copy_with_engine(blit, &linear->fb, fb);
+		else
+			copy_with_blitter(blit, &linear->fb, fb);
 
 		linear->map = xe_bo_mmap_ext(fd, linear->fb.gem_handle,
 					     linear->fb.size, PROT_READ | PROT_WRITE);
-- 
2.40.0



More information about the Intel-gfx-trybot mailing list