dxgi: Replace dxgi_cs with wined3d_mutex.

This commit is contained in:
Józef Kucia 2015-09-17 01:10:13 +02:00 committed by Alexandre Julliard
parent 425160ce85
commit 0eefb93535
8 changed files with 50 additions and 62 deletions

View File

@ -153,9 +153,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_adapter_GetDesc1(IDXGIAdapter1 *iface, DXG
adapter_id.description_size = sizeof(description); adapter_id.description_size = sizeof(description);
adapter_id.device_name_size = 0; adapter_id.device_name_size = 0;
EnterCriticalSection(&dxgi_cs); wined3d_mutex_lock();
hr = wined3d_get_adapter_identifier(adapter->parent->wined3d, adapter->ordinal, 0, &adapter_id); hr = wined3d_get_adapter_identifier(adapter->parent->wined3d, adapter->ordinal, 0, &adapter_id);
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;

View File

@ -79,10 +79,10 @@ static ULONG STDMETHODCALLTYPE dxgi_device_Release(IWineDXGIDevice *iface)
if (!refcount) if (!refcount)
{ {
if (This->child_layer) IUnknown_Release(This->child_layer); if (This->child_layer) IUnknown_Release(This->child_layer);
EnterCriticalSection(&dxgi_cs); wined3d_mutex_lock();
wined3d_device_uninit_3d(This->wined3d_device); wined3d_device_uninit_3d(This->wined3d_device);
wined3d_device_decref(This->wined3d_device); wined3d_device_decref(This->wined3d_device);
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
IDXGIFactory1_Release(This->factory); IDXGIFactory1_Release(This->factory);
wined3d_private_store_cleanup(&This->private_store); wined3d_private_store_cleanup(&This->private_store);
HeapFree(GetProcessHeap(), 0, This); HeapFree(GetProcessHeap(), 0, This);
@ -152,9 +152,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_GetAdapter(IWineDXGIDevice *iface,
TRACE("iface %p, adapter %p\n", iface, adapter); TRACE("iface %p, adapter %p\n", iface, adapter);
EnterCriticalSection(&dxgi_cs); wined3d_mutex_lock();
wined3d_device_get_creation_parameters(This->wined3d_device, &create_parameters); wined3d_device_get_creation_parameters(This->wined3d_device, &create_parameters);
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
return IDXGIFactory1_EnumAdapters(This->factory, create_parameters.adapter_idx, adapter); return IDXGIFactory1_EnumAdapters(This->factory, create_parameters.adapter_idx, adapter);
} }
@ -400,10 +400,10 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
return hr; return hr;
} }
EnterCriticalSection(&dxgi_cs); 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);
LeaveCriticalSection(&dxgi_cs); 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);

View File

@ -25,15 +25,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(dxgi); WINE_DEFAULT_DEBUG_CHANNEL(dxgi);
static CRITICAL_SECTION_DEBUG dxgi_cs_debug =
{
0, 0, &dxgi_cs,
{&dxgi_cs_debug.ProcessLocksList,
&dxgi_cs_debug.ProcessLocksList},
0, 0, {(DWORD_PTR)(__FILE__ ": dxgi_cs")}
};
CRITICAL_SECTION dxgi_cs = {&dxgi_cs_debug, -1, 0, 0, 0, 0};
struct dxgi_main struct dxgi_main
{ {
HMODULE d3d10core; HMODULE d3d10core;
@ -46,7 +37,6 @@ static void dxgi_main_cleanup(void)
{ {
HeapFree(GetProcessHeap(), 0, dxgi_main.device_layers); HeapFree(GetProcessHeap(), 0, dxgi_main.device_layers);
FreeLibrary(dxgi_main.d3d10core); FreeLibrary(dxgi_main.d3d10core);
DeleteCriticalSection(&dxgi_cs);
} }
BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved) BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved)
@ -84,25 +74,25 @@ static BOOL get_layer(enum dxgi_device_layer_id id, struct dxgi_device_layer *la
{ {
UINT i; UINT i;
EnterCriticalSection(&dxgi_cs); wined3d_mutex_lock();
for (i = 0; i < dxgi_main.layer_count; ++i) for (i = 0; i < dxgi_main.layer_count; ++i)
{ {
if (dxgi_main.device_layers[i].id == id) if (dxgi_main.device_layers[i].id == id)
{ {
*layer = dxgi_main.device_layers[i]; *layer = dxgi_main.device_layers[i];
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
return TRUE; return TRUE;
} }
} }
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
return FALSE; return FALSE;
} }
static HRESULT register_d3d10core_layers(HMODULE d3d10core) static HRESULT register_d3d10core_layers(HMODULE d3d10core)
{ {
EnterCriticalSection(&dxgi_cs); wined3d_mutex_lock();
if (!dxgi_main.d3d10core) if (!dxgi_main.d3d10core)
{ {
@ -113,7 +103,7 @@ static HRESULT register_d3d10core_layers(HMODULE d3d10core)
if (!(ret = GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (const char *)d3d10core, &mod))) if (!(ret = GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (const char *)d3d10core, &mod)))
{ {
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
return E_FAIL; return E_FAIL;
} }
@ -122,14 +112,14 @@ static HRESULT register_d3d10core_layers(HMODULE d3d10core)
if (FAILED(hr)) if (FAILED(hr))
{ {
ERR("Failed to register d3d11 layers, returning %#x\n", hr); ERR("Failed to register d3d11 layers, returning %#x\n", hr);
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
return hr; return hr;
} }
dxgi_main.d3d10core = mod; dxgi_main.d3d10core = mod;
} }
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
return S_OK; return S_OK;
} }
@ -210,7 +200,7 @@ HRESULT WINAPI DXGID3D10RegisterLayers(const struct dxgi_device_layer *layers, U
TRACE("layers %p, layer_count %u\n", layers, layer_count); TRACE("layers %p, layer_count %u\n", layers, layer_count);
EnterCriticalSection(&dxgi_cs); wined3d_mutex_lock();
if (!dxgi_main.layer_count) if (!dxgi_main.layer_count)
new_layers = HeapAlloc(GetProcessHeap(), 0, layer_count * sizeof(*new_layers)); new_layers = HeapAlloc(GetProcessHeap(), 0, layer_count * sizeof(*new_layers));
@ -220,7 +210,7 @@ HRESULT WINAPI DXGID3D10RegisterLayers(const struct dxgi_device_layer *layers, U
if (!new_layers) if (!new_layers)
{ {
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
ERR("Failed to allocate layer memory\n"); ERR("Failed to allocate layer memory\n");
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
@ -238,7 +228,7 @@ HRESULT WINAPI DXGID3D10RegisterLayers(const struct dxgi_device_layer *layers, U
dxgi_main.device_layers = new_layers; dxgi_main.device_layers = new_layers;
dxgi_main.layer_count += layer_count; dxgi_main.layer_count += layer_count;
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
return S_OK; return S_OK;
} }

View File

@ -37,8 +37,6 @@
#include "wine/wined3d.h" #include "wine/wined3d.h"
#include "wine/winedxgi.h" #include "wine/winedxgi.h"
extern CRITICAL_SECTION dxgi_cs DECLSPEC_HIDDEN;
/* Layered device */ /* Layered device */
enum dxgi_device_layer_id enum dxgi_device_layer_id
{ {

View File

@ -80,9 +80,9 @@ static ULONG STDMETHODCALLTYPE dxgi_factory_Release(IDXGIFactory1 *iface)
} }
HeapFree(GetProcessHeap(), 0, factory->adapters); HeapFree(GetProcessHeap(), 0, factory->adapters);
EnterCriticalSection(&dxgi_cs); wined3d_mutex_lock();
wined3d_decref(factory->wined3d); wined3d_decref(factory->wined3d);
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
wined3d_private_store_cleanup(&factory->private_store); wined3d_private_store_cleanup(&factory->private_store);
HeapFree(GetProcessHeap(), 0, factory); HeapFree(GetProcessHeap(), 0, factory);
} }
@ -308,17 +308,17 @@ static HRESULT dxgi_factory_init(struct dxgi_factory *factory, BOOL extended)
factory->refcount = 1; factory->refcount = 1;
wined3d_private_store_init(&factory->private_store); wined3d_private_store_init(&factory->private_store);
EnterCriticalSection(&dxgi_cs); wined3d_mutex_lock();
factory->wined3d = wined3d_create(0); factory->wined3d = wined3d_create(0);
if (!factory->wined3d) if (!factory->wined3d)
{ {
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
wined3d_private_store_cleanup(&factory->private_store); wined3d_private_store_cleanup(&factory->private_store);
return DXGI_ERROR_UNSUPPORTED; return DXGI_ERROR_UNSUPPORTED;
} }
factory->adapter_count = wined3d_get_adapter_count(factory->wined3d); factory->adapter_count = wined3d_get_adapter_count(factory->wined3d);
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
factory->adapters = HeapAlloc(GetProcessHeap(), 0, factory->adapter_count * sizeof(*factory->adapters)); factory->adapters = HeapAlloc(GetProcessHeap(), 0, factory->adapter_count * sizeof(*factory->adapters));
if (!factory->adapters) if (!factory->adapters)
{ {
@ -367,9 +367,9 @@ static HRESULT dxgi_factory_init(struct dxgi_factory *factory, BOOL extended)
fail: fail:
HeapFree(GetProcessHeap(), 0, factory->adapters); HeapFree(GetProcessHeap(), 0, factory->adapters);
EnterCriticalSection(&dxgi_cs); wined3d_mutex_lock();
wined3d_decref(factory->wined3d); wined3d_decref(factory->wined3d);
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
wined3d_private_store_cleanup(&factory->private_store); wined3d_private_store_cleanup(&factory->private_store);
return hr; return hr;
} }
@ -399,21 +399,21 @@ HRESULT dxgi_factory_create(REFIID riid, void **factory, BOOL extended)
HWND dxgi_factory_get_device_window(struct dxgi_factory *factory) HWND dxgi_factory_get_device_window(struct dxgi_factory *factory)
{ {
EnterCriticalSection(&dxgi_cs); wined3d_mutex_lock();
if (!factory->device_window) if (!factory->device_window)
{ {
if (!(factory->device_window = CreateWindowA("static", "DXGI device window", if (!(factory->device_window = CreateWindowA("static", "DXGI device window",
WS_DISABLED, 0, 0, 0, 0, NULL, NULL, NULL, NULL))) WS_DISABLED, 0, 0, 0, 0, NULL, NULL, NULL, NULL)))
{ {
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
ERR("Failed to create a window.\n"); ERR("Failed to create a window.\n");
return NULL; return NULL;
} }
TRACE("Created device window %p for factory %p.\n", factory->device_window, factory); TRACE("Created device window %p for factory %p.\n", factory->device_window, factory);
} }
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
return factory->device_window; return factory->device_window;
} }

View File

@ -150,20 +150,20 @@ static HRESULT STDMETHODCALLTYPE dxgi_output_GetDisplayModeList(IDXGIOutput *ifa
wined3d = This->adapter->parent->wined3d; wined3d = This->adapter->parent->wined3d;
wined3d_format = wined3dformat_from_dxgi_format(format); wined3d_format = wined3dformat_from_dxgi_format(format);
EnterCriticalSection(&dxgi_cs); wined3d_mutex_lock();
max_count = wined3d_get_adapter_mode_count(wined3d, This->adapter->ordinal, max_count = wined3d_get_adapter_mode_count(wined3d, This->adapter->ordinal,
wined3d_format, WINED3D_SCANLINE_ORDERING_UNKNOWN); wined3d_format, WINED3D_SCANLINE_ORDERING_UNKNOWN);
if (!desc) if (!desc)
{ {
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
*mode_count = max_count; *mode_count = max_count;
return S_OK; return S_OK;
} }
if (max_count > *mode_count) if (max_count > *mode_count)
{ {
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
return DXGI_ERROR_MORE_DATA; return DXGI_ERROR_MORE_DATA;
} }
@ -179,7 +179,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_output_GetDisplayModeList(IDXGIOutput *ifa
if (FAILED(hr)) if (FAILED(hr))
{ {
WARN("EnumAdapterModes failed, hr %#x.\n", hr); WARN("EnumAdapterModes failed, hr %#x.\n", hr);
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
return hr; return hr;
} }
@ -191,7 +191,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_output_GetDisplayModeList(IDXGIOutput *ifa
desc[i].ScanlineOrdering = mode.scanline_ordering; desc[i].ScanlineOrdering = mode.scanline_ordering;
desc[i].Scaling = DXGI_MODE_SCALING_UNSPECIFIED; /* FIXME */ desc[i].Scaling = DXGI_MODE_SCALING_UNSPECIFIED; /* FIXME */
} }
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
return S_OK; return S_OK;
} }

View File

@ -150,17 +150,17 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetBuffer(IDXGISwapChain *iface,
TRACE("iface %p, buffer_idx %u, riid %s, surface %p\n", TRACE("iface %p, buffer_idx %u, riid %s, surface %p\n",
iface, buffer_idx, debugstr_guid(riid), surface); iface, buffer_idx, debugstr_guid(riid), surface);
EnterCriticalSection(&dxgi_cs); wined3d_mutex_lock();
if (!(texture = wined3d_swapchain_get_back_buffer(This->wined3d_swapchain, buffer_idx))) if (!(texture = wined3d_swapchain_get_back_buffer(This->wined3d_swapchain, buffer_idx)))
{ {
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
return DXGI_ERROR_INVALID_CALL; return DXGI_ERROR_INVALID_CALL;
} }
parent = wined3d_texture_get_parent(texture); parent = wined3d_texture_get_parent(texture);
hr = IUnknown_QueryInterface(parent, riid, surface); hr = IUnknown_QueryInterface(parent, riid, surface);
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
return hr; return hr;
} }
@ -191,9 +191,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetDesc(IDXGISwapChain *iface, D
if (desc == NULL) if (desc == NULL)
return E_INVALIDARG; return E_INVALIDARG;
EnterCriticalSection(&dxgi_cs); wined3d_mutex_lock();
wined3d_swapchain_get_desc(swapchain->wined3d_swapchain, &wined3d_desc); wined3d_swapchain_get_desc(swapchain->wined3d_swapchain, &wined3d_desc);
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
FIXME("Ignoring ScanlineOrdering, Scaling, SwapEffect and Flags\n"); FIXME("Ignoring ScanlineOrdering, Scaling, SwapEffect and Flags\n");
@ -230,7 +230,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_ResizeBuffers(IDXGISwapChain *if
if (flags) if (flags)
FIXME("Ignoring flags %#x.\n", flags); FIXME("Ignoring flags %#x.\n", flags);
EnterCriticalSection(&dxgi_cs); wined3d_mutex_lock();
wined3d_swapchain_get_desc(swapchain->wined3d_swapchain, &wined3d_desc); wined3d_swapchain_get_desc(swapchain->wined3d_swapchain, &wined3d_desc);
for (i = 0; i < wined3d_desc.backbuffer_count; ++i) for (i = 0; i < wined3d_desc.backbuffer_count; ++i)
{ {
@ -239,7 +239,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_ResizeBuffers(IDXGISwapChain *if
IUnknown_AddRef(parent); IUnknown_AddRef(parent);
if (IUnknown_Release(parent)) if (IUnknown_Release(parent))
{ {
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
return DXGI_ERROR_INVALID_CALL; return DXGI_ERROR_INVALID_CALL;
} }
} }
@ -247,7 +247,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_ResizeBuffers(IDXGISwapChain *if
wined3d_desc.backbuffer_format = wined3dformat_from_dxgi_format(format); wined3d_desc.backbuffer_format = wined3dformat_from_dxgi_format(format);
hr = wined3d_swapchain_resize_buffers(swapchain->wined3d_swapchain, buffer_count, width, height, hr = wined3d_swapchain_resize_buffers(swapchain->wined3d_swapchain, buffer_count, width, height,
wined3d_desc.backbuffer_format, wined3d_desc.multisample_type, wined3d_desc.multisample_quality); wined3d_desc.backbuffer_format, wined3d_desc.multisample_type, wined3d_desc.multisample_quality);
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
return hr; return hr;
} }

View File

@ -357,7 +357,7 @@ HRESULT dxgi_get_private_data(struct wined3d_private_store *store,
if (!data_size) if (!data_size)
return E_INVALIDARG; return E_INVALIDARG;
EnterCriticalSection(&dxgi_cs); wined3d_mutex_lock();
if (!(stored_data = wined3d_private_store_get_private_data(store, guid))) if (!(stored_data = wined3d_private_store_get_private_data(store, guid)))
{ {
hr = DXGI_ERROR_NOT_FOUND; hr = DXGI_ERROR_NOT_FOUND;
@ -384,7 +384,7 @@ HRESULT dxgi_get_private_data(struct wined3d_private_store *store,
hr = S_OK; hr = S_OK;
done: done:
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
return hr; return hr;
} }
@ -397,22 +397,22 @@ HRESULT dxgi_set_private_data(struct wined3d_private_store *store,
if (!data) if (!data)
{ {
EnterCriticalSection(&dxgi_cs); wined3d_mutex_lock();
if (!(entry = wined3d_private_store_get_private_data(store, guid))) if (!(entry = wined3d_private_store_get_private_data(store, guid)))
{ {
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
return S_FALSE; return S_FALSE;
} }
wined3d_private_store_free_private_data(store, entry); wined3d_private_store_free_private_data(store, entry);
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
return S_OK; return S_OK;
} }
EnterCriticalSection(&dxgi_cs); wined3d_mutex_lock();
hr = wined3d_private_store_set_private_data(store, guid, data, data_size, 0); hr = wined3d_private_store_set_private_data(store, guid, data, data_size, 0);
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
return hr; return hr;
} }
@ -425,10 +425,10 @@ HRESULT dxgi_set_private_data_interface(struct wined3d_private_store *store,
if (!object) if (!object)
return dxgi_set_private_data(store, guid, sizeof(object), &object); return dxgi_set_private_data(store, guid, sizeof(object), &object);
EnterCriticalSection(&dxgi_cs); wined3d_mutex_lock();
hr = wined3d_private_store_set_private_data(store, hr = wined3d_private_store_set_private_data(store,
guid, object, sizeof(object), WINED3DSPD_IUNKNOWN); guid, object, sizeof(object), WINED3DSPD_IUNKNOWN);
LeaveCriticalSection(&dxgi_cs); wined3d_mutex_unlock();
return hr; return hr;
} }