Module: wine Branch: master Commit: 6dddb88ebe05680b9e161d033af2151a945cd77f URL: https://source.winehq.org/git/wine.git/?a=commit;h=6dddb88ebe05680b9e161d033...
Author: Józef Kucia jkucia@codeweavers.com Date: Mon Dec 3 14:41:06 2018 +0100
wined3d: Lock wined3d mutex in wined3d_get_adapter_identifier().
Signed-off-by: Józef Kucia jkucia@codeweavers.com Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/d3d8/directx.c | 2 -- dlls/d3d9/directx.c | 6 +----- dlls/dxgi/adapter.c | 12 ++---------- dlls/wined3d/directx.c | 16 +++++++++++----- 4 files changed, 14 insertions(+), 22 deletions(-)
diff --git a/dlls/d3d8/directx.c b/dlls/d3d8/directx.c index df5e7d6..385c70d 100644 --- a/dlls/d3d8/directx.c +++ b/dlls/d3d8/directx.c @@ -132,9 +132,7 @@ static HRESULT WINAPI d3d8_GetAdapterIdentifier(IDirect3D8 *iface, UINT adapter, adapter_id.device_name = NULL; /* d3d9 only */ adapter_id.device_name_size = 0; /* d3d9 only */
- wined3d_mutex_lock(); hr = wined3d_get_adapter_identifier(d3d8->wined3d, adapter, flags, &adapter_id); - wined3d_mutex_unlock();
identifier->DriverVersion = adapter_id.driver_version; identifier->VendorId = adapter_id.vendor_id; diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c index dd6e0bd..242e36d 100644 --- a/dlls/d3d9/directx.c +++ b/dlls/d3d9/directx.c @@ -137,9 +137,7 @@ static HRESULT WINAPI d3d9_GetAdapterIdentifier(IDirect3D9Ex *iface, UINT adapte adapter_id.device_name = identifier->DeviceName; adapter_id.device_name_size = sizeof(identifier->DeviceName);
- wined3d_mutex_lock(); hr = wined3d_get_adapter_identifier(d3d9->wined3d, adapter, flags, &adapter_id); - wined3d_mutex_unlock();
identifier->DriverVersion = adapter_id.driver_version; identifier->VendorId = adapter_id.vendor_id; @@ -544,11 +542,9 @@ static HRESULT WINAPI d3d9_GetAdapterLUID(IDirect3D9Ex *iface, UINT adapter, LUI adapter_id.description_size = 0; adapter_id.device_name_size = 0;
- wined3d_mutex_lock(); hr = wined3d_get_adapter_identifier(d3d9->wined3d, adapter, 0, &adapter_id); - wined3d_mutex_unlock();
- memcpy(luid, &adapter_id.adapter_luid, sizeof(*luid)); + *luid = adapter_id.adapter_luid;
return hr; } diff --git a/dlls/dxgi/adapter.c b/dlls/dxgi/adapter.c index 4371ae7..31baae6 100644 --- a/dlls/dxgi/adapter.c +++ b/dlls/dxgi/adapter.c @@ -158,11 +158,7 @@ static HRESULT dxgi_adapter_get_desc(struct dxgi_adapter *adapter, DXGI_ADAPTER_ adapter_id.description_size = sizeof(description); adapter_id.device_name_size = 0;
- wined3d_mutex_lock(); - hr = wined3d_get_adapter_identifier(adapter->factory->wined3d, adapter->ordinal, 0, &adapter_id); - wined3d_mutex_unlock(); - - if (FAILED(hr)) + if (FAILED(hr = wined3d_get_adapter_identifier(adapter->factory->wined3d, adapter->ordinal, 0, &adapter_id))) return hr;
if (!MultiByteToWideChar(CP_ACP, 0, description, -1, desc->Description, 128)) @@ -311,11 +307,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_adapter_QueryVideoMemoryInfo(IWineDXGIAdap adapter_id.description_size = 0; adapter_id.device_name_size = 0;
- wined3d_mutex_lock(); - hr = wined3d_get_adapter_identifier(adapter->factory->wined3d, adapter->ordinal, 0, &adapter_id); - wined3d_mutex_unlock(); - - if (FAILED(hr)) + if (FAILED(hr = wined3d_get_adapter_identifier(adapter->factory->wined3d, adapter->ordinal, 0, &adapter_id))) return hr;
switch (segment_group) diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index b9aa9fa..544c76e 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -1155,8 +1155,6 @@ HRESULT CDECL wined3d_set_adapter_display_mode(struct wined3d *wined3d, return WINED3D_OK; }
-/* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER, - and fields being inserted in the middle, a new structure is used in place */ HRESULT CDECL wined3d_get_adapter_identifier(const struct wined3d *wined3d, UINT adapter_idx, DWORD flags, struct wined3d_adapter_identifier *identifier) { @@ -1166,8 +1164,10 @@ HRESULT CDECL wined3d_get_adapter_identifier(const struct wined3d *wined3d, TRACE("wined3d %p, adapter_idx %u, flags %#x, identifier %p.\n", wined3d, adapter_idx, flags, identifier);
+ wined3d_mutex_lock(); + if (adapter_idx >= wined3d->adapter_count) - return WINED3DERR_INVALIDCALL; + goto fail;
adapter = &wined3d->adapters[adapter_idx];
@@ -1194,7 +1194,7 @@ HRESULT CDECL wined3d_get_adapter_identifier(const struct wined3d *wined3d, identifier->device_name_size, NULL, NULL)) { ERR("Failed to convert device name, last error %#x.\n", GetLastError()); - return WINED3DERR_INVALIDCALL; + goto fail; } }
@@ -1206,11 +1206,17 @@ HRESULT CDECL wined3d_get_adapter_identifier(const struct wined3d *wined3d, identifier->revision = 0; memcpy(&identifier->device_identifier, &IID_D3DDEVICE_D3DUID, sizeof(identifier->device_identifier)); identifier->whql_level = (flags & WINED3DENUM_NO_WHQL_LEVEL) ? 0 : 1; - memcpy(&identifier->adapter_luid, &adapter->luid, sizeof(identifier->adapter_luid)); + identifier->adapter_luid = adapter->luid; identifier->video_memory = min(~(SIZE_T)0, adapter->driver_info.vram_bytes); identifier->shared_system_memory = min(~(SIZE_T)0, adapter->driver_info.sysmem_bytes);
+ wined3d_mutex_unlock(); + return WINED3D_OK; + +fail: + wined3d_mutex_unlock(); + return WINED3DERR_INVALIDCALL; }
HRESULT CDECL wined3d_get_adapter_raster_status(const struct wined3d *wined3d, UINT adapter_idx,