From 32c9cb1bf3b759c6ba73436714a8a501e7f91fc5 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 18 Dec 2020 15:04:28 +0000 Subject: [PATCH] c/main: Make sure to close sync handles on layer_commit --- src/xrt/compositor/main/comp_compositor.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/xrt/compositor/main/comp_compositor.c b/src/xrt/compositor/main/comp_compositor.c index d85ce0639..5caa18c17 100644 --- a/src/xrt/compositor/main/comp_compositor.c +++ b/src/xrt/compositor/main/comp_compositor.c @@ -60,6 +60,11 @@ #include #include +#ifdef XRT_GRAPHICS_SYNC_HANDLE_IS_FD +#include +#endif + + #define WINDOW_TITLE "Monado" static double @@ -465,10 +470,19 @@ compositor_layer_commit(struct xrt_compositor *xc, { struct comp_compositor *c = comp_compositor(xc); - assert(!xrt_graphics_sync_handle_is_valid(sync_handle)); - COMP_SPEW(c, "LAYER_COMMIT at %8.3fms", ts_ms()); +#ifdef XRT_GRAPHICS_SYNC_HANDLE_IS_FD + // Need to consume this handle. + if (xrt_graphics_sync_handle_is_valid(sync_handle)) { + close(sync_handle); + sync_handle = XRT_GRAPHICS_SYNC_HANDLE_INVALID; + } +#else +#error "Not yet implemented for this platform" +#endif + + // Always zero for now. uint32_t slot_id = 0; uint32_t num_layers = c->slots[slot_id].num_layers;