[PATCH i-g-t 8/9] tests/kms_plane: Allow choosing the number of colors when drawing the color array
Louis Chauvet
louis.chauvet at bootlin.com
Wed Mar 6 17:28:42 UTC 2024
To test different formats, it can be useful to pass a custom list of
colors. For example with the grayscale formats, the red/green/blue
components alone don't have any meaning and it's better to test multiple
gray values. This patch edit the fill algorithm to use custom color list.
Signed-off-by: Louis Chauvet <louis.chauvet at bootlin.com>
---
tests/kms_plane.c | 64 +++++++++++++++++++++++++++++++++----------------------
1 file changed, 38 insertions(+), 26 deletions(-)
diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index 2baaeef7bbc8..8e92d2e13993 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -582,10 +582,16 @@ static bool set_c8_legacy_lut(data_t *data, enum pipe pipe,
return true;
}
-static void draw_entire_color_array(data_t *data, cairo_t *cr, uint32_t format,
- struct igt_fb *fb)
+/*
+ * draw_color_array() - Draw a color array on a plane, respecting the requested cropping
+ *
+ * @data, @cr, @format, @fb: Description of the framebuffer
+ * @colors: list of colors to draw
+ * @color_count: number of colors to draw
+ */
+static void draw_color_array(data_t *data, cairo_t *cr, uint32_t format,
+ struct igt_fb *fb, const color_t *colors, int color_count)
{
- 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;
@@ -605,21 +611,32 @@ static void draw_entire_color_array(data_t *data, cairo_t *cr, uint32_t format,
margin + m * step_y,
step_x,
step_y,
- colors_extended[color_index].red,
- colors_extended[color_index].green,
- colors_extended[color_index].blue);
+ colors[color_index].red,
+ colors[color_index].green,
+ colors[color_index].blue);
}
}
}
+
+/**
+ * prepare_format_color() - Fill a plane with a specific color or pattern
+ *
+ * @data: Generic data for this test
+ * @pipe, @plane, @format, @modifier, @width, @height, @color_encoding, @color_range, @fb: description of the plane
+ * @colors: Color list to display on this plane
+ * @color_count: Number of color in the list
+ *
+ * At least one color must be given
+ */
static void prepare_format_color(data_t *data, enum pipe pipe,
igt_plane_t *plane,
uint32_t format, uint64_t modifier,
int width, int height,
enum igt_color_encoding color_encoding,
enum igt_color_range color_range,
- const color_t *c, struct igt_fb *fb,
- bool packed)
+ struct igt_fb *fb, const color_t *colors,
+ int color_count)
{
cairo_t *cr;
const int localcrop = format == DRM_FORMAT_XRGB8888 ? 0 : data->crop;
@@ -640,17 +657,12 @@ static void prepare_format_color(data_t *data, enum pipe pipe,
igt_paint_color(cr, 0, 0,
width + localcrop * 2,
height + localcrop * 2,
- 1.0f - c->red,
- 1.0f - c->green,
- 1.0f - c->blue);
+ 1.0f - colors[0].red,
+ 1.0f - colors[0].green,
+ 1.0f - colors[0].blue);
- if (packed)
- draw_entire_color_array(data, cr, format, fb);
- else
- igt_paint_color(cr, localcrop, localcrop,
- width, height,
- c->red, c->green, c->blue);
+ draw_color_array(data, cr, format, fb, colors, color_count);
igt_put_cairo_ctx(cr);
igt_plane_set_fb(plane, fb);
@@ -700,13 +712,13 @@ static void capture_format_crcs_single(data_t *data, enum pipe pipe,
int width, int height,
enum igt_color_encoding encoding,
enum igt_color_range range,
- igt_crc_t crc[], struct igt_fb *fb)
+ igt_crc_t crc[], struct igt_fb *fb,
+ const color_t *colors, int color_count)
{
struct igt_fb old_fb = *fb;
- const color_t black = { 0.0f, 0.0f, 0.0f };
prepare_format_color(data, pipe, plane, format, modifier,
- width, height, encoding, range, &black, fb, true);
+ width, height, encoding, range, fb, colors, color_count);
igt_display_commit2(&data->display, data->display.is_atomic ?
COMMIT_ATOMIC : COMMIT_UNIVERSAL);
@@ -729,20 +741,20 @@ static void capture_format_crcs_multiple(data_t *data, enum pipe pipe,
int i;
/* Also run single colors to capture more failures */
- capture_format_crcs_single(data, pipe, plane, format, modifier, width, height, encoding, range, crc, fb);
+ capture_format_crcs_single(data, pipe, plane, format, modifier, width, height, encoding, range, crc, fb,
+ colors_extended, ARRAY_SIZE(colors_extended));
/* Skip the first crc as it's taken by "capture_format_crcs_single" */
crc = crc + 1;
restart_round:
for (i = 0; i < data->num_colors; i++) {
- const color_t *c = &data->colors[i];
struct igt_fb old_fb = *fb;
int ret;
prepare_format_color(data, pipe, plane, format, modifier,
- width, height, encoding, range, c, fb,
- false);
+ width, height, encoding, range, fb,
+ &data->colors[i], 1);
if (data->display.is_atomic && i >= 1) {
igt_assert(read(data->drm_fd, &ev, sizeof(ev)) == sizeof(ev));
@@ -873,7 +885,7 @@ static bool test_format_plane_colors(data_t *data, enum pipe pipe,
} else {
capture_format_crcs_single(data, pipe, plane, format, modifier,
width, height, encoding, range, crc,
- fb);
+ fb, colors_extended, ARRAY_SIZE(colors_extended));
}
for (i = 0; i < total_crcs; i++) {
@@ -1062,7 +1074,7 @@ static bool test_format_plane(data_t *data, enum pipe pipe,
capture_format_crcs_single(data, pipe, plane, ref.format, ref.modifier,
width, height, IGT_COLOR_YCBCR_BT709,
IGT_COLOR_YCBCR_LIMITED_RANGE,
- ref_crc[SINGLE_CRC_SET], &fb);
+ ref_crc[SINGLE_CRC_SET], &fb, colors_extended, ARRAY_SIZE(colors_extended));
capture_format_crcs_multiple(data, pipe, plane, ref.format, ref.modifier,
width, height, IGT_COLOR_YCBCR_BT709,
--
2.43.0
More information about the igt-dev
mailing list