[PATCH i-g-t 5/9] tests/kms_plane: Use a complex pattern to test plane color conversion.

Louis Chauvet louis.chauvet at bootlin.com
Wed Mar 6 17:28:39 UTC 2024


The capture_format_crcs_single helper uses a "line pattern" with all the
colors in the color list. It is useful to make quick test of color
conversion (only one plane to render, not one per color).

To help detecting issues, this "line pattern" is replaced by a
"square pattern". It is useful for complex formats like YUV where the
iteration on each pixel is not a trivial "ptr++".

The kind of issue which can be detected can be found in [1]. The tests
were all "SUCCESS" despite a wrong pixel iteration. With the "square"
pattern, it is now more difficult to have a test "SUCCESS" if the pixel
iteration is not correct.

[1]: https://lore.kernel.org/dri-devel/ZbvXV-1hrfXLcvC3@localhost.localdomain/

Signed-off-by: Louis Chauvet <louis.chauvet at bootlin.com>
---
 tests/kms_plane.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index 9757c6e44325..f0be09b8e506 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -585,8 +585,11 @@ static bool set_c8_legacy_lut(data_t *data, enum pipe pipe,
 static void draw_entire_color_array(data_t *data, cairo_t *cr, uint32_t format,
 				    struct igt_fb *fb)
 {
-	const int color_amount = ARRAY_SIZE(colors_extended);
-	const int x = format == DRM_FORMAT_XRGB8888 ? 0 : data->crop;
+	const int color_count = ARRAY_SIZE(colors_extended);
+	const int margin = format == DRM_FORMAT_XRGB8888 ? 0 : data->crop;
+	const int step_x = (fb->width - margin * 2) / color_count;
+	const int step_y = (fb->height - margin * 2) / color_count;
+	int color_index;
 
 	if (format != DRM_FORMAT_XRGB8888) {
 		cairo_rectangle(cr, data->crop, data->crop,
@@ -594,16 +597,18 @@ static void draw_entire_color_array(data_t *data, cairo_t *cr, uint32_t format,
 				fb->height - data->crop * 2);
 	}
 
-
-	for (int n = 0; n < color_amount; n++) {
-		int y = (fb->height - x * 2) * n / color_amount + x;
-
-		igt_paint_color(cr, x, y,
-				fb->width - x * 2,
-				(fb->height - x * 2) / color_amount + 1,
-				colors_extended[n].red,
-				colors_extended[n].green,
-				colors_extended[n].blue);
+	for (int n = 0; n < color_count; n++) {
+		for (int m = 0; m < color_count; m++) {
+			color_index = (n + m) % color_count;
+			igt_paint_color(cr,
+					margin + n * step_x,
+					margin + m * step_y,
+					step_x,
+					step_y,
+					colors_extended[color_index].red,
+					colors_extended[color_index].green,
+					colors_extended[color_index].blue);
+		}
 	}
 }
 

-- 
2.43.0



More information about the igt-dev mailing list