[PATCH 7/9] wined3d: Lock wined3d mutex in wined3d_swapchain_decref().
Józef Kucia
joseph.kucia at gmail.com
Thu Nov 29 07:33:45 CST 2018
From: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/d3d8/swapchain.c | 2 --
dlls/d3d9/swapchain.c | 2 --
dlls/dxgi/swapchain.c | 2 --
dlls/wined3d/swapchain.c | 7 ++++++-
4 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/dlls/d3d8/swapchain.c b/dlls/d3d8/swapchain.c
index 92ec011f99cb..c137d0ded0bb 100644
--- a/dlls/d3d8/swapchain.c
+++ b/dlls/d3d8/swapchain.c
@@ -74,9 +74,7 @@ static ULONG WINAPI d3d8_swapchain_Release(IDirect3DSwapChain8 *iface)
{
IDirect3DDevice8 *parent_device = swapchain->parent_device;
- wined3d_mutex_lock();
wined3d_swapchain_decref(swapchain->wined3d_swapchain);
- wined3d_mutex_unlock();
if (parent_device)
IDirect3DDevice8_Release(parent_device);
diff --git a/dlls/d3d9/swapchain.c b/dlls/d3d9/swapchain.c
index 81d560539051..5bd16bad5a7d 100644
--- a/dlls/d3d9/swapchain.c
+++ b/dlls/d3d9/swapchain.c
@@ -124,9 +124,7 @@ static ULONG WINAPI d3d9_swapchain_Release(IDirect3DSwapChain9Ex *iface)
{
IDirect3DDevice9Ex *parent_device = swapchain->parent_device;
- wined3d_mutex_lock();
wined3d_swapchain_decref(swapchain->wined3d_swapchain);
- wined3d_mutex_unlock();
/* Release the device last, as it may cause the device to be destroyed. */
if (parent_device)
diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c
index 914ba480e827..4dfa06873351 100644
--- a/dlls/dxgi/swapchain.c
+++ b/dlls/dxgi/swapchain.c
@@ -168,9 +168,7 @@ static ULONG STDMETHODCALLTYPE d3d11_swapchain_Release(IDXGISwapChain1 *iface)
}
if (swapchain->factory)
IDXGIFactory_Release(swapchain->factory);
- wined3d_mutex_lock();
wined3d_swapchain_decref(swapchain->wined3d_swapchain);
- wined3d_mutex_unlock();
if (device)
IWineDXGIDevice_Release(device);
}
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 2170629801c5..ed8a3b3aca5f 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -109,17 +109,22 @@ ULONG CDECL wined3d_swapchain_incref(struct wined3d_swapchain *swapchain)
ULONG CDECL wined3d_swapchain_decref(struct wined3d_swapchain *swapchain)
{
ULONG refcount = InterlockedDecrement(&swapchain->ref);
+ struct wined3d_device *device;
TRACE("%p decreasing refcount to %u.\n", swapchain, refcount);
if (!refcount)
{
- struct wined3d_device *device = swapchain->device;
+ wined3d_mutex_lock();
+ device = swapchain->device;
device->cs->ops->finish(device->cs, WINED3D_CS_QUEUE_DEFAULT);
swapchain_cleanup(swapchain);
swapchain->parent_ops->wined3d_object_destroyed(swapchain->parent);
+
+ wined3d_mutex_unlock();
+
heap_free(swapchain);
}
--
2.18.1
More information about the wine-devel
mailing list