Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
To: igt-dev@lists.freedesktop.org
Cc: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Subject: [PATCH i-g-t v2 2/3] lib/igt_fb: add igt_xe2_blit_with_dst_pat function
Date: Thu, 17 Oct 2024 14:27:27 +0300	[thread overview]
Message-ID: <20241017112728.3503205-3-juhapekka.heikkila@gmail.com> (raw)
In-Reply-To: <20241017112728.3503205-1-juhapekka.heikkila@gmail.com>

Add igt_xe2_blit_with_dst_pat() function which use blitter block copy
to copy src framebuffer to destination framebuffer setting destination
pat index to what is passed as parameter.

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
---
 lib/igt_fb.c | 65 ++++++++++++++++++++++++++++++++++++++++++++--------
 lib/igt_fb.h |  3 +++
 2 files changed, 59 insertions(+), 9 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index b8ffd7cfb..e87809ba3 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -2833,7 +2833,8 @@ static struct blt_copy_object *allocate_and_initialize_blt(const struct igt_fb *
 							   uint32_t handle,
 							   uint32_t memregion,
 							   enum blt_tiling_type blt_tile,
-							   uint32_t plane)
+							   uint32_t plane,
+							   uint8_t pat_index)
 {
 	uint64_t stride;
 	struct blt_copy_object *blt = calloc(1, sizeof(*blt));
@@ -2845,7 +2846,7 @@ static struct blt_copy_object *allocate_and_initialize_blt(const struct igt_fb *
 
 	blt_set_object(blt, handle, fb->size, memregion,
 		       intel_get_uc_mocs_index(fb->fd),
-		       intel_get_pat_idx_uc(fb->fd),
+		       pat_index,
 		       blt_tile,
 		       igt_fb_is_ccs_modifier(fb->modifier) ? COMPRESSION_ENABLED : COMPRESSION_DISABLED,
 		       igt_fb_is_gen12_mc_ccs_modifier(fb->modifier) ? COMPRESSION_TYPE_MEDIA : COMPRESSION_TYPE_3D);
@@ -2867,7 +2868,8 @@ static void *map_buffer(int fd, uint32_t handle, size_t size)
 }
 
 static struct blt_copy_object *blt_fb_init(const struct igt_fb *fb,
-					   uint32_t plane, uint32_t memregion)
+					   uint32_t plane, uint32_t memregion,
+					   uint8_t pat_index)
 {
 	uint32_t name, handle;
 	enum blt_tiling_type blt_tile;
@@ -2883,7 +2885,8 @@ static struct blt_copy_object *blt_fb_init(const struct igt_fb *fb,
 		return NULL;
 
 	blt_tile = fb_tile_to_blt_tile(fb->modifier);
-	blt = allocate_and_initialize_blt(fb, handle, memregion, blt_tile, plane);
+	blt = allocate_and_initialize_blt(fb, handle, memregion, blt_tile,
+					  plane, pat_index);
 
 	if (!blt)
 		return NULL;
@@ -3024,11 +3027,14 @@ static void do_block_copy(const struct igt_fb *src_fb,
 			  uint32_t mem_region, uint32_t i, uint64_t ahnd,
 			  uint32_t xe_bb, uint64_t bb_size,
 			  const intel_ctx_t *ctx,
-			  struct intel_execution_engine2 *e)
+			  struct intel_execution_engine2 *e,
+			  uint8_t dst_pat_index)
 {
 	struct blt_copy_data blt = {};
-	struct blt_copy_object *src = blt_fb_init(src_fb, i, mem_region);
-	struct blt_copy_object *dst = blt_fb_init(dst_fb, i, mem_region);
+	struct blt_copy_object *src = blt_fb_init(src_fb, i, mem_region,
+						  intel_get_pat_idx_uc(src_fb->fd));
+	struct blt_copy_object *dst = blt_fb_init(dst_fb, i, mem_region,
+						  dst_pat_index);
 	struct blt_block_copy_data_ext ext = {}, *pext = NULL;
 
 	igt_assert(src && dst);
@@ -3093,7 +3099,8 @@ static void blitcopy(const struct igt_fb *dst_fb,
 
 		if (is_xe) {
 			do_block_copy(src_fb, dst_fb, mem_region, i, ahnd,
-				      bb, bb_size, xe_ctx, NULL);
+				      bb, bb_size, xe_ctx, NULL,
+				      intel_get_pat_idx_uc(dst_fb->fd));
 		} else if (fast_blit_ok(src_fb) && fast_blit_ok(dst_fb)) {
 			igt_blitter_fast_copy__raw(dst_fb->fd,
 						   ahnd, ctx, NULL,
@@ -3116,7 +3123,8 @@ static void blitcopy(const struct igt_fb *dst_fb,
 			for_each_ctx_engine(src_fb->fd, ictx, e) {
 				if (gem_engine_can_block_copy(src_fb->fd, e)) {
 					do_block_copy(src_fb, dst_fb, mem_region, i, ahnd,
-						      bb, bb_size, ictx, e);
+						      bb, bb_size, ictx, e,
+						      intel_get_pat_idx_uc(dst_fb->fd));
 					break;
 				}
 			}
@@ -3146,6 +3154,45 @@ static void blitcopy(const struct igt_fb *dst_fb,
 			      src_fb->fd, ictx);
 }
 
+/**
+ * igt_xe2_blit_with_dst_pat:
+ * @dst_fb: pointer to a destination #igt_fb structure
+ * @src_fb: pointer to a source #igt_fb structure
+ * @dst_pat_index: uint8_t pat index to set for destination framebuffer
+ *
+ * Copy matching size src_fb to dst_fb with setting pat index to destination
+ * framebuffer
+ */
+void igt_xe2_blit_with_dst_pat(const struct igt_fb *dst_fb,
+			       const struct igt_fb *src_fb,
+			       uint8_t dst_pat_index)
+{
+	uint32_t ctx = 0, bb, mem_region, vm, exec_queue;
+	uint64_t ahnd = 0, bb_size = 4096;
+	intel_ctx_t *xe_ctx = NULL;
+
+	igt_assert_eq(dst_fb->fd, src_fb->fd);
+	igt_assert_eq(dst_fb->num_planes, src_fb->num_planes);
+	igt_assert(!igt_fb_is_gen12_rc_ccs_cc_modifier(src_fb->modifier));
+	igt_assert(!igt_fb_is_gen12_rc_ccs_cc_modifier(dst_fb->modifier));
+
+	setup_context_and_memory_region(dst_fb, &ctx, &ahnd, &mem_region,
+					&vm, &bb, &bb_size, NULL,
+					&exec_queue, &xe_ctx);
+
+	for (int i = 0; i < dst_fb->num_planes; i++) {
+		igt_assert_eq(dst_fb->plane_bpp[i], src_fb->plane_bpp[i]);
+		igt_assert_eq(dst_fb->plane_width[i], src_fb->plane_width[i]);
+		igt_assert_eq(dst_fb->plane_height[i], src_fb->plane_height[i]);
+
+		do_block_copy(src_fb, dst_fb, mem_region, i, ahnd, bb, bb_size,
+			      xe_ctx, NULL, dst_pat_index);
+	}
+
+	cleanup_blt_resources(ctx, ahnd, true, bb, exec_queue, vm, xe_ctx,
+			      src_fb->fd, NULL);
+}
+
 static void free_linear_mapping(struct fb_blit_upload *blit)
 {
 	int fd = blit->fd;
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index eb707cc34..d5aa1e88a 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -187,6 +187,9 @@ bool igt_fb_is_gen12_mc_ccs_modifier(uint64_t modifier);
 bool igt_fb_is_ccs_plane(const struct igt_fb *fb, int plane);
 bool igt_fb_is_gen12_ccs_cc_plane(const struct igt_fb *fb, int plane);
 int igt_fb_ccs_to_main_plane(const struct igt_fb *fb, int ccs_plane);
+void igt_xe2_blit_with_dst_pat(const struct igt_fb *dst_fb,
+			       const struct igt_fb *src_fb,
+			       uint8_t dst_pat_index);
 
 /* cairo-based painting */
 cairo_surface_t *igt_get_cairo_surface(int fd, struct igt_fb *fb);
-- 
2.45.2


  parent reply	other threads:[~2024-10-17 11:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-17 11:27 [PATCH i-g-t v2 0/3] kms_ccs optimization Juha-Pekka Heikkila
2024-10-17 11:27 ` [PATCH i-g-t v2 1/3] tests/intel/kms_ccs: recycle framebuffers Juha-Pekka Heikkila
2024-10-22 10:28   ` Kahola, Mika
2024-10-17 11:27 ` Juha-Pekka Heikkila [this message]
2024-10-22 10:48   ` [PATCH i-g-t v2 2/3] lib/igt_fb: add igt_xe2_blit_with_dst_pat function Kahola, Mika
2024-10-17 11:27 ` [PATCH i-g-t v2 3/3] tests/intel/kms_ccs: use igt_fb functions instead of locally defined Juha-Pekka Heikkila
2024-10-22 11:26   ` Kahola, Mika
2024-10-22 12:02     ` Juha-Pekka Heikkila
2024-10-17 19:02 ` ✓ CI.xeBAT: success for kms_ccs optimization (rev2) Patchwork
2024-10-17 19:02 ` ✓ Fi.CI.BAT: " Patchwork
2024-10-17 19:03 ` Patchwork
2024-10-17 19:03 ` ✗ CI.xeBAT: failure " Patchwork
2024-10-17 22:07 ` ✗ Fi.CI.IGT: " Patchwork
2024-10-18 10:45 ` ✗ CI.xeFULL: " Patchwork
2024-10-22  7:57   ` Juha-Pekka Heikkila

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=20241017112728.3503205-3-juhapekka.heikkila@gmail.com \
    --to=juhapekka.heikkila@gmail.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