From: Józef Kucia jkucia@codeweavers.com
Fixes a deadlock. It can also be seen as a small step towards more fine-grained locking in wined3d.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45431 Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/dxgi/swapchain.c | 7 +------ dlls/wined3d/swapchain.c | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 13 deletions(-)
diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c index 0d325cf61f9d..76a4d440565b 100644 --- a/dlls/dxgi/swapchain.c +++ b/dlls/dxgi/swapchain.c @@ -434,7 +434,6 @@ static HRESULT STDMETHODCALLTYPE d3d11_swapchain_ResizeTarget(IDXGISwapChain1 *i { struct d3d11_swapchain *swapchain = d3d11_swapchain_from_IDXGISwapChain1(iface); struct wined3d_display_mode mode; - HRESULT hr;
TRACE("iface %p, target_mode_desc %p.\n", iface, target_mode_desc);
@@ -451,11 +450,7 @@ static HRESULT STDMETHODCALLTYPE d3d11_swapchain_ResizeTarget(IDXGISwapChain1 *i
wined3d_display_mode_from_dxgi(&mode, target_mode_desc);
- wined3d_mutex_lock(); - hr = wined3d_swapchain_resize_target(swapchain->wined3d_swapchain, &mode); - wined3d_mutex_unlock(); - - return hr; + return wined3d_swapchain_resize_target(swapchain->wined3d_swapchain, &mode); }
static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetContainingOutput(IDXGISwapChain1 *iface, IDXGIOutput **output) diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index 43582ceb2eea..2170629801c5 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -1327,29 +1327,38 @@ static HRESULT wined3d_swapchain_set_display_mode(struct wined3d_swapchain *swap HRESULT CDECL wined3d_swapchain_resize_target(struct wined3d_swapchain *swapchain, const struct wined3d_display_mode *mode) { - struct wined3d_device *device = swapchain->device; struct wined3d_display_mode actual_mode; RECT original_window_rect, window_rect; + struct wined3d_device *device; + HWND window; HRESULT hr;
TRACE("swapchain %p, mode %p.\n", swapchain, mode);
+ wined3d_mutex_lock(); + + device = swapchain->device; + window = swapchain->device_window; + if (swapchain->desc.windowed) { SetRect(&window_rect, 0, 0, mode->width, mode->height); AdjustWindowRectEx(&window_rect, - GetWindowLongW(swapchain->device_window, GWL_STYLE), FALSE, - GetWindowLongW(swapchain->device_window, GWL_EXSTYLE)); + GetWindowLongW(window, GWL_STYLE), FALSE, + GetWindowLongW(window, GWL_EXSTYLE)); SetRect(&window_rect, 0, 0, window_rect.right - window_rect.left, window_rect.bottom - window_rect.top); - GetWindowRect(swapchain->device_window, &original_window_rect); + GetWindowRect(window, &original_window_rect); OffsetRect(&window_rect, original_window_rect.left, original_window_rect.top); } else if (swapchain->desc.flags & WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH) { actual_mode = *mode; if (FAILED(hr = wined3d_swapchain_set_display_mode(swapchain, &actual_mode))) + { + wined3d_mutex_unlock(); return hr; + } SetRect(&window_rect, 0, 0, actual_mode.width, actual_mode.height); } else @@ -1358,15 +1367,17 @@ HRESULT CDECL wined3d_swapchain_resize_target(struct wined3d_swapchain *swapchai &actual_mode, NULL))) { ERR("Failed to get display mode, hr %#x.\n", hr); + wined3d_mutex_unlock(); return hr; }
SetRect(&window_rect, 0, 0, actual_mode.width, actual_mode.height); }
- MoveWindow(swapchain->device_window, window_rect.left, window_rect.top, - window_rect.right - window_rect.left, - window_rect.bottom - window_rect.top, TRUE); + wined3d_mutex_unlock(); + + MoveWindow(window, window_rect.left, window_rect.top, + window_rect.right - window_rect.left, window_rect.bottom - window_rect.top, TRUE);
return WINED3D_OK; }
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=45199
Your paranoid android.
=== debian9 (build log) ===
X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig) X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig)
=== debian9 (build log) ===
X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig) X Error of failed request: BadValue (integer parameter out of range for operation) Major opcode of failed request: 140 (RANDR) Minor opcode of failed request: 21 (RRSetCrtcConfig)