From 5e039dbf8ecf8a4dae4b40e4fb5ac272c7349554 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 17 Mar 2023 14:23:29 -0600 Subject: [PATCH] gallium/xlib: call fence_finish() in XMesaSwapBuffers() Before we can present the buffer we need to wait for the fence to finish. This fixes severe flickering of unfinished rendering in many demos/tests. This has been broken for a while, I think. Note, this is for the non-DRI / Xlib-based GLX. Signed-off-by: Brian Paul Part-of: --- src/gallium/frontends/glx/xlib/xm_api.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gallium/frontends/glx/xlib/xm_api.c b/src/gallium/frontends/glx/xlib/xm_api.c index 458c56c..9599741 100644 --- a/src/gallium/frontends/glx/xlib/xm_api.c +++ b/src/gallium/frontends/glx/xlib/xm_api.c @@ -1343,7 +1343,16 @@ void XMesaSwapBuffers( XMesaBuffer b ) } if (xmctx && xmctx->xm_buffer == b) { - st_context_flush(xmctx->st, ST_FLUSH_FRONT, NULL, NULL, NULL); + struct pipe_fence_handle *fence = NULL; + st_context_flush(xmctx->st, ST_FLUSH_FRONT, &fence, NULL, NULL); + /* Wait until all rendering is complete */ + if (fence) { + XMesaDisplay xmdpy = xmesa_init_display(b->xm_visual->display); + struct pipe_screen *screen = xmdpy->screen; + xmdpy->screen->fence_finish(screen, NULL, fence, + PIPE_TIMEOUT_INFINITE); + xmdpy->screen->fence_reference(screen, &fence, NULL); + } } xmesa_swap_st_framebuffer(b->drawable); -- 2.7.4