Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58448 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58459 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58488
From: Rémi Bernon rbernon@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58448 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58459 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58488 --- dlls/win32u/opengl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index f27143f3357..5ac9fd72147 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -1152,7 +1152,7 @@ static BOOL context_set_drawables( struct wgl_context *context, void *private, H if (old_read) opengl_drawable_release( old_read );
/* update the current window drawable to the last used draw surface */ - if ((hwnd = NtUserWindowFromDC( draw_hdc ))) set_window_opengl_drawable( hwnd, new_draw ); + if (new_draw && (hwnd = NtUserWindowFromDC( draw_hdc ))) set_window_opengl_drawable( hwnd, new_draw ); } }
From: Rémi Bernon rbernon@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58448 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58459 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58488 --- dlls/win32u/opengl.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-)
diff --git a/dlls/win32u/opengl.c b/dlls/win32u/opengl.c index 5ac9fd72147..b800806623b 100644 --- a/dlls/win32u/opengl.c +++ b/dlls/win32u/opengl.c @@ -904,17 +904,13 @@ struct opengl_drawable *get_window_opengl_drawable( HWND hwnd ) return drawable; }
-static void set_dc_opengl_drawable( HDC hdc, struct opengl_drawable *new_drawable ) +void set_dc_opengl_drawable( HDC hdc, struct opengl_drawable *new_drawable ) { void *old_drawable = NULL; - HWND hwnd; DC *dc;
TRACE( "hdc %p, new_drawable %s\n", hdc, debugstr_opengl_drawable( new_drawable ) );
- /* update the current window drawable to the last used draw surface */ - if ((hwnd = NtUserWindowFromDC( hdc ))) set_window_opengl_drawable( hwnd, new_drawable ); - if ((dc = get_dc_ptr( hdc ))) { old_drawable = dc->opengl_drawable; @@ -925,15 +921,11 @@ static void set_dc_opengl_drawable( HDC hdc, struct opengl_drawable *new_drawabl if (old_drawable) opengl_drawable_release( old_drawable ); }
-static struct opengl_drawable *get_dc_opengl_drawable( HDC hdc, BOOL read ) +static struct opengl_drawable *get_dc_opengl_drawable( HDC hdc ) { void *drawable = NULL; - HWND hwnd; DC *dc;
- /* get the last used window drawable when reading */ - if ((hwnd = NtUserWindowFromDC( hdc )) && read) return get_window_opengl_drawable( hwnd ); - if ((dc = get_dc_ptr( hdc ))) { if ((drawable = dc->opengl_drawable)) opengl_drawable_add_ref( drawable ); @@ -1036,9 +1028,13 @@ static BOOL set_dc_pixel_format( HDC hdc, int new_format, BOOL internal )
if ((old_format = get_window_pixel_format( hwnd, FALSE )) && !internal) return old_format == new_format;
- drawable = get_dc_opengl_drawable( hdc, FALSE ); + drawable = get_dc_opengl_drawable( hdc ); if ((ret = driver_funcs->p_surface_create( hwnd, hdc, new_format, &drawable ))) + { + /* update the current window drawable to the last used draw surface */ + if ((hwnd = NtUserWindowFromDC( hdc ))) set_window_opengl_drawable( hwnd, drawable ); set_dc_opengl_drawable( hdc, drawable ); + } if (drawable) opengl_drawable_release( drawable );
if (!ret) return FALSE; @@ -1128,8 +1124,11 @@ static BOOL context_set_drawables( struct wgl_context *context, void *private, H HWND hwnd;
flush = create_memory_pbuffer( draw_hdc, context->pixel_format ); - new_draw = get_dc_opengl_drawable( draw_hdc, FALSE ); - new_read = get_dc_opengl_drawable( read_hdc, read_hdc != draw_hdc ); + new_draw = get_dc_opengl_drawable( draw_hdc ); + + /* get the last used window drawable when reading */ + if ((hwnd = NtUserWindowFromDC( read_hdc ))) new_read = get_window_opengl_drawable( hwnd ); + else new_read = get_dc_opengl_drawable( read_hdc );
TRACE( "context %p, new_draw %s, new_read %s\n", context, debugstr_opengl_drawable( new_draw ), debugstr_opengl_drawable( new_read ) );
@@ -1662,7 +1661,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 (!(draw = get_dc_opengl_drawable( draw_hdc, FALSE ))) return FALSE; + if (!(draw = get_dc_opengl_drawable( draw_hdc ))) return FALSE; opengl_drawable_flush( draw, interval, flags ); opengl_drawable_release( draw );
@@ -1685,7 +1684,7 @@ static BOOL win32u_wglSwapBuffers( HDC hdc ) context_set_drawables( context, context->driver_private, draw_hdc, read_hdc, FALSE ); if (flush_memory_dc( context, hdc, FALSE, funcs->p_glFlush )) return TRUE;
- if (!(draw = get_dc_opengl_drawable( draw_hdc, FALSE ))) return FALSE; + if (!(draw = get_dc_opengl_drawable( draw_hdc ))) return FALSE; opengl_drawable_flush( draw, interval, 0 ); if (!draw->client) ret = FALSE; /* pbuffer, nothing to do */ else ret = draw->funcs->swap( draw );
From: Rémi Bernon rbernon@codeweavers.com
Instead of when it is reset, so that releasing a window DC then acquiring it again will keep its allocated OpenGL surface or update it to the latest window surface when acquiring a DC previously associated with another window.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58448 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58459 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=58488 --- dlls/win32u/dc.c | 6 +----- dlls/win32u/dce.c | 8 ++++++++ dlls/win32u/win32u_private.h | 7 +++++++ 3 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/dlls/win32u/dc.c b/dlls/win32u/dc.c index 94946d9ad23..47981dd867d 100644 --- a/dlls/win32u/dc.c +++ b/dlls/win32u/dc.c @@ -248,6 +248,7 @@ DC *alloc_dc_ptr( DWORD magic ) */ static void free_dc_state( DC *dc ) { + if (dc->opengl_drawable) opengl_drawable_release( dc->opengl_drawable ); if (dc->hClipRgn) NtGdiDeleteObjectApp( dc->hClipRgn ); if (dc->hMetaRgn) NtGdiDeleteObjectApp( dc->hMetaRgn ); if (dc->hVisRgn) NtGdiDeleteObjectApp( dc->hVisRgn ); @@ -458,7 +459,6 @@ void DC_UpdateXforms( DC *dc ) */ static BOOL reset_dc_state( HDC hdc ) { - struct opengl_drawable *drawable; DC *dc, *dcs, *next;
if (!(dc = get_dc_ptr( hdc ))) return FALSE; @@ -487,12 +487,8 @@ static BOOL reset_dc_state( HDC hdc ) } dc->saved_dc = NULL; dc->attr->save_level = 0; - - drawable = dc->opengl_drawable; - dc->opengl_drawable = NULL; release_dc_ptr( dc );
- if (drawable) opengl_drawable_release( drawable ); return TRUE; }
diff --git a/dlls/win32u/dce.c b/dlls/win32u/dce.c index 3e258d837dd..29f11e18256 100644 --- a/dlls/win32u/dce.c +++ b/dlls/win32u/dce.c @@ -29,6 +29,7 @@ #define WIN32_NO_STATUS #include "ntgdi_private.h" #include "ntuser_private.h" +#include "wine/opengl_driver.h" #include "wine/server.h" #include "wine/debug.h"
@@ -885,6 +886,7 @@ static void release_dce( struct dce *dce )
set_visible_region( dce->hdc, 0, &dummy_surface.rect, &dummy_surface.rect, &dummy_surface ); user_driver->pReleaseDC( dce->hwnd, dce->hdc ); + set_dc_opengl_drawable( dce->hdc, NULL );
if (dce->clip_rgn) NtGdiDeleteObjectApp( dce->clip_rgn ); dce->clip_rgn = 0; @@ -1362,6 +1364,12 @@ HDC WINAPI NtUserGetDCEx( HWND hwnd, HRGN clip_rgn, DWORD flags ) if (get_window_long( hwnd, GWL_EXSTYLE ) & WS_EX_LAYOUTRTL) NtGdiSetLayout( dce->hdc, -1, LAYOUT_RTL );
+ if (dce->hwnd != hwnd) + { + struct opengl_drawable *drawable = get_window_opengl_drawable( hwnd ); + set_dc_opengl_drawable( dce->hdc, drawable ); + if (drawable) opengl_drawable_release( drawable ); + } dce->hwnd = hwnd; dce->flags = (dce->flags & ~user_flags) | (flags & user_flags);
diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index 3018321c3ed..780e8cd26cc 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -190,6 +190,13 @@ extern void user_lock(void); extern void user_unlock(void); extern void user_check_not_lock(void);
+/* opengl.c */ + +struct opengl_drawable; +void set_dc_opengl_drawable( HDC hdc, struct opengl_drawable *new_drawable ); + +/* d3dkmtc. */ + struct vulkan_gpu { struct list entry;
This merge request was approved by Huw Davies.