Commit 2a1186db authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

dxgi: Add locking around remaining wined3d calls.

parent 0eefb935
...@@ -194,6 +194,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IWineDXGIDevice *ifac ...@@ -194,6 +194,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IWineDXGIDevice *ifac
surface_desc.depth = 1; surface_desc.depth = 1;
surface_desc.size = 0; surface_desc.size = 0;
wined3d_mutex_lock();
memset(surface, 0, surface_count * sizeof(*surface)); memset(surface, 0, surface_count * sizeof(*surface));
for (i = 0; i < surface_count; ++i) for (i = 0; i < surface_count; ++i)
{ {
...@@ -218,11 +219,13 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IWineDXGIDevice *ifac ...@@ -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); TRACE("Created IDXGISurface %p (%u/%u)\n", surface[i], i + 1, surface_count);
} }
wined3d_mutex_unlock();
IWineDXGIDeviceParent_Release(dxgi_device_parent); IWineDXGIDeviceParent_Release(dxgi_device_parent);
return S_OK; return S_OK;
fail: fail:
wined3d_mutex_unlock();
for (j = 0; j < i; ++j) for (j = 0; j < i; ++j)
{ {
IDXGISurface_Release(surface[i]); IDXGISurface_Release(surface[i]);
...@@ -364,6 +367,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l ...@@ -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->IWineDXGIDevice_iface.lpVtbl = &dxgi_device_vtbl;
device->refcount = 1; device->refcount = 1;
wined3d_mutex_lock();
wined3d_private_store_init(&device->private_store); wined3d_private_store_init(&device->private_store);
layer_base = device + 1; layer_base = device + 1;
...@@ -373,6 +377,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l ...@@ -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); WARN("Failed to create device, returning %#x.\n", hr);
wined3d_private_store_cleanup(&device->private_store); wined3d_private_store_cleanup(&device->private_store);
wined3d_mutex_unlock();
return hr; return hr;
} }
...@@ -382,6 +387,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l ...@@ -382,6 +387,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
ERR("DXGI device should implement IWineD3DDeviceParent.\n"); ERR("DXGI device should implement IWineD3DDeviceParent.\n");
IUnknown_Release(device->child_layer); IUnknown_Release(device->child_layer);
wined3d_private_store_cleanup(&device->private_store); wined3d_private_store_cleanup(&device->private_store);
wined3d_mutex_unlock();
return hr; return hr;
} }
wined3d_device_parent = IWineDXGIDeviceParent_get_wined3d_device_parent(dxgi_device_parent); 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 ...@@ -397,18 +403,18 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
hr = E_FAIL; hr = E_FAIL;
IUnknown_Release(device->child_layer); IUnknown_Release(device->child_layer);
wined3d_private_store_cleanup(&device->private_store); wined3d_private_store_cleanup(&device->private_store);
wined3d_mutex_unlock();
return hr; return hr;
} }
wined3d_mutex_lock();
hr = wined3d_device_create(dxgi_factory->wined3d, dxgi_adapter->ordinal, WINED3D_DEVICE_TYPE_HAL, hr = wined3d_device_create(dxgi_factory->wined3d, dxgi_adapter->ordinal, WINED3D_DEVICE_TYPE_HAL,
NULL, 0, 4, wined3d_device_parent, &device->wined3d_device); NULL, 0, 4, wined3d_device_parent, &device->wined3d_device);
wined3d_mutex_unlock();
if (FAILED(hr)) if (FAILED(hr))
{ {
WARN("Failed to create a wined3d device, returning %#x.\n", hr); WARN("Failed to create a wined3d device, returning %#x.\n", hr);
IUnknown_Release(device->child_layer); IUnknown_Release(device->child_layer);
wined3d_private_store_cleanup(&device->private_store); wined3d_private_store_cleanup(&device->private_store);
wined3d_mutex_unlock();
return hr; return hr;
} }
...@@ -422,8 +428,10 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l ...@@ -422,8 +428,10 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
wined3d_device_decref(device->wined3d_device); wined3d_device_decref(device->wined3d_device);
IUnknown_Release(device->child_layer); IUnknown_Release(device->child_layer);
wined3d_private_store_cleanup(&device->private_store); wined3d_private_store_cleanup(&device->private_store);
wined3d_mutex_unlock();
return hr; return hr;
} }
wined3d_mutex_unlock();
device->factory = &dxgi_factory->IDXGIFactory1_iface; device->factory = &dxgi_factory->IDXGIFactory1_iface;
IDXGIFactory1_AddRef(device->factory); IDXGIFactory1_AddRef(device->factory);
......
...@@ -253,7 +253,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IDXGIFactory1 *ifa ...@@ -253,7 +253,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChain(IDXGIFactory1 *ifa
return hr; return hr;
} }
wined3d_mutex_lock();
*swapchain = wined3d_swapchain_get_parent(wined3d_swapchain); *swapchain = wined3d_swapchain_get_parent(wined3d_swapchain);
wined3d_mutex_unlock();
return S_OK; return S_OK;
} }
......
...@@ -168,7 +168,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_surface_GetDesc(IDXGISurface *iface, DXGI_ ...@@ -168,7 +168,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_surface_GetDesc(IDXGISurface *iface, DXGI_
TRACE("iface %p, desc %p.\n", iface, desc); TRACE("iface %p, desc %p.\n", iface, desc);
wined3d_mutex_lock();
wined3d_resource_get_desc(surface->wined3d_resource, &wined3d_desc); wined3d_resource_get_desc(surface->wined3d_resource, &wined3d_desc);
wined3d_mutex_unlock();
desc->Width = wined3d_desc.width; desc->Width = wined3d_desc.width;
desc->Height = wined3d_desc.height; desc->Height = wined3d_desc.height;
desc->Format = dxgi_format_from_wined3dformat(wined3d_desc.format); desc->Format = dxgi_format_from_wined3dformat(wined3d_desc.format);
......
...@@ -59,7 +59,11 @@ static ULONG STDMETHODCALLTYPE dxgi_swapchain_AddRef(IDXGISwapChain *iface) ...@@ -59,7 +59,11 @@ static ULONG STDMETHODCALLTYPE dxgi_swapchain_AddRef(IDXGISwapChain *iface)
TRACE("%p increasing refcount to %u\n", This, refcount); TRACE("%p increasing refcount to %u\n", This, refcount);
if (refcount == 1) if (refcount == 1)
{
wined3d_mutex_lock();
wined3d_swapchain_incref(This->wined3d_swapchain); wined3d_swapchain_incref(This->wined3d_swapchain);
wined3d_mutex_unlock();
}
return refcount; return refcount;
} }
...@@ -72,7 +76,11 @@ static ULONG STDMETHODCALLTYPE dxgi_swapchain_Release(IDXGISwapChain *iface) ...@@ -72,7 +76,11 @@ static ULONG STDMETHODCALLTYPE dxgi_swapchain_Release(IDXGISwapChain *iface)
TRACE("%p decreasing refcount to %u\n", This, refcount); TRACE("%p decreasing refcount to %u\n", This, refcount);
if (!refcount) if (!refcount)
{
wined3d_mutex_lock();
wined3d_swapchain_decref(This->wined3d_swapchain); wined3d_swapchain_decref(This->wined3d_swapchain);
wined3d_mutex_unlock();
}
return refcount; return refcount;
} }
...@@ -130,13 +138,18 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetDevice(IDXGISwapChain *iface, ...@@ -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) static HRESULT STDMETHODCALLTYPE dxgi_swapchain_Present(IDXGISwapChain *iface, UINT sync_interval, UINT flags)
{ {
struct dxgi_swapchain *This = impl_from_IDXGISwapChain(iface); struct dxgi_swapchain *This = impl_from_IDXGISwapChain(iface);
HRESULT hr;
TRACE("iface %p, sync_interval %u, flags %#x\n", iface, sync_interval, flags); 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 (sync_interval) FIXME("Unimplemented sync interval %u\n", sync_interval);
if (flags) FIXME("Unimplemented flags %#x\n", flags); 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, static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetBuffer(IDXGISwapChain *iface,
...@@ -327,6 +340,7 @@ HRESULT dxgi_swapchain_init(struct dxgi_swapchain *swapchain, struct dxgi_device ...@@ -327,6 +340,7 @@ HRESULT dxgi_swapchain_init(struct dxgi_swapchain *swapchain, struct dxgi_device
swapchain->IDXGISwapChain_iface.lpVtbl = &dxgi_swapchain_vtbl; swapchain->IDXGISwapChain_iface.lpVtbl = &dxgi_swapchain_vtbl;
swapchain->refcount = 1; swapchain->refcount = 1;
wined3d_mutex_lock();
wined3d_private_store_init(&swapchain->private_store); wined3d_private_store_init(&swapchain->private_store);
if (FAILED(hr = wined3d_swapchain_create(device->wined3d_device, desc, swapchain, 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 ...@@ -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); WARN("Failed to create wined3d swapchain, hr %#x.\n", hr);
wined3d_private_store_cleanup(&swapchain->private_store); wined3d_private_store_cleanup(&swapchain->private_store);
wined3d_mutex_unlock();
return hr; return hr;
} }
wined3d_mutex_unlock();
return S_OK; return S_OK;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment