[PATCH 2/2] dxgi: Add locking around remaining wined3d calls.
Józef Kucia
jkucia at codeweavers.com
Wed Sep 16 18:10:14 CDT 2015
---
dlls/dxgi/device.c | 12 ++++++++++--
dlls/dxgi/factory.c | 2 ++
dlls/dxgi/surface.c | 2 ++
dlls/dxgi/swapchain.c | 18 +++++++++++++++++-
4 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/dlls/dxgi/device.c b/dlls/dxgi/device.c
index a6c4589..ae07bac 100644
--- a/dlls/dxgi/device.c
+++ b/dlls/dxgi/device.c
@@ -194,6 +194,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IWineDXGIDevice *ifac
surface_desc.depth = 1;
surface_desc.size = 0;
+ wined3d_mutex_lock();
memset(surface, 0, surface_count * sizeof(*surface));
for (i = 0; i < surface_count; ++i)
{
@@ -218,11 +219,13 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IWineDXGIDevice *ifac
TRACE("Created IDXGISurface %p (%u/%u)\n", surface[i], i + 1, surface_count);
}
+ wined3d_mutex_unlock();
IWineDXGIDeviceParent_Release(dxgi_device_parent);
return S_OK;
fail:
+ wined3d_mutex_unlock();
for (j = 0; j < i; ++j)
{
IDXGISurface_Release(surface[i]);
@@ -364,6 +367,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
device->IWineDXGIDevice_iface.lpVtbl = &dxgi_device_vtbl;
device->refcount = 1;
+ wined3d_mutex_lock();
wined3d_private_store_init(&device->private_store);
layer_base = device + 1;
@@ -373,6 +377,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
{
WARN("Failed to create device, returning %#x.\n", hr);
wined3d_private_store_cleanup(&device->private_store);
+ wined3d_mutex_unlock();
return hr;
}
@@ -382,6 +387,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
ERR("DXGI device should implement IWineD3DDeviceParent.\n");
IUnknown_Release(device->child_layer);
wined3d_private_store_cleanup(&device->private_store);
+ wined3d_mutex_unlock();
return hr;
}
wined3d_device_parent = IWineDXGIDeviceParent_get_wined3d_device_parent(dxgi_device_parent);
@@ -397,18 +403,18 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
hr = E_FAIL;
IUnknown_Release(device->child_layer);
wined3d_private_store_cleanup(&device->private_store);
+ wined3d_mutex_unlock();
return hr;
}
- wined3d_mutex_lock();
hr = wined3d_device_create(dxgi_factory->wined3d, dxgi_adapter->ordinal, WINED3D_DEVICE_TYPE_HAL,
NULL, 0, 4, wined3d_device_parent, &device->wined3d_device);
- wined3d_mutex_unlock();
if (FAILED(hr))
{
WARN("Failed to create a wined3d device, returning %#x.\n", hr);
IUnknown_Release(device->child_layer);
wined3d_private_store_cleanup(&device->private_store);
+ wined3d_mutex_unlock();
return hr;
}
@@ -422,8 +428,10 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
wined3d_device_decref(device->wined3d_device);
IUnknown_Release(device->child_layer);
wined3d_private_store_cleanup(&device->private_store);
+ wined3d_mutex_unlock();
return hr;
}
+ wined3d_mutex_unlock();
device->factory = &dxgi_factory->IDXGIFactory1_iface;
IDXGIFactory1_AddRef(device->factory);
diff --git a/dlls/dxgi/factory.c b/dlls/dxgi/factory.c
index fb8b7ce..2e0d5ab 100644
--- a/dlls/dxgi/factory.c
+++ b/dlls/dxgi/factory.c
@@ -253,7 +253,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IDXGIFactory1 *ifa
return hr;
}
+ wined3d_mutex_lock();
*swapchain = wined3d_swapchain_get_parent(wined3d_swapchain);
+ wined3d_mutex_unlock();
return S_OK;
}
diff --git a/dlls/dxgi/surface.c b/dlls/dxgi/surface.c
index 221a80d..4ce9130 100644
--- a/dlls/dxgi/surface.c
+++ b/dlls/dxgi/surface.c
@@ -168,7 +168,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_surface_GetDesc(IDXGISurface *iface, DXGI_
TRACE("iface %p, desc %p.\n", iface, desc);
+ wined3d_mutex_lock();
wined3d_resource_get_desc(surface->wined3d_resource, &wined3d_desc);
+ wined3d_mutex_unlock();
desc->Width = wined3d_desc.width;
desc->Height = wined3d_desc.height;
desc->Format = dxgi_format_from_wined3dformat(wined3d_desc.format);
diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c
index 53d2b7f..f1495cb 100644
--- a/dlls/dxgi/swapchain.c
+++ b/dlls/dxgi/swapchain.c
@@ -59,7 +59,11 @@ static ULONG STDMETHODCALLTYPE dxgi_swapchain_AddRef(IDXGISwapChain *iface)
TRACE("%p increasing refcount to %u\n", This, refcount);
if (refcount == 1)
+ {
+ wined3d_mutex_lock();
wined3d_swapchain_incref(This->wined3d_swapchain);
+ wined3d_mutex_unlock();
+ }
return refcount;
}
@@ -72,7 +76,11 @@ static ULONG STDMETHODCALLTYPE dxgi_swapchain_Release(IDXGISwapChain *iface)
TRACE("%p decreasing refcount to %u\n", This, refcount);
if (!refcount)
+ {
+ wined3d_mutex_lock();
wined3d_swapchain_decref(This->wined3d_swapchain);
+ wined3d_mutex_unlock();
+ }
return refcount;
}
@@ -130,13 +138,18 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetDevice(IDXGISwapChain *iface,
static HRESULT STDMETHODCALLTYPE dxgi_swapchain_Present(IDXGISwapChain *iface, UINT sync_interval, UINT flags)
{
struct dxgi_swapchain *This = impl_from_IDXGISwapChain(iface);
+ HRESULT hr;
TRACE("iface %p, sync_interval %u, flags %#x\n", iface, sync_interval, flags);
if (sync_interval) FIXME("Unimplemented sync interval %u\n", sync_interval);
if (flags) FIXME("Unimplemented flags %#x\n", flags);
- return wined3d_swapchain_present(This->wined3d_swapchain, NULL, NULL, NULL, NULL, 0);
+ wined3d_mutex_lock();
+ hr = wined3d_swapchain_present(This->wined3d_swapchain, NULL, NULL, NULL, NULL, 0);
+ wined3d_mutex_unlock();
+
+ return hr;
}
static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetBuffer(IDXGISwapChain *iface,
@@ -327,6 +340,7 @@ HRESULT dxgi_swapchain_init(struct dxgi_swapchain *swapchain, struct dxgi_device
swapchain->IDXGISwapChain_iface.lpVtbl = &dxgi_swapchain_vtbl;
swapchain->refcount = 1;
+ wined3d_mutex_lock();
wined3d_private_store_init(&swapchain->private_store);
if (FAILED(hr = wined3d_swapchain_create(device->wined3d_device, desc, swapchain,
@@ -334,8 +348,10 @@ HRESULT dxgi_swapchain_init(struct dxgi_swapchain *swapchain, struct dxgi_device
{
WARN("Failed to create wined3d swapchain, hr %#x.\n", hr);
wined3d_private_store_cleanup(&swapchain->private_store);
+ wined3d_mutex_unlock();
return hr;
}
+ wined3d_mutex_unlock();
return S_OK;
}
--
2.4.6
More information about the wine-patches
mailing list