[PATCH] Wayland: Use the thread affinity for the display
Jørgen Lind
jorgen.lind at nokia.com
Fri Feb 10 05:34:17 PST 2012
So that we catch if we can call wl_display_iterate, or if we have to
wait for some other thread to call wl_display_iterate
---
.../state_trackers/egl/wayland/native_wayland.c | 16 ++++++++++++++--
.../state_trackers/egl/wayland/native_wayland.h | 3 +++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/gallium/state_trackers/egl/wayland/native_wayland.c b/src/gallium/state_trackers/egl/wayland/native_wayland.c
index dfaa50f..93fffe5 100644
--- a/src/gallium/state_trackers/egl/wayland/native_wayland.c
+++ b/src/gallium/state_trackers/egl/wayland/native_wayland.c
@@ -244,8 +244,14 @@ static void
wayland_frame_callback(void *data, struct wl_callback *callback, uint32_t time)
{
struct wayland_surface *surface = data;
+ int sem_count;
surface->block_swap_buffers = FALSE;
+ /* FIXME: print internal error */
+ if (sem_getvalue(&surface->block_swap_buffers_sem, &sem_count))
+ return;
+ if (sem_count < 1)
+ sem_post(&surface->block_swap_buffers_sem);
wl_callback_destroy(callback);
}
@@ -271,8 +277,13 @@ wayland_surface_swap_buffers(struct native_surface *nsurf)
struct wayland_display *display = surface->display;
struct wl_callback *callback;
- while (surface->block_swap_buffers)
- wl_display_iterate(display->dpy, WL_DISPLAY_READABLE);
+ while (surface->block_swap_buffers) {
+ if (wl_display_thread(display->dpy) == pthread_self()) {
+ wl_display_iterate(display->dpy, WL_DISPLAY_READABLE);
+ } else {
+ sem_wait(&surface->block_swap_buffers_sem);
+ }
+ }
surface->block_swap_buffers = TRUE;
@@ -454,6 +465,7 @@ wayland_create_window_surface(struct native_display *ndpy,
surface->pending_resource = NULL;
surface->block_swap_buffers = FALSE;
+ sem_init(&surface->block_swap_buffers_sem, 0, 0);
surface->type = WL_WINDOW_SURFACE;
surface->buffer[WL_BUFFER_FRONT] = NULL;
diff --git a/src/gallium/state_trackers/egl/wayland/native_wayland.h b/src/gallium/state_trackers/egl/wayland/native_wayland.h
index e6a914f..64ba2ba 100644
--- a/src/gallium/state_trackers/egl/wayland/native_wayland.h
+++ b/src/gallium/state_trackers/egl/wayland/native_wayland.h
@@ -34,6 +34,8 @@
#include "wayland-egl-priv.h"
+#include <semaphore.h>
+
struct wayland_surface;
enum wayland_format_flag {
@@ -86,6 +88,7 @@ struct wayland_surface {
unsigned int attachment_mask;
boolean block_swap_buffers;
+ sem_t block_swap_buffers_sem;
boolean premultiplied_alpha;
};
--
1.7.5.4
--VS++wcV0S1rZb1Fb--
More information about the wayland-devel
mailing list