Commit 72aaaac4 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

dxgi: Get rid of IWineDXGIFactory.

parent 22abd896
......@@ -105,7 +105,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_adapter_GetParent(IDXGIAdapter1 *iface, RE
TRACE("iface %p, iid %s, parent %p\n", iface, debugstr_guid(iid), parent);
return IWineDXGIFactory_QueryInterface(adapter->parent, iid, parent);
return IDXGIFactory1_QueryInterface(&adapter->parent->IDXGIFactory1_iface, iid, parent);
}
static HRESULT STDMETHODCALLTYPE dxgi_adapter_EnumOutputs(IDXGIAdapter1 *iface,
......@@ -134,7 +134,6 @@ static HRESULT STDMETHODCALLTYPE dxgi_adapter_GetDesc1(IDXGIAdapter1 *iface, DXG
struct dxgi_adapter *adapter = impl_from_IDXGIAdapter1(iface);
struct wined3d_adapter_identifier adapter_id;
char description[128];
struct wined3d *wined3d;
HRESULT hr;
TRACE("iface %p, desc %p.\n", iface, desc);
......@@ -142,15 +141,13 @@ static HRESULT STDMETHODCALLTYPE dxgi_adapter_GetDesc1(IDXGIAdapter1 *iface, DXG
if (!desc)
return E_INVALIDARG;
wined3d = IWineDXGIFactory_get_wined3d(adapter->parent);
adapter_id.driver_size = 0;
adapter_id.description = description;
adapter_id.description_size = sizeof(description);
adapter_id.device_name_size = 0;
EnterCriticalSection(&dxgi_cs);
hr = wined3d_get_adapter_identifier(wined3d, adapter->ordinal, 0, &adapter_id);
wined3d_decref(wined3d);
hr = wined3d_get_adapter_identifier(adapter->parent->wined3d, adapter->ordinal, 0, &adapter_id);
LeaveCriticalSection(&dxgi_cs);
if (FAILED(hr))
......@@ -224,7 +221,7 @@ struct dxgi_adapter *unsafe_impl_from_IDXGIAdapter1(IDXGIAdapter1 *iface)
return CONTAINING_RECORD(iface, struct dxgi_adapter, IDXGIAdapter1_iface);
}
HRESULT dxgi_adapter_init(struct dxgi_adapter *adapter, IWineDXGIFactory *parent, UINT ordinal)
HRESULT dxgi_adapter_init(struct dxgi_adapter *adapter, struct dxgi_factory *parent, UINT ordinal)
{
struct dxgi_output *output;
......
......@@ -82,7 +82,7 @@ static ULONG STDMETHODCALLTYPE dxgi_device_Release(IWineDXGIDevice *iface)
EnterCriticalSection(&dxgi_cs);
wined3d_device_decref(This->wined3d_device);
LeaveCriticalSection(&dxgi_cs);
IWineDXGIFactory_Release(This->factory);
IDXGIFactory1_Release(This->factory);
HeapFree(GetProcessHeap(), 0, This);
}
......@@ -148,7 +148,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_GetAdapter(IWineDXGIDevice *iface,
wined3d_device_get_creation_parameters(This->wined3d_device, &create_parameters);
LeaveCriticalSection(&dxgi_cs);
return IWineDXGIFactory_EnumAdapters(This->factory, create_parameters.adapter_idx, adapter);
return IDXGIFactory1_EnumAdapters(This->factory, create_parameters.adapter_idx, adapter);
}
static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IWineDXGIDevice *iface,
......@@ -349,11 +349,17 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
struct wined3d_device_parent *wined3d_device_parent;
IWineDXGIDeviceParent *dxgi_device_parent;
struct dxgi_adapter *dxgi_adapter;
struct wined3d *wined3d;
struct dxgi_factory *dxgi_factory;
void *layer_base;
HRESULT hr;
WINED3DCAPS caps;
if (!(dxgi_factory = unsafe_impl_from_IDXGIFactory1((IDXGIFactory1 *)factory)))
{
WARN("This is not the factory we're looking for.\n");
return E_FAIL;
}
if (!(dxgi_adapter = unsafe_impl_from_IDXGIAdapter1((IDXGIAdapter1 *)adapter)))
{
WARN("This is not the adapter we're looking for.\n");
......@@ -365,65 +371,48 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
layer_base = device + 1;
hr = layer->create(layer->id, &layer_base, 0,
device, &IID_IUnknown, (void **)&device->child_layer);
if (FAILED(hr))
if (FAILED(hr = layer->create(layer->id, &layer_base, 0,
device, &IID_IUnknown, (void **)&device->child_layer)))
{
WARN("Failed to create device, returning %#x.\n", hr);
goto fail;
}
hr = IDXGIFactory_QueryInterface(factory, &IID_IWineDXGIFactory, (void **)&device->factory);
if (FAILED(hr))
{
WARN("This is not the factory we're looking for, returning %#x.\n", hr);
goto fail;
return hr;
}
wined3d = IWineDXGIFactory_get_wined3d(device->factory);
hr = IWineDXGIDevice_QueryInterface(&device->IWineDXGIDevice_iface, &IID_IWineDXGIDeviceParent,
(void **)&dxgi_device_parent);
if (FAILED(hr))
if (FAILED(hr = IWineDXGIDevice_QueryInterface(&device->IWineDXGIDevice_iface,
&IID_IWineDXGIDeviceParent, (void **)&dxgi_device_parent)))
{
ERR("DXGI device should implement IWineD3DDeviceParent.\n");
goto fail;
IUnknown_Release(device->child_layer);
return hr;
}
wined3d_device_parent = IWineDXGIDeviceParent_get_wined3d_device_parent(dxgi_device_parent);
IWineDXGIDeviceParent_Release(dxgi_device_parent);
FIXME("Ignoring adapter type.\n");
hr = wined3d_get_device_caps(wined3d, dxgi_adapter->ordinal, WINED3D_DEVICE_TYPE_HAL, &caps);
hr = wined3d_get_device_caps(dxgi_factory->wined3d, dxgi_adapter->ordinal, WINED3D_DEVICE_TYPE_HAL, &caps);
if (FAILED(hr) || caps.VertexShaderVersion < 4 || caps.PixelShaderVersion < 4)
{
WARN("Direct3D 10 is not supported on this GPU with the current shader backend.\n");
if (SUCCEEDED(hr))
hr = E_FAIL;
goto fail;
IUnknown_Release(device->child_layer);
return hr;
}
EnterCriticalSection(&dxgi_cs);
hr = wined3d_device_create(wined3d, dxgi_adapter->ordinal, WINED3D_DEVICE_TYPE_HAL, NULL, 0, 4,
wined3d_device_parent, &device->wined3d_device);
IWineDXGIDeviceParent_Release(dxgi_device_parent);
wined3d_decref(wined3d);
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);
if (FAILED(hr))
{
WARN("Failed to create a wined3d device, returning %#x.\n", hr);
goto fail;
IUnknown_Release(device->child_layer);
return hr;
}
return S_OK;
device->factory = &dxgi_factory->IDXGIFactory1_iface;
IDXGIFactory1_AddRef(device->factory);
fail:
if (device->wined3d_device)
{
EnterCriticalSection(&dxgi_cs);
wined3d_device_decref(device->wined3d_device);
LeaveCriticalSection(&dxgi_cs);
}
if (device->factory) IWineDXGIFactory_Release(device->factory);
if (device->child_layer) IUnknown_Release(device->child_layer);
return hr;
return S_OK;
}
......@@ -80,7 +80,7 @@ enum wined3d_format_id wined3dformat_from_dxgi_format(DXGI_FORMAT format) DECLSP
/* IDXGIFactory */
struct dxgi_factory
{
IWineDXGIFactory IWineDXGIFactory_iface;
IDXGIFactory1 IDXGIFactory1_iface;
LONG refcount;
struct wined3d *wined3d;
UINT adapter_count;
......@@ -89,6 +89,7 @@ struct dxgi_factory
};
HRESULT dxgi_factory_create(REFIID riid, void **factory, BOOL extended) DECLSPEC_HIDDEN;
struct dxgi_factory *unsafe_impl_from_IDXGIFactory1(IDXGIFactory1 *iface) DECLSPEC_HIDDEN;
/* IDXGIDevice */
struct dxgi_device
......@@ -97,7 +98,7 @@ struct dxgi_device
IUnknown *child_layer;
LONG refcount;
struct wined3d_device *wined3d_device;
IWineDXGIFactory *factory;
IDXGIFactory1 *factory;
};
HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *layer,
......@@ -117,13 +118,13 @@ void dxgi_output_init(struct dxgi_output *output, struct dxgi_adapter *adapter)
struct dxgi_adapter
{
IDXGIAdapter1 IDXGIAdapter1_iface;
IWineDXGIFactory *parent;
struct dxgi_factory *parent;
LONG refcount;
UINT ordinal;
IDXGIOutput *output;
};
HRESULT dxgi_adapter_init(struct dxgi_adapter *adapter, IWineDXGIFactory *parent, UINT ordinal) DECLSPEC_HIDDEN;
HRESULT dxgi_adapter_init(struct dxgi_adapter *adapter, struct dxgi_factory *parent, UINT ordinal) DECLSPEC_HIDDEN;
struct dxgi_adapter *unsafe_impl_from_IDXGIAdapter1(IDXGIAdapter1 *iface) DECLSPEC_HIDDEN;
/* IDXGISwapChain */
......
......@@ -140,7 +140,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_output_GetDisplayModeList(IDXGIOutput *ifa
return S_OK;
}
wined3d = IWineDXGIFactory_get_wined3d(This->adapter->parent);
wined3d = This->adapter->parent->wined3d;
wined3d_format = wined3dformat_from_dxgi_format(format);
EnterCriticalSection(&dxgi_cs);
......@@ -149,7 +149,6 @@ static HRESULT STDMETHODCALLTYPE dxgi_output_GetDisplayModeList(IDXGIOutput *ifa
if (!desc)
{
wined3d_decref(wined3d);
LeaveCriticalSection(&dxgi_cs);
*mode_count = max_count;
return S_OK;
......@@ -157,7 +156,6 @@ static HRESULT STDMETHODCALLTYPE dxgi_output_GetDisplayModeList(IDXGIOutput *ifa
if (max_count > *mode_count)
{
wined3d_decref(wined3d);
LeaveCriticalSection(&dxgi_cs);
return DXGI_ERROR_MORE_DATA;
}
......@@ -174,7 +172,6 @@ static HRESULT STDMETHODCALLTYPE dxgi_output_GetDisplayModeList(IDXGIOutput *ifa
if (FAILED(hr))
{
WARN("EnumAdapterModes failed, hr %#x.\n", hr);
wined3d_decref(wined3d);
LeaveCriticalSection(&dxgi_cs);
return hr;
}
......@@ -187,7 +184,6 @@ static HRESULT STDMETHODCALLTYPE dxgi_output_GetDisplayModeList(IDXGIOutput *ifa
desc[i].ScanlineOrdering = mode.scanline_ordering;
desc[i].Scaling = DXGI_MODE_SCALING_UNSPECIFIED; /* FIXME */
}
wined3d_decref(wined3d);
LeaveCriticalSection(&dxgi_cs);
return S_OK;
......
......@@ -21,16 +21,6 @@ import "dxgi.idl";
[
object,
local,
uuid(a07ad9ab-fb01-4574-8bfb-0a70a7373f04)
]
interface IWineDXGIFactory : IDXGIFactory1
{
struct wined3d *get_wined3d();
}
[
object,
local,
uuid(3e1ff30b-c951-48c3-b010-0fb49f3dca71)
]
interface IWineDXGIDevice : IDXGIDevice
......
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