From: Brian Paul Date: Fri, 17 Mar 2023 20:23:29 +0000 (-0600) Subject: gallium/xlib: call fence_finish() in XMesaSwapBuffers() X-Git-Tag: upstream/23.3.3~11409 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5e039dbf8ecf8a4dae4b40e4fb5ac272c7349554;p=platform%2Fupstream%2Fmesa.git 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: --- 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);