Module: wine Branch: master Commit: 75f7bd0eea4f0a9a351c858196ef6c83fda2a747 URL: https://gitlab.winehq.org/wine/wine/-/commit/75f7bd0eea4f0a9a351c858196ef6c8...
Author: Stefan Dösinger stefan@codeweavers.com Date: Mon Feb 27 10:38:46 2023 +0300
dxgi: Unlock the wined3d mutex after storing the new target.
Otherwise a second thread might set it to something else between the unlock and assignment.
---
dlls/dxgi/swapchain.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c index 454d58792fe..9449d13ae49 100644 --- a/dlls/dxgi/swapchain.c +++ b/dlls/dxgi/swapchain.c @@ -410,12 +410,11 @@ static HRESULT STDMETHODCALLTYPE DECLSPEC_HOTPATCH d3d11_swapchain_SetFullscreen swapchain_desc.output = dxgi_output->wined3d_output; swapchain_desc.windowed = !fullscreen; hr = wined3d_swapchain_state_set_fullscreen(state, &swapchain_desc, NULL); - wined3d_mutex_unlock(); if (FAILED(hr)) { IDXGIOutput_Release(target); - - return DXGI_ERROR_NOT_CURRENTLY_AVAILABLE; + hr = DXGI_ERROR_NOT_CURRENTLY_AVAILABLE; + goto done; }
if (!fullscreen) @@ -428,7 +427,9 @@ static HRESULT STDMETHODCALLTYPE DECLSPEC_HOTPATCH d3d11_swapchain_SetFullscreen IDXGIOutput_Release(swapchain->target); swapchain->target = target;
- return S_OK; +done: + wined3d_mutex_unlock(); + return hr; }
static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetFullscreenState(IDXGISwapChain1 *iface, @@ -2098,13 +2099,20 @@ static HRESULT STDMETHODCALLTYPE DECLSPEC_HOTPATCH d3d12_swapchain_SetFullscreen
if (FAILED(hr = wined3d_swapchain_desc_from_dxgi(&wined3d_desc, target, window, swapchain_desc, fullscreen_desc))) - goto fail; + { + IDXGIOutput_Release(target); + return hr; + } + wined3d_mutex_lock(); wined3d_desc.windowed = !fullscreen; hr = wined3d_swapchain_state_set_fullscreen(swapchain->state, &wined3d_desc, NULL); - wined3d_mutex_unlock(); if (FAILED(hr)) - goto fail; + { + IDXGIOutput_Release(target); + hr = DXGI_ERROR_NOT_CURRENTLY_AVAILABLE; + goto done; + }
fullscreen_desc->Windowed = wined3d_desc.windowed; if (!fullscreen) @@ -2117,12 +2125,9 @@ static HRESULT STDMETHODCALLTYPE DECLSPEC_HOTPATCH d3d12_swapchain_SetFullscreen IDXGIOutput_Release(swapchain->target); swapchain->target = target;
- return S_OK; - -fail: - IDXGIOutput_Release(target); - - return DXGI_ERROR_NOT_CURRENTLY_AVAILABLE; +done: + wined3d_mutex_unlock(); + return hr; }
static HRESULT STDMETHODCALLTYPE d3d12_swapchain_GetFullscreenState(IDXGISwapChain4 *iface,