[PATCH 5/6] clients: Fix a few issues in simple-dmabuf-intel

Emmanuel Gil Peyrot emmanuel.peyrot at collabora.com
Tue Nov 24 11:28:28 PST 2015


Those were found while working on simple-dmabuf-v4l, as found in the
next patch of this series.

After each buffer’s params were ready to be submitted to the
compositor, a roundtrip was done, which is wasteful since we can do it
only once after having queued all the params we want.  Removing those
nested roundtrips also prevent the potentially dangerous side-effect of
calling callbacks for later events while previous events were still
being processed.

Signed-off-by: Emmanuel Gil Peyrot <emmanuel.peyrot at collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
Reviewed-by: Daniel Stone <daniels at collabora.com>

Differential Revision: https://phabricator.freedesktop.org/D344
---
 clients/simple-dmabuf-intel.c | 41 +++++++++++++++++++----------------------
 1 file changed, 19 insertions(+), 22 deletions(-)

diff --git a/clients/simple-dmabuf-intel.c b/clients/simple-dmabuf-intel.c
index f371d80..0ceefeb 100644
--- a/clients/simple-dmabuf-intel.c
+++ b/clients/simple-dmabuf-intel.c
@@ -35,9 +35,9 @@
 #include <fcntl.h>
 
 #include <xf86drm.h>
-#include <libdrm/i915_drm.h>
-#include <libdrm/intel_bufmgr.h>
-#include <libdrm/drm_fourcc.h>
+#include <i915_drm.h>
+#include <intel_bufmgr.h>
+#include <drm_fourcc.h>
 
 #include <wayland-client.h>
 #include "xdg-shell-unstable-v5-client-protocol.h"
@@ -204,6 +204,7 @@ create_failed(void *data, struct zwp_linux_buffer_params_v1 *params)
 	struct buffer *buffer = data;
 
 	buffer->buffer = NULL;
+	running = 0;
 
 	zwp_linux_buffer_params_v1_destroy(params);
 
@@ -274,13 +275,6 @@ create_dmabuf_buffer(struct display *display, struct buffer *buffer,
 					  DRM_FORMAT_XRGB8888,
 					  flags);
 
-	/* params is destroyed by the event handlers */
-
-	wl_display_roundtrip(display->display);
-	if (buffer->buffer == NULL) {
-		goto error2;
-	}
-
 	return 0;
 
 error2:
@@ -313,6 +307,8 @@ static struct window *
 create_window(struct display *display, int width, int height)
 {
 	struct window *window;
+	int i;
+	int ret;
 
 	window = calloc(1, sizeof *window);
 	if (!window)
@@ -344,6 +340,14 @@ create_window(struct display *display, int width, int height)
 		assert(0);
 	}
 
+	for (i = 0; i < 2; ++i) {
+		ret = create_dmabuf_buffer(display, &window->buffers[i],
+		                               width, height);
+
+		if (ret < 0)
+			return NULL;
+	}
+
 	return window;
 }
 
@@ -375,7 +379,6 @@ static struct buffer *
 window_next_buffer(struct window *window)
 {
 	struct buffer *buffer;
-	int ret = 0;
 
 	if (!window->buffers[0].busy)
 		buffer = &window->buffers[0];
@@ -384,14 +387,6 @@ window_next_buffer(struct window *window)
 	else
 		return NULL;
 
-	if (!buffer->buffer) {
-		ret = create_dmabuf_buffer(window->display, buffer,
-					   window->width, window->height);
-
-		if (ret < 0)
-			return NULL;
-	}
-
 	return buffer;
 }
 
@@ -574,9 +569,11 @@ main(int argc, char **argv)
 	sigint.sa_flags = SA_RESETHAND;
 	sigaction(SIGINT, &sigint, NULL);
 
-	/* Initialise damage to full surface, so the padding gets painted */
-	wl_surface_damage(window->surface, 0, 0,
-			  window->width, window->height);
+	/* Here we retrieve the linux-dmabuf objects, or error */
+	wl_display_roundtrip(display->display);
+
+	if (!running)
+		return 1;
 
 	redraw(window, NULL, 0);
 
-- 
2.6.2



More information about the wayland-devel mailing list