From: Rémi Bernon <rbernon@codeweavers.com> Instead of doing for every flush, which might happen more often than necessary, as they are shared with some additional GL operations for the memory DCs. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=59147 --- dlls/win32u/opengl.c | 6 +++--- dlls/winex11.drv/opengl.c | 2 ++ include/wine/opengl_driver.h | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 51d386b1bc2..23ea61a207d 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -162,8 +162,7 @@ static void opengl_drawable_flush( struct opengl_drawable *drawable, int interva flags = GL_FLUSH_INTERVAL; } - if (flags || InterlockedCompareExchange( &drawable->client->offscreen, 0, 0 )) - drawable->funcs->flush( drawable, flags ); + if (flags) drawable->funcs->flush( drawable, flags ); } static BOOL opengl_drawable_swap( struct opengl_drawable *drawable ) @@ -1705,7 +1704,7 @@ static BOOL context_sync_drawables( struct wgl_context *context, HDC draw_hdc, H if (new_read != new_draw) opengl_drawable_set_context( new_draw, context ); opengl_drawable_flush( new_read, new_read->interval, 0 ); - opengl_drawable_flush( new_draw, new_draw->interval, 0 ); + opengl_drawable_flush( new_draw, new_draw->interval, GL_FLUSH_PRESENT ); } if (ret) @@ -2283,6 +2282,7 @@ static BOOL win32u_wgl_context_flush( struct wgl_context *context, void (*flush) if (flush) flush(); if (flush == funcs->p_glFinish) flags |= GL_FLUSH_FINISHED; + if (flush && !force_swap) flags |= GL_FLUSH_PRESENT; opengl_drawable_flush( draw, interval, flags ); if (force_swap) opengl_drawable_swap( draw ); diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index f3fe7690118..01eb3b9c356 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -1209,6 +1209,7 @@ static void x11drv_surface_flush( struct opengl_drawable *base, UINT flags ) TRACE( "%s flags %#x\n", debugstr_opengl_drawable( base ), flags ); if (flags & GL_FLUSH_INTERVAL) set_swap_interval( gl, base->interval ); + if (!(flags & GL_FLUSH_PRESENT)) return; if (InterlockedCompareExchange( &base->client->offscreen, 0, 0 )) { @@ -1493,6 +1494,7 @@ static void x11drv_egl_surface_flush( struct opengl_drawable *base, UINT flags ) TRACE( "%s\n", debugstr_opengl_drawable( base ) ); if (flags & GL_FLUSH_INTERVAL) funcs->p_eglSwapInterval( egl->display, abs( base->interval ) ); + if (!(flags & GL_FLUSH_PRESENT)) return; if (InterlockedCompareExchange( &base->client->offscreen, 0, 0 )) { diff --git a/include/wine/opengl_driver.h b/include/wine/opengl_driver.h index 2e4ee296159..40b6224141d 100644 --- a/include/wine/opengl_driver.h +++ b/include/wine/opengl_driver.h @@ -175,6 +175,7 @@ struct opengl_drawable_funcs #define GL_FLUSH_FINISHED 0x01 #define GL_FLUSH_INTERVAL 0x02 #define GL_FLUSH_UPDATED 0x04 +#define GL_FLUSH_PRESENT 0x08 /* a driver opengl drawable, either a client surface of a pbuffer */ struct opengl_drawable -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9817