[PATCH i-g-t v6 08/12] benchmarks/kms_fb_stress: Add enable switches for every plane

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


In the future, we would like to separately enable each plane depending
on the benchmark, so create an enable flag on each plane.

Signed-off-by: Arthur Grillo <arthurgrillo at riseup.net>
---
 benchmarks/kms_fb_stress.c | 69 +++++++++++++++++++++++++++++-----------------
 1 file changed, 44 insertions(+), 25 deletions(-)

diff --git a/benchmarks/kms_fb_stress.c b/benchmarks/kms_fb_stress.c
index 6f70f201be0d..45e03f97919a 100644
--- a/benchmarks/kms_fb_stress.c
+++ b/benchmarks/kms_fb_stress.c
@@ -18,6 +18,7 @@ struct plane_t {
 	struct rect_t rect;
 	uint32_t format;
 	struct igt_fb fbs[NUM_FBS];
+	bool enable;
 };
 
 struct kms_t {
@@ -76,13 +77,18 @@ static void gen_fbs(struct data_t *data)
 	kms->writeback.rect.height = mode->vdisplay;
 
 	for (int i = 0; i < NUM_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);
-
-		igt_create_fb(data->fd, kms->writeback.rect.width, kms->writeback.rect.height,
-			      kms->writeback.format, DRM_FORMAT_MOD_LINEAR,
-			      &kms->writeback.fbs[i]);
+		if (kms->primary.enable)
+			create_fb(data->fd, &kms->primary, i, !i, i, i);
+		if (kms->overlay_a.enable)
+			create_fb(data->fd, &kms->overlay_a, i, i, !i, i);
+		if (kms->overlay_b.enable)
+			create_fb(data->fd, &kms->overlay_b, i, i, i, !i);
+
+		if (kms->writeback.enable)
+			igt_create_fb(data->fd, kms->writeback.rect.width,
+				      kms->writeback.rect.height,
+				      kms->writeback.format, DRM_FORMAT_MOD_LINEAR,
+				      &kms->writeback.fbs[i]);
 	}
 }
 
@@ -151,17 +157,19 @@ static void stress_driver(struct data_t *data)
 	for (int i = 0; i < FRAME_COUNT; i++) {
 		int fb_index = i % NUM_FBS;
 
-		plane_setup(&data->kms.primary, fb_index);
-
-		plane_setup(&data->kms.overlay_a, fb_index);
-
-		plane_setup(&data->kms.overlay_b, fb_index);
-
-		igt_output_set_writeback_fb(data->wb_output, &data->kms.writeback.fbs[fb_index]);
+		if (data->kms.primary.enable)
+			plane_setup(&data->kms.primary, fb_index);
+		if (data->kms.overlay_a.enable)
+			plane_setup(&data->kms.overlay_a, fb_index);
+		if (data->kms.overlay_b.enable)
+			plane_setup(&data->kms.overlay_b, fb_index);
+		if (data->kms.writeback.enable)
+			igt_output_set_writeback_fb(data->wb_output,
+						    &data->kms.writeback.fbs[fb_index]);
 
 		igt_display_commit2(&data->display, COMMIT_ATOMIC);
 
-		if (data->wb_output->writeback_out_fence_fd != -1) {
+		if (data->kms.writeback.enable && data->wb_output->writeback_out_fence_fd != -1) {
 			close(data->wb_output->writeback_out_fence_fd);
 			data->wb_output->writeback_out_fence_fd = -1;
 		}
@@ -170,16 +178,24 @@ static void stress_driver(struct data_t *data)
 	igt_assert_eq(igt_gettime(&now), 0);
 	elapsed = igt_time_elapsed(&then, &now);
 
-	igt_plane_set_fb(data->kms.primary.base, NULL);
-	igt_plane_set_fb(data->kms.overlay_a.base, NULL);
-	igt_plane_set_fb(data->kms.overlay_b.base, NULL);
-	igt_output_set_writeback_fb(data->wb_output, NULL);
+	if (data->kms.primary.enable)
+		igt_plane_set_fb(data->kms.primary.base, NULL);
+	if (data->kms.overlay_a.enable)
+		igt_plane_set_fb(data->kms.overlay_a.base, NULL);
+	if (data->kms.overlay_b.enable)
+		igt_plane_set_fb(data->kms.overlay_b.base, NULL);
+	if (data->kms.writeback.enable)
+		igt_output_set_writeback_fb(data->wb_output, NULL);
 
 	for (int i = 0; i < NUM_FBS; i++) {
-		igt_remove_fb(data->fd, &data->kms.primary.fbs[i]);
-		igt_remove_fb(data->fd, &data->kms.overlay_a.fbs[i]);
-		igt_remove_fb(data->fd, &data->kms.overlay_b.fbs[i]);
-		igt_remove_fb(data->fd, &data->kms.writeback.fbs[i]);
+		if (data->kms.primary.enable)
+			igt_remove_fb(data->fd, &data->kms.primary.fbs[i]);
+		if (data->kms.overlay_a.enable)
+			igt_remove_fb(data->fd, &data->kms.overlay_a.fbs[i]);
+		if (data->kms.overlay_b.enable)
+			igt_remove_fb(data->fd, &data->kms.overlay_b.fbs[i]);
+		if (data->kms.writeback.enable)
+			igt_remove_fb(data->fd, &data->kms.writeback.fbs[i]);
 	}
 
 	igt_display_commit2(&data->display, COMMIT_ATOMIC);
@@ -269,11 +285,14 @@ igt_main
 	}
 
 	igt_subtest("default-stress") {
-		stress_driver(&data);
+		data.kms.primary.enable = true;
+		data.kms.overlay_a.enable = true;
+		data.kms.overlay_b.enable = true;
+		data.kms.writeback.enable = true;
 
+		stress_driver(&data);
 	}
 
-
 	igt_fixture {
 		igt_display_fini(&data.display);
 		drm_close_driver(data.fd);

-- 
2.46.0



More information about the igt-dev mailing list