[PATCH 3/3] gl-renderer: Attach buffer during surface state creation if possible

Ander Conselvan de Oliveira conselvan2 at gmail.com
Tue Nov 19 01:30:12 PST 2013

From: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com>

When a renderer switch happens, it is possible that when the surface
state is created, a buffer for the given surface is already available.
In that case, run the attach routine so that the pixel contents are
properly set. Otherwise, it would only be set when a new attach request
is made for that surface.

This makes the renderer transition seamless, without leaving a black
screen as before. (As long as --disable-early-buffer-release is passed
to compositor-drm).
 man/weston-drm.man |    5 +++--
 src/gl-renderer.c  |    8 +++++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/man/weston-drm.man b/man/weston-drm.man
index d3d0b70..0c5f6de 100644
--- a/man/weston-drm.man
+++ b/man/weston-drm.man
@@ -110,8 +110,9 @@ instead of using the current tty.
 .B \-\-disable\-early\-buffer\-release
 Don't release buffers early and instead keep references to them as
 long as any surface uses them, even if the compositor has an
-internal copy of the buffer contents. This causes some clients to
-allocate more memory than necessary.
+internal copy of the buffer contents. This prevents artifacts when
+doing a renderer switch, but causes some clients to allocate more
+memory than necessary.
 .\" ***************************************************************
diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index 5e1b396..218fca4 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -883,7 +883,8 @@ gl_renderer_flush_damage(struct weston_surface *surface)
 	if (!texture_used)
-	if (!pixman_region32_not_empty(&gs->texture_damage))
+	if (!pixman_region32_not_empty(&gs->texture_damage) &&
+	    !gs->needs_full_upload)
 		goto done;
 	switch (wl_shm_buffer_get_format(buffer->shm_buffer)) {
@@ -1240,6 +1241,11 @@ gl_renderer_create_surface(struct weston_surface *surface)
+	if (surface->buffer_ref.buffer) {
+		gl_renderer_attach(surface, surface->buffer_ref.buffer);
+		gl_renderer_flush_damage(surface);
+	}
 	return 0;

More information about the wayland-devel mailing list