Module: Mesa Branch: main Commit: 5e039dbf8ecf8a4dae4b40e4fb5ac272c7349554 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5e039dbf8ecf8a4dae4b40e4fb5ac272c7349554
Author: Brian Paul <[email protected]> Date: Fri Mar 17 14:23:29 2023 -0600 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 <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21993> --- 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 458c56c1075..95997418d3b 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);
