[PATCH i-g-t v6 05/12] benchmarks/kms_fb_stress: Move FB creation to a separate function

Arthur Grillo arthurgrillo at riseup.net
Fri Sep 13 00:39:29 UTC 2024


In the future, we want to add more logic to the FB creation. So, to
reduce code repetition, move the procedure to its own function.

Reviewed-by: Louis Chauvet <louis.chauvet at bootlin.com>
Tested-by: Louis Chauvet <louis.chauvet at bootlin.com>
Signed-off-by: Arthur Grillo <arthurgrillo at riseup.net>
---
 benchmarks/kms_fb_stress.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/benchmarks/kms_fb_stress.c b/benchmarks/kms_fb_stress.c
index 1e79af897ecc..25673d57f593 100644
--- a/benchmarks/kms_fb_stress.c
+++ b/benchmarks/kms_fb_stress.c
@@ -43,26 +43,23 @@ static void plane_setup(struct plane_t *plane, int index)
 	igt_plane_set_fb(plane->base, &plane->fbs[index]);
 }
 
+static void create_fb(int fd, struct plane_t *plane, int fb_index, double r, double g, double b)
+{
+	igt_create_color_fb(fd, plane->rect.width, plane->rect.height,
+			    plane->format, DRM_FORMAT_MOD_LINEAR,
+			    r, g, b,
+			    &plane->fbs[fb_index]);
+}
+
 static void gen_fbs(struct data_t *data)
 {
 	struct kms_t *kms = &data->kms;
 	drmModeModeInfo *mode = igt_output_get_mode(data->wb_output);
 
 	for (int i = 0; i < NUM_FBS; i++) {
-		igt_create_color_fb(data->fd, kms->primary.rect.width, kms->primary.rect.height,
-				    kms->primary.format, DRM_FORMAT_MOD_LINEAR,
-				    !i, i, i,
-				    &kms->primary.fbs[i]);
-
-		igt_create_color_fb(data->fd, kms->overlay_a.rect.width, kms->overlay_a.rect.height,
-				    kms->overlay_a.format, DRM_FORMAT_MOD_LINEAR,
-				    i, !i, i,
-				    &kms->overlay_a.fbs[i]);
-
-		igt_create_color_fb(data->fd, kms->overlay_b.rect.width, kms->overlay_b.rect.height,
-				    kms->overlay_b.format, DRM_FORMAT_MOD_LINEAR,
-				    i, i, !i,
-				    &kms->overlay_b.fbs[i]);
+		create_fb(data->fd, &kms->primary, i, !i, i, i);
+		create_fb(data->fd, &kms->overlay_a, i, i, !i, i);
+		create_fb(data->fd, &kms->overlay_b, i, i, i, !i);
 
 		kms->writeback.rect.width = mode->hdisplay;
 		kms->writeback.rect.height = mode->vdisplay;

-- 
2.46.0



More information about the igt-dev mailing list