[PATCH i-g-t v5 5/8] benchmarks/kms_fb_stress: Move FB creation to a separate function
Arthur Grillo
arthurgrillo at riseup.net
Mon Apr 22 22:18:20 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.
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 433e751273e6..e028424bb3e4 100644
--- a/benchmarks/kms_fb_stress.c
+++ b/benchmarks/kms_fb_stress.c
@@ -46,26 +46,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.44.0
More information about the igt-dev
mailing list