Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51848
SPORE creates a swapchain on a window, then destroys it, then creates a different swapchain on the same window and uses it for the rest of its lifetime. The swapchains have different GLX visuals (the details are unimportant).
The effect is that the second swapchain sees the pixel format set by the first swapchain, through GetPixelFormat(), and therefore needs to set and then restore the new pixel format on every present. This results in recreating the GLX drawable twice per frame, which is extremely expensive.
This patch series changes WGL_WINE_pixel_format_passthrough to only set an "internal" pixel format. The real pixel format will still be set as it is now, but GetPixelFormat() will always return 0, signalling to wined3d that the application has not set the pixel format, and therefore there is no need to restore it.
As the tests show, this change also matches Windows, which does not report that a pixel format has been set after presenting a Direct3D swapchain.
This is a large series by patch count, but I fear that splitting it into two parts would make it difficult to grasp the entire picture, and purpose of the earlier patches. It also contains six patches which are simply repetitions across the three user drivers, which should ease the burden of review somewhat.
-- v4: wineandroid: Separately store the internal pixel format set by WGL_WINE_pixel_format_passthrough. winemac: Separately store the internal pixel format set by WGL_WINE_pixel_format_passthrough.
From: Zebediah Figura zfigura@codeweavers.com
This is simpler in general, given that this function is no longer used from user-space. In this particular case, the secondary purpose is to allow easily adding arguments to the function. --- dlls/win32u/window.c | 5 +---- dlls/wineandroid.drv/opengl.c | 2 +- dlls/winemac.drv/opengl.c | 2 +- dlls/winex11.drv/opengl.c | 4 ++-- include/ntuser.h | 6 ------ include/wine/gdi_driver.h | 2 ++ 6 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index a3ff0647dcd..cd8b6583249 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -1441,7 +1441,7 @@ LONG_PTR WINAPI NtUserSetWindowLongPtr( HWND hwnd, INT offset, LONG_PTR newval, return set_window_long( hwnd, offset, sizeof(LONG_PTR), newval, ansi ); }
-static BOOL set_window_pixel_format( HWND hwnd, int format ) +BOOL win32u_set_window_pixel_format( HWND hwnd, int format ) { WND *win = get_win_ptr( hwnd );
@@ -5555,9 +5555,6 @@ ULONG_PTR WINAPI NtUserCallHwndParam( HWND hwnd, DWORD_PTR param, DWORD code ) case NtUserCallHwndParam_SetWindowContextHelpId: return set_window_context_help_id( hwnd, param );
- case NtUserCallHwndParam_SetWindowPixelFormat: - return set_window_pixel_format( hwnd, param ); - case NtUserCallHwndParam_ShowOwnedPopups: return show_owned_popups( hwnd, param );
diff --git a/dlls/wineandroid.drv/opengl.c b/dlls/wineandroid.drv/opengl.c index a930e249ba5..41df3d3c09c 100644 --- a/dlls/wineandroid.drv/opengl.c +++ b/dlls/wineandroid.drv/opengl.c @@ -242,7 +242,7 @@ static BOOL set_pixel_format( HDC hdc, int format, BOOL allow_change ) release_gl_drawable( gl );
if (prev && prev != format && !allow_change) return FALSE; - if (NtUserSetWindowPixelFormat( hwnd, format )) return TRUE; + if (win32u_set_window_pixel_format( hwnd, format )) return TRUE; destroy_gl_drawable( hwnd ); return FALSE; } diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index ff78b183360..7251745258a 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -1588,7 +1588,7 @@ static BOOL set_pixel_format(HDC hdc, int fmt, BOOL allow_reset)
done: release_win_data(data); - if (ret && gl_surface_mode == GL_SURFACE_BEHIND) NtUserSetWindowPixelFormat(hwnd, fmt); + if (ret && gl_surface_mode == GL_SURFACE_BEHIND) win32u_set_window_pixel_format(hwnd, fmt); return ret; }
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index c44e9579cb6..783ac5f3a9d 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -1402,7 +1402,7 @@ static BOOL set_win_format( HWND hwnd, const struct wgl_pixel_format *format, BO XFlush( gdi_display ); release_gl_drawable( gl );
- NtUserSetWindowPixelFormat( hwnd, pixel_format_index( format )); + win32u_set_window_pixel_format( hwnd, pixel_format_index( format )); return TRUE; }
@@ -1512,7 +1512,7 @@ void set_gl_drawable_parent( HWND hwnd, HWND parent ) else { destroy_gl_drawable( hwnd ); - NtUserSetWindowPixelFormat( hwnd, 0 ); + win32u_set_window_pixel_format( hwnd, 0 ); } release_gl_drawable( old ); } diff --git a/include/ntuser.h b/include/ntuser.h index 3b821f0c9fe..35ead9750c6 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -1331,7 +1331,6 @@ enum NtUserCallHwndParam_SetDialogInfo, NtUserCallHwndParam_SetMDIClientInfo, NtUserCallHwndParam_SetWindowContextHelpId, - NtUserCallHwndParam_SetWindowPixelFormat, NtUserCallHwndParam_ShowOwnedPopups, /* temporary exports */ NtUserSetWindowStyle, @@ -1498,11 +1497,6 @@ static inline BOOL NtUserSetWindowContextHelpId( HWND hwnd, DWORD id ) return NtUserCallHwndParam( hwnd, id, NtUserCallHwndParam_SetWindowContextHelpId ); }
-static inline BOOL NtUserSetWindowPixelFormat( HWND hwnd, int format ) -{ - return NtUserCallHwndParam( hwnd, format, NtUserCallHwndParam_SetWindowPixelFormat ); -} - static inline BOOL NtUserShowOwnedPopups( HWND hwnd, BOOL show ) { return NtUserCallHwndParam( hwnd, show, NtUserCallHwndParam_ShowOwnedPopups ); diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index 3de7e20af9a..3590e0bede5 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -338,6 +338,8 @@ struct user_driver_funcs
extern void __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT version );
+extern BOOL win32u_set_window_pixel_format( HWND hwnd, int format ); + #endif /* WINE_UNIX_LIB */
#endif /* __WINE_WINE_GDI_DRIVER_H */
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/win32u/window.c | 17 +++++++++++++++++ include/wine/gdi_driver.h | 1 + 2 files changed, 18 insertions(+)
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index cd8b6583249..a3c46dfdf31 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -1457,6 +1457,23 @@ BOOL win32u_set_window_pixel_format( HWND hwnd, int format ) return TRUE; }
+int win32u_get_window_pixel_format( HWND hwnd ) +{ + WND *win = get_win_ptr( hwnd ); + int ret; + + if (!win || win == WND_DESKTOP || win == WND_OTHER_PROCESS) + { + WARN( "getting format on win %p not supported\n", hwnd ); + return 0; + } + + ret = win->pixel_format; + release_win_ptr( win ); + + return ret; +} + /*********************************************************************** * NtUserGetProp (win32u.@) * diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index 3590e0bede5..c76ef9900ae 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -339,6 +339,7 @@ struct user_driver_funcs extern void __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT version );
extern BOOL win32u_set_window_pixel_format( HWND hwnd, int format ); +extern int win32u_get_window_pixel_format( HWND hwnd );
#endif /* WINE_UNIX_LIB */
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/winex11.drv/opengl.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 783ac5f3a9d..92768267bae 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -1687,8 +1687,12 @@ static int glxdrv_wglGetPixelFormat( HDC hdc ) { struct gl_drawable *gl; int ret = 0; + HWND hwnd;
- if ((gl = get_gl_drawable( NtUserWindowFromDC( hdc ), hdc ))) + if ((hwnd = NtUserWindowFromDC( hdc ))) + return win32u_get_window_pixel_format( hwnd ); + + if ((gl = get_gl_drawable( NULL, hdc ))) { ret = pixel_format_index( gl->format ); /* Offscreen formats can't be used with traditional WGL calls.
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/wineandroid.drv/opengl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/dlls/wineandroid.drv/opengl.c b/dlls/wineandroid.drv/opengl.c index 41df3d3c09c..37e9c713fb1 100644 --- a/dlls/wineandroid.drv/opengl.c +++ b/dlls/wineandroid.drv/opengl.c @@ -497,8 +497,14 @@ static int android_wglGetPixelFormat( HDC hdc ) { struct gl_drawable *gl; int ret = 0; + HWND hwnd; + + if ((hwnd = NtUserWindowFromDC( hdc ))) + return win32u_get_window_pixel_format( hwnd );
- if ((gl = get_gl_drawable( NtUserWindowFromDC( hdc ), hdc ))) + /* This code is currently dead, but will be necessary if WGL_ARB_pbuffer + * support is introduced. */ + if ((gl = get_gl_drawable( NULL, hdc ))) { ret = gl->format; /* offscreen formats can't be used with traditional WGL calls */
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/winemac.drv/opengl.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index 7251745258a..d92276bf253 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -1329,12 +1329,11 @@ static BOOL init_gl_info(void) }
-static int get_dc_pixel_format(HDC hdc) +static int get_dc_pixel_format(HWND hwnd, HDC hdc) { int format; - HWND hwnd;
- if ((hwnd = NtUserWindowFromDC(hdc))) + if (hwnd) { struct macdrv_win_data *data;
@@ -2719,7 +2718,7 @@ static struct wgl_context *macdrv_wglCreateContextAttribsARB(HDC hdc,
TRACE("hdc %p, share_context %p, attrib_list %p\n", hdc, share_context, attrib_list);
- format = get_dc_pixel_format(hdc); + format = get_dc_pixel_format(NtUserWindowFromDC(hdc), hdc);
if (!is_valid_pixel_format(format)) { @@ -4417,8 +4416,12 @@ static BOOL macdrv_wglDeleteContext(struct wgl_context *context) static int macdrv_wglGetPixelFormat(HDC hdc) { int format; + HWND hwnd; + + if ((hwnd = NtUserWindowFromDC( hdc ))) + return win32u_get_window_pixel_format( hwnd );
- format = get_dc_pixel_format(hdc); + format = get_dc_pixel_format(NULL, hdc);
if (!is_valid_pixel_format(format)) /* not set yet */ format = 0;
From: Zebediah Figura zfigura@codeweavers.com
Currently this does nothing, because wglGetPixelFormat() returns the pixel format set by wglSetPixelFormatWINE(). However, with the following changes to WGL_WINE_pixel_format_passthrough, wglGetPixelFormat() will only return the pixel format set by wglSetPixelFormat(). Hence we should avoid trying to set the "internal" pixel format more than once. --- dlls/wined3d/context_gl.c | 15 +++++++++++---- dlls/wined3d/wined3d_private.h | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index 5574997bf05..a59f7549cc2 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -1210,7 +1210,8 @@ static BOOL wined3d_context_gl_set_pixel_format(struct wined3d_context_gl *conte return FALSE;
current = gl_info->gl_ops.wgl.p_wglGetPixelFormat(dc); - if (current == format) goto success; + if ((current == format) || (!current && context_gl->internal_format_set)) + goto success;
/* By default WGL doesn't allow pixel format adjustments but we need it * here. For this reason there's a Wine specific wglSetPixelFormat() @@ -1225,6 +1226,7 @@ static BOOL wined3d_context_gl_set_pixel_format(struct wined3d_context_gl *conte format, dc); return FALSE; } + context_gl->internal_format_set = 1; } else if (current) { @@ -1346,6 +1348,7 @@ static void wined3d_context_gl_update_window(struct wined3d_context_gl *context_ context_gl->dc_has_format = FALSE; context_gl->needs_set = 1; context_gl->valid = 1; + context_gl->internal_format_set = 0;
if (!(context_gl->dc = GetDCEx(context_gl->window, 0, DCX_USESTYLE | DCX_CACHE))) { @@ -1673,9 +1676,13 @@ static void wined3d_context_gl_enter(struct wined3d_context_gl *context_gl) context_gl->restore_dc = wglGetCurrentDC(); context_gl->needs_set = 1; } - else if (!context_gl->needs_set && !(context_gl->dc_is_private && context_gl->dc_has_format) - && context_gl->pixel_format != context_gl->gl_info->gl_ops.wgl.p_wglGetPixelFormat(context_gl->dc)) - context_gl->needs_set = 1; + else if (!context_gl->needs_set && !(context_gl->dc_is_private && context_gl->dc_has_format)) + { + int current = context_gl->gl_info->gl_ops.wgl.p_wglGetPixelFormat(context_gl->dc); + + if ((current && current != context_gl->pixel_format) || (!current && !context_gl->internal_format_set)) + context_gl->needs_set = 1; + } } }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 459ac7a19c8..920e98cd0eb 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2347,8 +2347,9 @@ struct wined3d_context_gl uint32_t rebind_fbo : 1; uint32_t untracked_material_count : 2; /* Max value 2 */ uint32_t needs_set : 1; + uint32_t internal_format_set : 1; uint32_t valid : 1; - uint32_t padding : 23; + uint32_t padding : 22;
uint32_t default_attrib_value_set;
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/win32u/ntuser_private.h | 1 + dlls/win32u/window.c | 10 +++++++--- dlls/wineandroid.drv/opengl.c | 2 +- dlls/winemac.drv/opengl.c | 3 ++- dlls/winex11.drv/opengl.c | 4 ++-- include/wine/gdi_driver.h | 2 +- 6 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index 385e7c0ded5..5c337c722a7 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -90,6 +90,7 @@ typedef struct tagWND struct window_surface *surface; /* Window surface if any */ struct tagDIALOGINFO *dlgInfo; /* Dialog additional info (dialogs only) */ int pixel_format; /* Pixel format set by the graphics driver */ + int internal_pixel_format; /* Internal pixel format set via WGL_WINE_pixel_format_passthrough */ int cbWndExtra; /* class cbWndExtra at window creation */ DWORD_PTR userdata; /* User private data */ DWORD wExtra[1]; /* Window extra bytes */ diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index a3c46dfdf31..4db9d99884c 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -1441,7 +1441,7 @@ LONG_PTR WINAPI NtUserSetWindowLongPtr( HWND hwnd, INT offset, LONG_PTR newval, return set_window_long( hwnd, offset, sizeof(LONG_PTR), newval, ansi ); }
-BOOL win32u_set_window_pixel_format( HWND hwnd, int format ) +BOOL win32u_set_window_pixel_format( HWND hwnd, int format, BOOL internal ) { WND *win = get_win_ptr( hwnd );
@@ -1450,7 +1450,10 @@ BOOL win32u_set_window_pixel_format( HWND hwnd, int format ) WARN( "setting format %d on win %p not supported\n", format, hwnd ); return FALSE; } - win->pixel_format = format; + if (internal) + win->internal_pixel_format = format; + else + win->pixel_format = format; release_win_ptr( win );
update_window_state( hwnd ); @@ -1852,7 +1855,8 @@ static BOOL apply_window_pos( HWND hwnd, HWND insert_after, UINT swp_flags, wine_server_add_data( req, extra_rects, sizeof(extra_rects) ); } if (new_surface) req->paint_flags |= SET_WINPOS_PAINT_SURFACE; - if (win->pixel_format) req->paint_flags |= SET_WINPOS_PIXEL_FORMAT; + if (win->pixel_format || win->internal_pixel_format) + req->paint_flags |= SET_WINPOS_PIXEL_FORMAT;
if ((ret = !wine_server_call( req ))) { diff --git a/dlls/wineandroid.drv/opengl.c b/dlls/wineandroid.drv/opengl.c index 37e9c713fb1..c8b7bf85cfb 100644 --- a/dlls/wineandroid.drv/opengl.c +++ b/dlls/wineandroid.drv/opengl.c @@ -242,7 +242,7 @@ static BOOL set_pixel_format( HDC hdc, int format, BOOL allow_change ) release_gl_drawable( gl );
if (prev && prev != format && !allow_change) return FALSE; - if (win32u_set_window_pixel_format( hwnd, format )) return TRUE; + if (win32u_set_window_pixel_format( hwnd, format, FALSE )) return TRUE; destroy_gl_drawable( hwnd ); return FALSE; } diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index d92276bf253..6f3c3b88155 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -1587,7 +1587,8 @@ static BOOL set_pixel_format(HDC hdc, int fmt, BOOL allow_reset)
done: release_win_data(data); - if (ret && gl_surface_mode == GL_SURFACE_BEHIND) win32u_set_window_pixel_format(hwnd, fmt); + if (ret && gl_surface_mode == GL_SURFACE_BEHIND) + win32u_set_window_pixel_format(hwnd, fmt, FALSE); return ret; }
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 92768267bae..3006d1a2447 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -1402,7 +1402,7 @@ static BOOL set_win_format( HWND hwnd, const struct wgl_pixel_format *format, BO XFlush( gdi_display ); release_gl_drawable( gl );
- win32u_set_window_pixel_format( hwnd, pixel_format_index( format )); + win32u_set_window_pixel_format( hwnd, pixel_format_index( format ), FALSE ); return TRUE; }
@@ -1512,7 +1512,7 @@ void set_gl_drawable_parent( HWND hwnd, HWND parent ) else { destroy_gl_drawable( hwnd ); - win32u_set_window_pixel_format( hwnd, 0 ); + win32u_set_window_pixel_format( hwnd, 0, FALSE ); } release_gl_drawable( old ); } diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h index c76ef9900ae..bba68aa5f06 100644 --- a/include/wine/gdi_driver.h +++ b/include/wine/gdi_driver.h @@ -338,7 +338,7 @@ struct user_driver_funcs
extern void __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT version );
-extern BOOL win32u_set_window_pixel_format( HWND hwnd, int format ); +extern BOOL win32u_set_window_pixel_format( HWND hwnd, int format, BOOL internal ); extern int win32u_get_window_pixel_format( HWND hwnd );
#endif /* WINE_UNIX_LIB */
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/d3d8/tests/device.c | 6 +++--- dlls/d3d9/tests/device.c | 6 +++--- dlls/ddraw/tests/ddraw1.c | 6 +++--- dlls/ddraw/tests/ddraw2.c | 6 +++--- dlls/ddraw/tests/ddraw4.c | 6 +++--- dlls/ddraw/tests/ddraw7.c | 6 +++--- dlls/winex11.drv/opengl.c | 26 +++++++++++--------------- 7 files changed, 29 insertions(+), 33 deletions(-)
diff --git a/dlls/d3d8/tests/device.c b/dlls/d3d8/tests/device.c index c8f52484054..cebf462804d 100644 --- a/dlls/d3d8/tests/device.c +++ b/dlls/d3d8/tests/device.c @@ -7916,20 +7916,20 @@ static void test_pixel_format(void) ok(hr == S_OK, "Got hr %#lx.\n", hr);
test_format = GetPixelFormat(hdc3); - todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + ok(!test_format, "Expected no format, got %d.\n", test_format);
hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL); ok(hr == S_OK, "Got hr %#lx.\n", hr);
test_format = GetPixelFormat(hdc3); - todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + ok(!test_format, "Expected no format, got %d.\n", test_format);
refcount = IDirect3DDevice8_Release(device); ok(!refcount, "Device has %lu references left.\n", refcount); IDirect3D8_Release(d3d8);
test_format = GetPixelFormat(hdc3); - todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + ok(!test_format, "Expected no format, got %d.\n", test_format);
ret = SetPixelFormat(hdc3, format, &pfd); ok(ret, "Failed to set pixel format %d.\n", format); diff --git a/dlls/d3d9/tests/device.c b/dlls/d3d9/tests/device.c index 0e361b3ac23..6a0fe586f53 100644 --- a/dlls/d3d9/tests/device.c +++ b/dlls/d3d9/tests/device.c @@ -11191,20 +11191,20 @@ static void test_pixel_format(void) ok(hr == S_OK, "Got hr %#lx.\n", hr);
test_format = GetPixelFormat(hdc3); - todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + ok(!test_format, "Expected no format, got %d.\n", test_format);
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); ok(hr == S_OK, "Got hr %#lx.\n", hr);
test_format = GetPixelFormat(hdc3); - todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + ok(!test_format, "Expected no format, got %d.\n", test_format);
refcount = IDirect3DDevice9_Release(device); ok(!refcount, "Device has %lu references left.\n", refcount); IDirect3D9_Release(d3d9);
test_format = GetPixelFormat(hdc3); - todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + ok(!test_format, "Expected no format, got %d.\n", test_format);
ret = SetPixelFormat(hdc3, format, &pfd); ok(ret, "Failed to set pixel format %d.\n", format); diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c index 71c60db3804..b52ea9ef4c3 100644 --- a/dlls/ddraw/tests/ddraw1.c +++ b/dlls/ddraw/tests/ddraw1.c @@ -6013,7 +6013,7 @@ static void test_pixel_format(void) ok(hr == S_OK, "Got hr %#lx.\n", hr);
test_format = GetPixelFormat(hdc3); - todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + ok(!test_format, "Expected no format, got %d.\n", test_format);
memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); @@ -6039,7 +6039,7 @@ static void test_pixel_format(void) ok(SUCCEEDED(hr), "Failed to blit to primary surface, hr %#lx.\n", hr);
test_format = GetPixelFormat(hdc3); - todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + ok(!test_format, "Expected no format, got %d.\n", test_format);
IDirectDrawSurface_Release(offscreen); IDirectDrawSurface_Release(primary); @@ -6047,7 +6047,7 @@ static void test_pixel_format(void) ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
test_format = GetPixelFormat(hdc3); - todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + ok(!test_format, "Expected no format, got %d.\n", test_format);
ret = SetPixelFormat(hdc3, format, &pfd); ok(ret, "Failed to set pixel format %d.\n", format); diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c index eddf846e54b..9384072689b 100644 --- a/dlls/ddraw/tests/ddraw2.c +++ b/dlls/ddraw/tests/ddraw2.c @@ -7110,7 +7110,7 @@ static void test_pixel_format(void) ok(hr == S_OK, "Got hr %#lx.\n", hr);
test_format = GetPixelFormat(hdc3); - todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + ok(!test_format, "Expected no format, got %d.\n", test_format);
memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); @@ -7136,7 +7136,7 @@ static void test_pixel_format(void) ok(SUCCEEDED(hr), "Failed to blit to primary surface, hr %#lx.\n", hr);
test_format = GetPixelFormat(hdc3); - todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + ok(!test_format, "Expected no format, got %d.\n", test_format);
IDirectDrawSurface_Release(offscreen); IDirectDrawSurface_Release(primary); @@ -7144,7 +7144,7 @@ static void test_pixel_format(void) ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
test_format = GetPixelFormat(hdc3); - todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + ok(!test_format, "Expected no format, got %d.\n", test_format);
ret = SetPixelFormat(hdc3, format, &pfd); ok(ret, "Failed to set pixel format %d.\n", format); diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c index a658de37b94..df3dba2ccb4 100644 --- a/dlls/ddraw/tests/ddraw4.c +++ b/dlls/ddraw/tests/ddraw4.c @@ -8993,7 +8993,7 @@ static void test_pixel_format(void) ok(hr == S_OK, "Got hr %#lx.\n", hr);
test_format = GetPixelFormat(hdc3); - todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + ok(!test_format, "Expected no format, got %d.\n", test_format);
memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); @@ -9019,7 +9019,7 @@ static void test_pixel_format(void) ok(SUCCEEDED(hr), "Failed to blit to primary surface, hr %#lx.\n", hr);
test_format = GetPixelFormat(hdc3); - todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + ok(!test_format, "Expected no format, got %d.\n", test_format);
IDirectDrawSurface4_Release(offscreen); IDirectDrawSurface4_Release(primary); @@ -9027,7 +9027,7 @@ static void test_pixel_format(void) ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
test_format = GetPixelFormat(hdc3); - todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + ok(!test_format, "Expected no format, got %d.\n", test_format);
ret = SetPixelFormat(hdc3, format, &pfd); ok(ret, "Failed to set pixel format %d.\n", format); diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c index a1c791a9116..4dc98a3d2f2 100644 --- a/dlls/ddraw/tests/ddraw7.c +++ b/dlls/ddraw/tests/ddraw7.c @@ -8833,7 +8833,7 @@ static void test_pixel_format(void) ok(hr == S_OK, "Got hr %#lx.\n", hr);
test_format = GetPixelFormat(hdc3); - todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + ok(!test_format, "Expected no format, got %d.\n", test_format);
memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); @@ -8859,7 +8859,7 @@ static void test_pixel_format(void) ok(SUCCEEDED(hr), "Failed to blit to primary surface, hr %#lx.\n", hr);
test_format = GetPixelFormat(hdc3); - todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + ok(!test_format, "Expected no format, got %d.\n", test_format);
IDirectDrawSurface7_Release(offscreen); IDirectDrawSurface7_Release(primary); @@ -8867,7 +8867,7 @@ static void test_pixel_format(void) ok(!refcount, "Got unexpected refcount %lu.\n", refcount);
test_format = GetPixelFormat(hdc3); - todo_wine ok(!test_format, "Expected no format, got %d.\n", test_format); + ok(!test_format, "Expected no format, got %d.\n", test_format);
ret = SetPixelFormat(hdc3, format, &pfd); ok(ret, "Failed to set pixel format %d.\n", format); diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index 3006d1a2447..b2169de9bf7 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -1388,13 +1388,13 @@ static struct gl_drawable *create_gl_drawable( HWND hwnd, const struct wgl_pixel /*********************************************************************** * set_win_format */ -static BOOL set_win_format( HWND hwnd, const struct wgl_pixel_format *format, BOOL mutable_pf ) +static BOOL set_win_format( HWND hwnd, const struct wgl_pixel_format *format, BOOL internal ) { struct gl_drawable *gl;
if (!format->visual) return FALSE;
- if (!(gl = create_gl_drawable( hwnd, format, FALSE, mutable_pf ))) return FALSE; + if (!(gl = create_gl_drawable( hwnd, format, FALSE, internal ))) return FALSE;
TRACE( "created GL drawable %lx for win %p %s\n", gl->drawable, hwnd, debugstr_fbconfig( format->fbconfig )); @@ -1402,12 +1402,12 @@ static BOOL set_win_format( HWND hwnd, const struct wgl_pixel_format *format, BO XFlush( gdi_display ); release_gl_drawable( gl );
- win32u_set_window_pixel_format( hwnd, pixel_format_index( format ), FALSE ); + win32u_set_window_pixel_format( hwnd, pixel_format_index( format ), internal ); return TRUE; }
-static BOOL set_pixel_format(HDC hdc, int format, BOOL allow_change) +static BOOL set_pixel_format( HDC hdc, int format, BOOL internal ) { const struct wgl_pixel_format *fmt; int value; @@ -1435,20 +1435,16 @@ static BOOL set_pixel_format(HDC hdc, int format, BOOL allow_change) return FALSE; }
- if (!allow_change) + if (!internal) { - struct gl_drawable *gl; - if ((gl = get_gl_drawable( hwnd, hdc ))) - { - int prev = pixel_format_index( gl->format ); - BOOL mutable_pf = gl->mutable_pf; - release_gl_drawable( gl ); - if (!mutable_pf) - return prev == format; /* cannot change it if already set */ - } + /* cannot change it if already set */ + int prev = win32u_get_window_pixel_format( hwnd ); + + if (prev) + return prev == format; }
- return set_win_format( hwnd, fmt, allow_change ); + return set_win_format( hwnd, fmt, internal ); }
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/winemac.drv/opengl.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index 6f3c3b88155..55e5704724b 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -1525,7 +1525,7 @@ static BOOL create_context(struct wgl_context *context, CGLContextObj share, uns * * Implementation of wglSetPixelFormat and wglSetPixelFormatWINE. */ -static BOOL set_pixel_format(HDC hdc, int fmt, BOOL allow_reset) +static BOOL set_pixel_format(HDC hdc, int fmt, BOOL internal) { struct macdrv_win_data *data; const pixel_format *pf; @@ -1540,16 +1540,19 @@ static BOOL set_pixel_format(HDC hdc, int fmt, BOOL allow_reset) return FALSE; }
- if (!(data = get_win_data(hwnd))) + if (!internal) { - FIXME("DC for window %p of other process: not implemented\n", hwnd); - return FALSE; + /* cannot change it if already set */ + int prev = win32u_get_window_pixel_format( hwnd ); + + if (prev) + return prev == fmt; }
- if (!allow_reset && data->pixel_format) /* cannot change it if already set */ + if (!(data = get_win_data(hwnd))) { - ret = (data->pixel_format == fmt); - goto done; + FIXME("DC for window %p of other process: not implemented\n", hwnd); + return FALSE; }
/* Check if fmt is in our list of supported formats to see if it is supported. */ @@ -1588,7 +1591,7 @@ static BOOL set_pixel_format(HDC hdc, int fmt, BOOL allow_reset) done: release_win_data(data); if (ret && gl_surface_mode == GL_SURFACE_BEHIND) - win32u_set_window_pixel_format(hwnd, fmt, FALSE); + win32u_set_window_pixel_format(hwnd, fmt, internal); return ret; }
From: Zebediah Figura zfigura@codeweavers.com
--- dlls/wineandroid.drv/opengl.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/dlls/wineandroid.drv/opengl.c b/dlls/wineandroid.drv/opengl.c index c8b7bf85cfb..c718e69eda3 100644 --- a/dlls/wineandroid.drv/opengl.c +++ b/dlls/wineandroid.drv/opengl.c @@ -208,11 +208,10 @@ void update_gl_drawable( HWND hwnd ) } }
-static BOOL set_pixel_format( HDC hdc, int format, BOOL allow_change ) +static BOOL set_pixel_format( HDC hdc, int format, BOOL internal ) { struct gl_drawable *gl; HWND hwnd = NtUserWindowFromDC( hdc ); - int prev = 0;
if (!hwnd || hwnd == NtUserGetDesktopWindow()) { @@ -226,9 +225,17 @@ static BOOL set_pixel_format( HDC hdc, int format, BOOL allow_change ) } TRACE( "%p/%p format %d\n", hdc, hwnd, format );
+ if (!internal) + { + /* cannot change it if already set */ + int prev = win32u_get_window_pixel_format( hwnd ); + + if (prev) + return prev == format; + } + if ((gl = get_gl_drawable( hwnd, 0 ))) { - prev = gl->format; if (allow_change) { EGLint pf; @@ -241,8 +248,7 @@ static BOOL set_pixel_format( HDC hdc, int format, BOOL allow_change )
release_gl_drawable( gl );
- if (prev && prev != format && !allow_change) return FALSE; - if (win32u_set_window_pixel_format( hwnd, format, FALSE )) return TRUE; + if (win32u_set_window_pixel_format( hwnd, format, internal )) return TRUE; destroy_gl_drawable( hwnd ); return FALSE; }
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=130385
Your paranoid android.
=== w10pro64 (32 bit report) ===
ddraw: ddraw4.c:17303: Test failed: WM_KILLFOCUS was not received. ddraw4.c:17480: Test failed: Got unexpected hr 0x887600e1. ddraw4.c:17483: Test failed: Got unexpected hr 0x887600ff. 1f30:ddraw4: unhandled exception c0000005 at 004AFB6F
=== w1064v1507 (32 bit report) ===
ddraw: ddraw7.c:4719: Test failed: Lit quad with light has color 0x00000000. ddraw7.c:4719: Test failed: Lit quad with singular world matrix has color 0x00000000. ddraw7.c:4719: Test failed: Lit quad with transformation matrix has color 0x00000000.
=== w10pro64 (64 bit report) ===
ddraw: ddraw7.c:17178: Test failed: WM_KILLFOCUS was not received. ddraw7.c:17340: Test failed: Got unexpected hr 0x887600e1. ddraw7.c:17343: Test failed: Got unexpected hr 0x887600ff. 19fc:ddraw7: unhandled exception c0000005 at 00000000004E46D0
=== debian11 (32 bit fr report) ===
d3d8: Unhandled exception: floating point underflow in 32-bit code (0x7e91438f).
d3d9: Unhandled exception: floating point underflow in 32-bit code (0x7e91438f).
=== debian11 (32 bit he:IL report) ===
d3d8: Unhandled exception: floating point underflow in 32-bit code (0x7e91438f).
d3d9: Unhandled exception: floating point underflow in 32-bit code (0x7e91438f).
=== debian11 (32 bit hi:IN report) ===
d3d8: Unhandled exception: floating point underflow in 32-bit code (0x7e8bc38f).
d3d9: Unhandled exception: floating point underflow in 32-bit code (0x7e8bc38f).
=== debian11 (32 bit ja:JP report) ===
d3d8: Unhandled exception: floating point underflow in 32-bit code (0x7e9d638f).
d3d9: Unhandled exception: floating point underflow in 32-bit code (0x7ea8838f).
=== debian11 (32 bit zh:CN report) ===
d3d8: Unhandled exception: floating point underflow in 32-bit code (0x7e88a38f).
d3d9: Unhandled exception: floating point underflow in 32-bit code (0x7e88a38f).
v4: Fix an incorrect variable identifier in patch 9/10.