igt-dev.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH i-g-t] tests/kms_plane_cursor: Use two FBs for reference image
@ 2025-11-27 13:16 Chaitanya Kumar Borah
  0 siblings, 0 replies; only message in thread
From: Chaitanya Kumar Borah @ 2025-11-27 13:16 UTC (permalink / raw)
  To: igt-dev; +Cc: swati2.sharma, juha-pekka.heikkila

Painting directly on the FB currently being scanned out ends up
modifying the frontbuffer. Since the FB isn’t marked dirty, those
updates never reach the actual buffer, leading to stale or incorrect
reference images during testing.

To avoid this, create two reference framebuffers and alternately flip
between them: one is displayed while the other is used for rendering
the reference image.

Signed-off-by: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
---
 tests/kms_plane_cursor.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/tests/kms_plane_cursor.c b/tests/kms_plane_cursor.c
index 9fa36bfd4..fa78b58ff 100644
--- a/tests/kms_plane_cursor.c
+++ b/tests/kms_plane_cursor.c
@@ -78,6 +78,7 @@ typedef struct data {
 	igt_pipe_t *pipe;
 	igt_pipe_crc_t *pipe_crc;
 	drmModeModeInfo *mode;
+	igt_fb_t ref_fb[2];
 	igt_fb_t pfb;
 	igt_fb_t ofb;
 	igt_fb_t cfb;
@@ -152,6 +153,7 @@ static void test_cursor_pos(data_t *data, int x, int y, unsigned int flags)
 {
 	igt_crc_t ref_crc, test_crc;
 	cairo_t *cr;
+	igt_fb_t *ref_fb;
 	igt_fb_t *pfb = &data->pfb;
 	igt_fb_t *ofb = &data->ofb;
 	igt_fb_t *cfb = &data->cfb;
@@ -159,8 +161,11 @@ static void test_cursor_pos(data_t *data, int x, int y, unsigned int flags)
 	int ch = cfb->height;
 	const rect_t *or = &data->or;
 
-	cr = igt_get_cairo_ctx(pfb->fd, pfb);
-	igt_paint_color(cr, 0, 0, pfb->width, pfb->height, 1.0, 1.0, 1.0);
+	ref_fb = (data->primary->drm_plane->fb_id ==
+		  data->ref_fb[0].fb_id) ? &data->ref_fb[1] : &data->ref_fb[0];
+
+	cr = igt_get_cairo_ctx(pfb->fd, ref_fb);
+	igt_paint_color(cr, 0, 0, ref_fb->width, ref_fb->height, 1.0, 1.0, 1.0);
 
 	if (flags & TEST_OVERLAY)
 		igt_paint_color(cr, or->x, or->y, or->w, or->h, 0.5, 0.5, 0.5);
@@ -168,6 +173,9 @@ static void test_cursor_pos(data_t *data, int x, int y, unsigned int flags)
 	igt_paint_color(cr, x, y, cw, ch, 1.0, 0.0, 1.0);
 	igt_put_cairo_ctx(cr);
 
+	igt_plane_set_fb(data->primary, ref_fb);
+	igt_display_commit_atomic(&data->display, 0, NULL);
+
 	if (flags & TEST_OVERLAY)
 		igt_plane_set_fb(data->overlay, NULL);
 	igt_plane_set_fb(data->cursor, NULL);
@@ -249,6 +257,8 @@ static void test_cleanup(data_t *data)
 	igt_remove_fb(data->drm_fd, &data->cfb);
 	igt_remove_fb(data->drm_fd, &data->ofb);
 	igt_remove_fb(data->drm_fd, &data->pfb);
+	igt_remove_fb(data->drm_fd, &data->ref_fb[0]);
+	igt_remove_fb(data->drm_fd, &data->ref_fb[1]);
 }
 
 static void test_cursor(data_t *data, int size, unsigned int flags)
@@ -263,6 +273,12 @@ static void test_cursor(data_t *data, int size, unsigned int flags)
 
 	test_cleanup(data);
 
+	igt_create_fb(data->drm_fd, sw, sh, DRM_FORMAT_XRGB8888,
+		      DRM_FORMAT_MOD_LINEAR, &data->ref_fb[0]);
+
+	igt_create_fb(data->drm_fd, sw, sh, DRM_FORMAT_XRGB8888,
+		      DRM_FORMAT_MOD_LINEAR, &data->ref_fb[1]);
+
 	igt_create_color_fb(data->drm_fd, sw, sh, DRM_FORMAT_XRGB8888,
 			    DRM_FORMAT_MOD_LINEAR, 1.0, 1.0, 1.0, &data->pfb);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2025-11-27 13:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-27 13:16 [PATCH i-g-t] tests/kms_plane_cursor: Use two FBs for reference image Chaitanya Kumar Borah

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).