dxgi: Replace dxgi_cs with wined3d_mutex.
This commit is contained in:
parent
425160ce85
commit
0eefb93535
|
@ -153,9 +153,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_adapter_GetDesc1(IDXGIAdapter1 *iface, DXG
|
|||
adapter_id.description_size = sizeof(description);
|
||||
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);
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
|
|
@ -79,10 +79,10 @@ static ULONG STDMETHODCALLTYPE dxgi_device_Release(IWineDXGIDevice *iface)
|
|||
if (!refcount)
|
||||
{
|
||||
if (This->child_layer) IUnknown_Release(This->child_layer);
|
||||
EnterCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_lock();
|
||||
wined3d_device_uninit_3d(This->wined3d_device);
|
||||
wined3d_device_decref(This->wined3d_device);
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
IDXGIFactory1_Release(This->factory);
|
||||
wined3d_private_store_cleanup(&This->private_store);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
|
@ -152,9 +152,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_GetAdapter(IWineDXGIDevice *iface,
|
|||
|
||||
TRACE("iface %p, adapter %p\n", iface, adapter);
|
||||
|
||||
EnterCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_lock();
|
||||
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);
|
||||
}
|
||||
|
@ -400,10 +400,10 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
|
|||
return hr;
|
||||
}
|
||||
|
||||
EnterCriticalSection(&dxgi_cs);
|
||||
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);
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to create a wined3d device, returning %#x.\n", hr);
|
||||
|
|
|
@ -25,15 +25,6 @@
|
|||
|
||||
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
|
||||
{
|
||||
HMODULE d3d10core;
|
||||
|
@ -46,7 +37,6 @@ static void dxgi_main_cleanup(void)
|
|||
{
|
||||
HeapFree(GetProcessHeap(), 0, dxgi_main.device_layers);
|
||||
FreeLibrary(dxgi_main.d3d10core);
|
||||
DeleteCriticalSection(&dxgi_cs);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
EnterCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_lock();
|
||||
|
||||
for (i = 0; i < dxgi_main.layer_count; ++i)
|
||||
{
|
||||
if (dxgi_main.device_layers[i].id == id)
|
||||
{
|
||||
*layer = dxgi_main.device_layers[i];
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static HRESULT register_d3d10core_layers(HMODULE d3d10core)
|
||||
{
|
||||
EnterCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_lock();
|
||||
|
||||
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)))
|
||||
{
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
@ -122,14 +112,14 @@ static HRESULT register_d3d10core_layers(HMODULE d3d10core)
|
|||
if (FAILED(hr))
|
||||
{
|
||||
ERR("Failed to register d3d11 layers, returning %#x\n", hr);
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
return hr;
|
||||
}
|
||||
|
||||
dxgi_main.d3d10core = mod;
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
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);
|
||||
|
||||
EnterCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_lock();
|
||||
|
||||
if (!dxgi_main.layer_count)
|
||||
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)
|
||||
{
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
ERR("Failed to allocate layer memory\n");
|
||||
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.layer_count += layer_count;
|
||||
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
|
|
@ -37,8 +37,6 @@
|
|||
#include "wine/wined3d.h"
|
||||
#include "wine/winedxgi.h"
|
||||
|
||||
extern CRITICAL_SECTION dxgi_cs DECLSPEC_HIDDEN;
|
||||
|
||||
/* Layered device */
|
||||
enum dxgi_device_layer_id
|
||||
{
|
||||
|
|
|
@ -80,9 +80,9 @@ static ULONG STDMETHODCALLTYPE dxgi_factory_Release(IDXGIFactory1 *iface)
|
|||
}
|
||||
HeapFree(GetProcessHeap(), 0, factory->adapters);
|
||||
|
||||
EnterCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_lock();
|
||||
wined3d_decref(factory->wined3d);
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
wined3d_private_store_cleanup(&factory->private_store);
|
||||
HeapFree(GetProcessHeap(), 0, factory);
|
||||
}
|
||||
|
@ -308,17 +308,17 @@ static HRESULT dxgi_factory_init(struct dxgi_factory *factory, BOOL extended)
|
|||
factory->refcount = 1;
|
||||
wined3d_private_store_init(&factory->private_store);
|
||||
|
||||
EnterCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_lock();
|
||||
factory->wined3d = wined3d_create(0);
|
||||
if (!factory->wined3d)
|
||||
{
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
wined3d_private_store_cleanup(&factory->private_store);
|
||||
return DXGI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
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));
|
||||
if (!factory->adapters)
|
||||
{
|
||||
|
@ -367,9 +367,9 @@ static HRESULT dxgi_factory_init(struct dxgi_factory *factory, BOOL extended)
|
|||
|
||||
fail:
|
||||
HeapFree(GetProcessHeap(), 0, factory->adapters);
|
||||
EnterCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_lock();
|
||||
wined3d_decref(factory->wined3d);
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
wined3d_private_store_cleanup(&factory->private_store);
|
||||
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)
|
||||
{
|
||||
EnterCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_lock();
|
||||
|
||||
if (!factory->device_window)
|
||||
{
|
||||
if (!(factory->device_window = CreateWindowA("static", "DXGI device window",
|
||||
WS_DISABLED, 0, 0, 0, 0, NULL, NULL, NULL, NULL)))
|
||||
{
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
ERR("Failed to create a window.\n");
|
||||
return NULL;
|
||||
}
|
||||
TRACE("Created device window %p for factory %p.\n", factory->device_window, factory);
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return factory->device_window;
|
||||
}
|
||||
|
|
|
@ -150,20 +150,20 @@ static HRESULT STDMETHODCALLTYPE dxgi_output_GetDisplayModeList(IDXGIOutput *ifa
|
|||
wined3d = This->adapter->parent->wined3d;
|
||||
wined3d_format = wined3dformat_from_dxgi_format(format);
|
||||
|
||||
EnterCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_lock();
|
||||
max_count = wined3d_get_adapter_mode_count(wined3d, This->adapter->ordinal,
|
||||
wined3d_format, WINED3D_SCANLINE_ORDERING_UNKNOWN);
|
||||
|
||||
if (!desc)
|
||||
{
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
*mode_count = max_count;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if (max_count > *mode_count)
|
||||
{
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
return DXGI_ERROR_MORE_DATA;
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_output_GetDisplayModeList(IDXGIOutput *ifa
|
|||
if (FAILED(hr))
|
||||
{
|
||||
WARN("EnumAdapterModes failed, hr %#x.\n", hr);
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
@ -191,7 +191,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_output_GetDisplayModeList(IDXGIOutput *ifa
|
|||
desc[i].ScanlineOrdering = mode.scanline_ordering;
|
||||
desc[i].Scaling = DXGI_MODE_SCALING_UNSPECIFIED; /* FIXME */
|
||||
}
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
|
|
@ -150,17 +150,17 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetBuffer(IDXGISwapChain *iface,
|
|||
TRACE("iface %p, buffer_idx %u, riid %s, surface %p\n",
|
||||
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)))
|
||||
{
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
return DXGI_ERROR_INVALID_CALL;
|
||||
}
|
||||
|
||||
parent = wined3d_texture_get_parent(texture);
|
||||
hr = IUnknown_QueryInterface(parent, riid, surface);
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
@ -191,9 +191,9 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_GetDesc(IDXGISwapChain *iface, D
|
|||
if (desc == NULL)
|
||||
return E_INVALIDARG;
|
||||
|
||||
EnterCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_lock();
|
||||
wined3d_swapchain_get_desc(swapchain->wined3d_swapchain, &wined3d_desc);
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
FIXME("Ignoring ScanlineOrdering, Scaling, SwapEffect and Flags\n");
|
||||
|
||||
|
@ -230,7 +230,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_ResizeBuffers(IDXGISwapChain *if
|
|||
if (flags)
|
||||
FIXME("Ignoring flags %#x.\n", flags);
|
||||
|
||||
EnterCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_lock();
|
||||
wined3d_swapchain_get_desc(swapchain->wined3d_swapchain, &wined3d_desc);
|
||||
for (i = 0; i < wined3d_desc.backbuffer_count; ++i)
|
||||
{
|
||||
|
@ -239,7 +239,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_swapchain_ResizeBuffers(IDXGISwapChain *if
|
|||
IUnknown_AddRef(parent);
|
||||
if (IUnknown_Release(parent))
|
||||
{
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
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);
|
||||
hr = wined3d_swapchain_resize_buffers(swapchain->wined3d_swapchain, buffer_count, width, height,
|
||||
wined3d_desc.backbuffer_format, wined3d_desc.multisample_type, wined3d_desc.multisample_quality);
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
|
|
@ -357,7 +357,7 @@ HRESULT dxgi_get_private_data(struct wined3d_private_store *store,
|
|||
if (!data_size)
|
||||
return E_INVALIDARG;
|
||||
|
||||
EnterCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_lock();
|
||||
if (!(stored_data = wined3d_private_store_get_private_data(store, guid)))
|
||||
{
|
||||
hr = DXGI_ERROR_NOT_FOUND;
|
||||
|
@ -384,7 +384,7 @@ HRESULT dxgi_get_private_data(struct wined3d_private_store *store,
|
|||
hr = S_OK;
|
||||
|
||||
done:
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
@ -397,22 +397,22 @@ HRESULT dxgi_set_private_data(struct wined3d_private_store *store,
|
|||
|
||||
if (!data)
|
||||
{
|
||||
EnterCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_lock();
|
||||
if (!(entry = wined3d_private_store_get_private_data(store, guid)))
|
||||
{
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
wined3d_private_store_free_private_data(store, entry);
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
EnterCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_lock();
|
||||
hr = wined3d_private_store_set_private_data(store, guid, data, data_size, 0);
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
@ -425,10 +425,10 @@ HRESULT dxgi_set_private_data_interface(struct wined3d_private_store *store,
|
|||
if (!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,
|
||||
guid, object, sizeof(object), WINED3DSPD_IUNKNOWN);
|
||||
LeaveCriticalSection(&dxgi_cs);
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue