[PATCH 7/7] compositor-drm: Add option to delay the loading of the gl-renderer

Ander Conselvan de Oliveira ander.conselvan.de.oliveira at intel.com
Fri Oct 25 15:26:37 CEST 2013


When using the renderer switch feature, the normal start up path and
the loading of gl-renderer and dependency libraries will compete for
IO bandwidth. In systems where that is limited, this may impact the
time it takes to get an image to the screen negatively.

This patch adds an option to delay the loading of the gl-renderer for
a number of seconds, to avoid the competition for IO. The delay is
chosen instead of simply starting the load as soon as the system is
running to provide more flexibility to system integrators. That way
they can choose this delay based on other factors on the system.
---
 man/weston-drm.man   |    7 +++++++
 src/compositor-drm.c |   12 ++++++++++--
 src/compositor.c     |    1 +
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/man/weston-drm.man b/man/weston-drm.man
index 035bace..2b97b39 100644
--- a/man/weston-drm.man
+++ b/man/weston-drm.man
@@ -111,6 +111,13 @@ instead of using the current tty.
 Start using the pixman renderer and later switch to the GL one. This
 should cause the system to able to render earlier when running from
 cold boot and slow storage.
+.TP
+\fB \-\-gl\-delay\fR=\fIdelay\fR
+When running with
+.BR \-\-fast\-start ,
+wait for
+.I delay
+seconds before loading the gl renderer.
 .
 .\" ***************************************************************
 .SH ENVIRONMENT
diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 5130278..00fcede 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -209,6 +209,7 @@ struct drm_parameters {
 	int tty;
 	int use_pixman;
 	int fast_start;
+	int gl_delay;
 	const char *seat_id;
 };
 
@@ -2645,6 +2646,7 @@ switch_to_gl_renderer(struct drm_compositor *c)
 struct gl_loader_thread_data {
 	int drm_fd;
 	int done_fd;
+	int delay;
 };
 
 static void *
@@ -2653,6 +2655,10 @@ gl_loader_thread_func(void *data)
 	struct gl_loader_thread_data *gl_data = data;
 	struct gbm_device *gbm;
 
+	/* Wait for a few seconds so that the loading doesn't steal the IO
+	 * bandwidth from the rest of the start up */
+	sleep(gl_data->delay);
+
 	gbm = create_gbm_device(gl_data->drm_fd);
 
 	if (write(gl_data->done_fd, "done", 4) != 4)
@@ -2687,7 +2693,7 @@ done:
 }
 
 static int
-prepare_renderer_switch(struct drm_compositor *ec)
+prepare_renderer_switch(struct drm_compositor *ec, int delay)
 {
 	struct gl_loader_thread_data *gl_data;
 	struct wl_event_loop *loop;
@@ -2702,6 +2708,7 @@ prepare_renderer_switch(struct drm_compositor *ec)
 
 	gl_data->drm_fd = ec->drm.fd;
 	gl_data->done_fd = sv[1];
+	gl_data->delay = delay;
 
 	pthread_create(&ec->gl_loader_thread, NULL,
 		       gl_loader_thread_func, gl_data);
@@ -2798,7 +2805,7 @@ drm_compositor_create(struct wl_display *display,
 
 	if (ec->use_pixman) {
 		if (param->fast_start)
-			prepare_renderer_switch(ec);
+			prepare_renderer_switch(ec, param->gl_delay);
 
 		if (init_pixman(ec) < 0) {
 			weston_log("failed to initialize pixman renderer\n");
@@ -2908,6 +2915,7 @@ backend_init(struct wl_display *display, int *argc, char *argv[],
 		{ WESTON_OPTION_BOOLEAN, "current-mode", 0, &option_current_mode },
 		{ WESTON_OPTION_BOOLEAN, "use-pixman", 0, &param.use_pixman },
 		{ WESTON_OPTION_BOOLEAN, "fast-start", 0, &param.fast_start },
+		{ WESTON_OPTION_INTEGER, "gl-delay", 0, &param.gl_delay },
 	};
 
 	param.seat_id = default_seat;
diff --git a/src/compositor.c b/src/compositor.c
index d11f765..f97da69 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -3601,6 +3601,7 @@ usage(int error_code)
 		"  --tty=TTY\t\tThe tty to use\n"
 		"  --use-pixman\t\tUse the pixman (CPU) renderer\n"
 		"  --fast-start\t\tStart with pixman renderer and later switch to GL\n"
+		"  --gl-delay=S\t\tWait for S secs to load gl renderer (needs --fast-start)\n"
 		"  --current-mode\tPrefer current KMS mode over EDID preferred mode\n\n");
 
 	fprintf(stderr,
-- 
1.7.9.5



More information about the wayland-devel mailing list