Commit 70088c4e authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d10: Use the factory that created the adapter to create a swapchain.

parent 81e92fc8
...@@ -141,6 +141,7 @@ HRESULT WINAPI D3D10CreateDeviceAndSwapChain(IDXGIAdapter *adapter, D3D10_DRIVER ...@@ -141,6 +141,7 @@ HRESULT WINAPI D3D10CreateDeviceAndSwapChain(IDXGIAdapter *adapter, D3D10_DRIVER
HMODULE swrast, UINT flags, UINT sdk_version, DXGI_SWAP_CHAIN_DESC *swapchain_desc, HMODULE swrast, UINT flags, UINT sdk_version, DXGI_SWAP_CHAIN_DESC *swapchain_desc,
IDXGISwapChain **swapchain, ID3D10Device **device) IDXGISwapChain **swapchain, ID3D10Device **device)
{ {
IDXGIDevice *dxgi_device;
IDXGIFactory *factory; IDXGIFactory *factory;
HRESULT hr; HRESULT hr;
...@@ -153,22 +154,40 @@ HRESULT WINAPI D3D10CreateDeviceAndSwapChain(IDXGIAdapter *adapter, D3D10_DRIVER ...@@ -153,22 +154,40 @@ HRESULT WINAPI D3D10CreateDeviceAndSwapChain(IDXGIAdapter *adapter, D3D10_DRIVER
if (FAILED(hr)) if (FAILED(hr))
{ {
WARN("Failed to create a device, returning %#x\n", hr); WARN("Failed to create a device, returning %#x\n", hr);
*device = NULL;
return hr; return hr;
} }
TRACE("Created ID3D10Device %p\n", *device); TRACE("Created ID3D10Device %p\n", *device);
hr = CreateDXGIFactory(&IID_IDXGIFactory, (void **)&factory); hr = ID3D10Device_QueryInterface(*device, &IID_IDXGIDevice, (void **)&dxgi_device);
if (FAILED(hr)) if (FAILED(hr))
{ {
ERR("Failed to get a dxgi device from the d3d10 device, returning %#x\n", hr);
ID3D10Device_Release(*device); ID3D10Device_Release(*device);
*device = NULL; *device = NULL;
return hr;
}
WARN("Failed to create a DXGI factory, returning %#x\n", hr); hr = IDXGIDevice_GetAdapter(dxgi_device, &adapter);
IDXGIDevice_Release(dxgi_device);
if (FAILED(hr))
{
ERR("Failed to get the device adapter, returning %#x\n", hr);
ID3D10Device_Release(*device);
*device = NULL;
return hr; return hr;
} }
TRACE("Created IDXGIFactory %p\n", factory); hr = IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory, (void **)&factory);
IDXGIAdapter_Release(adapter);
if (FAILED(hr))
{
ERR("Failed to get the adapter factory, returning %#x\n", hr);
ID3D10Device_Release(*device);
*device = NULL;
return hr;
}
hr = IDXGIFactory_CreateSwapChain(factory, (IUnknown *)*device, swapchain_desc, swapchain); hr = IDXGIFactory_CreateSwapChain(factory, (IUnknown *)*device, swapchain_desc, swapchain);
IDXGIFactory_Release(factory); IDXGIFactory_Release(factory);
......
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