dxgi: Store IDXGIAdapter in IDXGIDevice.

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>
This commit is contained in:
Józef Kucia 2016-04-14 12:20:22 +02:00 committed by Alexandre Julliard
parent b835a35881
commit 25ad11cef7
2 changed files with 19 additions and 17 deletions

View File

@ -72,21 +72,23 @@ static ULONG STDMETHODCALLTYPE dxgi_device_AddRef(IWineDXGIDevice *iface)
static ULONG STDMETHODCALLTYPE dxgi_device_Release(IWineDXGIDevice *iface) static ULONG STDMETHODCALLTYPE dxgi_device_Release(IWineDXGIDevice *iface)
{ {
struct dxgi_device *This = impl_from_IWineDXGIDevice(iface); struct dxgi_device *device = impl_from_IWineDXGIDevice(iface);
ULONG refcount = InterlockedDecrement(&This->refcount); ULONG refcount = InterlockedDecrement(&device->refcount);
TRACE("%p decreasing refcount to %u\n", This, refcount); TRACE("%p decreasing refcount to %u.\n", device, refcount);
if (!refcount) if (!refcount)
{ {
if (This->child_layer) IUnknown_Release(This->child_layer); if (device->child_layer)
IUnknown_Release(device->child_layer);
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_device_uninit_3d(This->wined3d_device); wined3d_device_uninit_3d(device->wined3d_device);
wined3d_device_decref(This->wined3d_device); wined3d_device_decref(device->wined3d_device);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
IDXGIFactory1_Release(This->factory); IDXGIAdapter1_Release(device->adapter);
wined3d_private_store_cleanup(&This->private_store); IDXGIFactory1_Release(device->factory);
HeapFree(GetProcessHeap(), 0, This); wined3d_private_store_cleanup(&device->private_store);
HeapFree(GetProcessHeap(), 0, device);
} }
return refcount; return refcount;
@ -148,16 +150,13 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_GetParent(IWineDXGIDevice *iface, R
static HRESULT STDMETHODCALLTYPE dxgi_device_GetAdapter(IWineDXGIDevice *iface, IDXGIAdapter **adapter) static HRESULT STDMETHODCALLTYPE dxgi_device_GetAdapter(IWineDXGIDevice *iface, IDXGIAdapter **adapter)
{ {
struct dxgi_device *This = impl_from_IWineDXGIDevice(iface); struct dxgi_device *device = impl_from_IWineDXGIDevice(iface);
struct wined3d_device_creation_parameters create_parameters;
TRACE("iface %p, adapter %p\n", iface, adapter); TRACE("iface %p, adapter %p.\n", iface, adapter);
wined3d_mutex_lock(); *adapter = (IDXGIAdapter *)device->adapter;
wined3d_device_get_creation_parameters(This->wined3d_device, &create_parameters); IDXGIAdapter_AddRef(*adapter);
wined3d_mutex_unlock(); return S_OK;
return IDXGIFactory1_EnumAdapters(This->factory, create_parameters.adapter_idx, adapter);
} }
static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IWineDXGIDevice *iface, static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IWineDXGIDevice *iface,
@ -457,6 +456,8 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
device->factory = &dxgi_factory->IDXGIFactory1_iface; device->factory = &dxgi_factory->IDXGIFactory1_iface;
IDXGIFactory1_AddRef(device->factory); IDXGIFactory1_AddRef(device->factory);
device->adapter = &dxgi_adapter->IDXGIAdapter1_iface;
IDXGIAdapter1_AddRef(device->adapter);
return S_OK; return S_OK;
} }

View File

@ -119,6 +119,7 @@ struct dxgi_device
struct wined3d_private_store private_store; struct wined3d_private_store private_store;
struct wined3d_device *wined3d_device; struct wined3d_device *wined3d_device;
IDXGIFactory1 *factory; IDXGIFactory1 *factory;
IDXGIAdapter1 *adapter;
}; };
HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *layer, HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *layer,