Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] lib/igt_fb: Fix intel_buf surface init
@ 2024-09-23 21:36 Ville Syrjala
  2024-09-26  0:17 ` ✗ CI.xeBAT: failure for " Patchwork
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: Ville Syrjala @ 2024-09-23 21:36 UTC (permalink / raw)
  To: igt-dev

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

The current coed is populating buf->ccs[] and buf->surface[]
in a rather inconsistent way.

It looks like for flat CCS platforms:
- we populate buf->ccs[] with some nonsense even though
  we shouldn't since the AUX stuff is completely hidden by
  the hardware
- we seem to stick data about the clear color into both
  both buf->ccs[] and buf->surfaces[] when it should be in neither

For non-flat CCS platforms the code seems more reasonable,
except it only manages to skip the clear color fumble by
the fact that num_planes is always odd with clear color
and thus the /2 will truncate it away.

Anyways, let's make the code make actual sense for all platforms
by properly calculating how many main surfaces and ccs surfaces
there should be.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 lib/igt_fb.c | 42 +++++++++++++++++++++++++++++++++++-------
 1 file changed, 35 insertions(+), 7 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index b8ffd7cfb261..6deb2a221df6 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -2636,6 +2636,35 @@ static int yuv_semiplanar_bpp(uint32_t drm_format)
 	}
 }
 
+static int intel_num_surfaces(const struct igt_fb *fb)
+{
+	int num_surfaces;
+
+	if (!igt_fb_is_ccs_modifier(fb->modifier))
+		return fb->num_planes;
+
+	num_surfaces = fb->num_planes;
+
+	if (igt_fb_is_gen12_rc_ccs_cc_modifier(fb->modifier))
+		num_surfaces--;
+
+	if (!HAS_FLATCCS(intel_get_drm_devid(fb->fd)))
+		num_surfaces /= 2;
+
+	return num_surfaces;
+}
+
+static int intel_num_ccs_surfaces(const struct igt_fb *fb)
+{
+	if (!igt_fb_is_ccs_modifier(fb->modifier))
+		return 0;
+
+	if (HAS_FLATCCS(intel_get_drm_devid(fb->fd)))
+		return 0;
+
+	return intel_num_surfaces(fb);
+}
+
 struct intel_buf *
 igt_fb_create_intel_buf(int fd, struct buf_ops *bops,
                         const struct igt_fb *fb,
@@ -2705,13 +2734,12 @@ igt_fb_create_intel_buf(int fd, struct buf_ops *bops,
 	if (buf->format_is_yuv_semiplanar)
 		buf->yuv_semiplanar_bpp = yuv_semiplanar_bpp(fb->drm_format);
 
-	if (igt_fb_is_ccs_modifier(fb->modifier)) {
-		num_surfaces = fb->num_planes / (HAS_FLATCCS(intel_get_drm_devid(fb->fd)) ? 1 : 2);
-		for (i = 0; i < num_surfaces; i++)
-			init_buf_ccs(buf, i,
-				     fb->offsets[num_surfaces + i],
-				     fb->strides[num_surfaces + i]);
-	}
+	num_surfaces = intel_num_surfaces(fb);
+
+	for (i = 0; i < intel_num_ccs_surfaces(fb); i++)
+		init_buf_ccs(buf, i,
+			     fb->offsets[num_surfaces + i],
+			     fb->strides[num_surfaces + i]);
 
 	igt_assert(fb->offsets[0] == 0);
 	for (i = 0; i < num_surfaces; i++) {
-- 
2.44.2


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-10-12 13:17 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-23 21:36 [PATCH i-g-t] lib/igt_fb: Fix intel_buf surface init Ville Syrjala
2024-09-26  0:17 ` ✗ CI.xeBAT: failure for " Patchwork
2024-09-26  0:19 ` ✗ Fi.CI.BAT: " Patchwork
2024-09-26  5:30 ` ✗ CI.xeFULL: " Patchwork
2024-09-27 17:28 ` ✗ Fi.CI.BAT: failure for lib/igt_fb: Fix intel_buf surface init (rev2) Patchwork
2024-09-27 18:25 ` ✓ CI.xeBAT: success " Patchwork
2024-09-30 17:17 ` ✓ Fi.CI.BAT: success for lib/igt_fb: Fix intel_buf surface init (rev3) Patchwork
2024-09-30 17:35 ` ✗ CI.xeBAT: failure " Patchwork
2024-09-30 22:27 ` ✗ CI.xeFULL: " Patchwork
2024-10-01  2:13 ` ✗ Fi.CI.IGT: " Patchwork
2024-10-04 11:00 ` [PATCH i-g-t] lib/igt_fb: Fix intel_buf surface init Juha-Pekka Heikkila
2024-10-11 18:18 ` ✓ Fi.CI.BAT: success for lib/igt_fb: Fix intel_buf surface init (rev4) Patchwork
2024-10-11 18:35 ` ✓ CI.xeBAT: " Patchwork
2024-10-11 23:55 ` ✗ CI.xeFULL: failure " Patchwork
2024-10-12 13:17 ` ✗ Fi.CI.IGT: " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox