Commit 0dc7de15 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

dxgi: Do not create a d3d11 swapchain object for the implicit swapchain.

This swapchain is never actually exposed, and effectively only exists due to implementation constraints. When it was introduced, it was necessary or simplest to create a dxgi swapchain object, but currently that's no longer necessary, and avoiding that allows some code to be simplified.
parent 467201a8
...@@ -490,7 +490,6 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l ...@@ -490,7 +490,6 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
struct wined3d_device_parent *wined3d_device_parent; struct wined3d_device_parent *wined3d_device_parent;
struct wined3d_swapchain_desc swapchain_desc; struct wined3d_swapchain_desc swapchain_desc;
IWineDXGIDeviceParent *dxgi_device_parent; IWineDXGIDeviceParent *dxgi_device_parent;
struct d3d11_swapchain *swapchain;
struct dxgi_adapter *dxgi_adapter; struct dxgi_adapter *dxgi_adapter;
struct dxgi_factory *dxgi_factory; struct dxgi_factory *dxgi_factory;
struct dxgi_output *dxgi_output; struct dxgi_output *dxgi_output;
...@@ -572,9 +571,10 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l ...@@ -572,9 +571,10 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
swapchain_desc.output = dxgi_output->wined3d_output; swapchain_desc.output = dxgi_output->wined3d_output;
IDXGIOutput_Release(output); IDXGIOutput_Release(output);
if (!(swapchain = heap_alloc_zero(sizeof(*swapchain)))) if (FAILED(hr = wined3d_swapchain_create(device->wined3d_device, &swapchain_desc,
NULL, NULL, &dxgi_null_wined3d_parent_ops, &device->implicit_swapchain)))
{ {
ERR("Failed to allocate swapchain memory.\n"); ERR("Failed to create implicit swapchain, hr %#lx.\n", hr);
wined3d_device_decref(device->wined3d_device); wined3d_device_decref(device->wined3d_device);
IUnknown_Release(device->child_layer); IUnknown_Release(device->child_layer);
wined3d_private_store_cleanup(&device->private_store); wined3d_private_store_cleanup(&device->private_store);
...@@ -582,20 +582,6 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l ...@@ -582,20 +582,6 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
if (FAILED(hr = d3d11_swapchain_init(swapchain, device, &swapchain_desc)))
{
WARN("Failed to initialize swapchain, hr %#lx.\n", hr);
heap_free(swapchain);
wined3d_device_decref(device->wined3d_device);
IUnknown_Release(device->child_layer);
wined3d_private_store_cleanup(&device->private_store);
wined3d_mutex_unlock();
return hr;
}
device->implicit_swapchain = swapchain->wined3d_swapchain;
TRACE("Created swapchain %p.\n", swapchain);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
device->adapter = &dxgi_adapter->IWineDXGIAdapter_iface; device->adapter = &dxgi_adapter->IWineDXGIAdapter_iface;
......
...@@ -236,11 +236,9 @@ static ULONG STDMETHODCALLTYPE d3d11_swapchain_Release(IDXGISwapChain1 *iface) ...@@ -236,11 +236,9 @@ static ULONG STDMETHODCALLTYPE d3d11_swapchain_Release(IDXGISwapChain1 *iface)
WARN("Releasing fullscreen swapchain.\n"); WARN("Releasing fullscreen swapchain.\n");
IDXGIOutput_Release(swapchain->target); IDXGIOutput_Release(swapchain->target);
} }
if (swapchain->factory) IWineDXGIFactory_Release(swapchain->factory);
IWineDXGIFactory_Release(swapchain->factory);
wined3d_swapchain_decref(swapchain->wined3d_swapchain); wined3d_swapchain_decref(swapchain->wined3d_swapchain);
if (device) IWineDXGIDevice_Release(device);
IWineDXGIDevice_Release(device);
} }
return refcount; return refcount;
...@@ -284,13 +282,6 @@ static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetParent(IDXGISwapChain1 *ifac ...@@ -284,13 +282,6 @@ static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetParent(IDXGISwapChain1 *ifac
TRACE("iface %p, riid %s, parent %p.\n", iface, debugstr_guid(riid), parent); TRACE("iface %p, riid %s, parent %p.\n", iface, debugstr_guid(riid), parent);
if (!swapchain->factory)
{
ERR("Implicit swapchain does not store reference to parent.\n");
*parent = NULL;
return E_NOINTERFACE;
}
return IWineDXGIFactory_QueryInterface(swapchain->factory, riid, parent); return IWineDXGIFactory_QueryInterface(swapchain->factory, riid, parent);
} }
...@@ -302,13 +293,6 @@ static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetDevice(IDXGISwapChain1 *ifac ...@@ -302,13 +293,6 @@ static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetDevice(IDXGISwapChain1 *ifac
TRACE("iface %p, riid %s, device %p.\n", iface, debugstr_guid(riid), device); TRACE("iface %p, riid %s, device %p.\n", iface, debugstr_guid(riid), device);
if (!swapchain->device)
{
ERR("Implicit swapchain does not store reference to device.\n");
*device = NULL;
return E_NOINTERFACE;
}
return IWineDXGIDevice_QueryInterface(swapchain->device, riid, device); return IWineDXGIDevice_QueryInterface(swapchain->device, riid, device);
} }
...@@ -587,12 +571,6 @@ static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetContainingOutput(IDXGISwapCh ...@@ -587,12 +571,6 @@ static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetContainingOutput(IDXGISwapCh
return S_OK; return S_OK;
} }
if (!swapchain->factory)
{
ERR("Implicit swapchain does not store a reference to factory.\n");
return E_NOINTERFACE;
}
window = d3d11_swapchain_get_hwnd(swapchain); window = d3d11_swapchain_get_hwnd(swapchain);
return dxgi_get_output_from_window(swapchain->factory, window, output); return dxgi_get_output_from_window(swapchain->factory, window, output);
} }
...@@ -889,27 +867,16 @@ HRESULT d3d11_swapchain_init(struct d3d11_swapchain *swapchain, struct dxgi_devi ...@@ -889,27 +867,16 @@ HRESULT d3d11_swapchain_init(struct d3d11_swapchain *swapchain, struct dxgi_devi
BOOL fullscreen; BOOL fullscreen;
HRESULT hr; HRESULT hr;
/* A reference to the implicit swapchain is held by the wined3d device. In if (desc->backbuffer_format == WINED3DFMT_UNKNOWN)
* order to avoid circular references we do not keep a reference to the return E_INVALIDARG;
* device in the implicit swapchain. */
if (!(desc->flags & WINED3D_SWAPCHAIN_IMPLICIT))
{
if (desc->backbuffer_format == WINED3DFMT_UNKNOWN)
return E_INVALIDARG;
if (FAILED(hr = IWineDXGIAdapter_GetParent(device->adapter, if (FAILED(hr = IWineDXGIAdapter_GetParent(device->adapter,
&IID_IWineDXGIFactory, (void **)&swapchain->factory))) &IID_IWineDXGIFactory, (void **)&swapchain->factory)))
{
WARN("Failed to get adapter parent, hr %#lx.\n", hr);
return hr;
}
IWineDXGIDevice_AddRef(swapchain->device = &device->IWineDXGIDevice_iface);
}
else
{ {
swapchain->device = NULL; WARN("Failed to get adapter parent, hr %#lx.\n", hr);
swapchain->factory = NULL; return hr;
} }
IWineDXGIDevice_AddRef(swapchain->device = &device->IWineDXGIDevice_iface);
swapchain->IDXGISwapChain1_iface.lpVtbl = &d3d11_swapchain_vtbl; swapchain->IDXGISwapChain1_iface.lpVtbl = &d3d11_swapchain_vtbl;
swapchain->state_parent.ops = &d3d11_swapchain_state_parent_ops; swapchain->state_parent.ops = &d3d11_swapchain_state_parent_ops;
...@@ -969,10 +936,8 @@ HRESULT d3d11_swapchain_init(struct d3d11_swapchain *swapchain, struct dxgi_devi ...@@ -969,10 +936,8 @@ HRESULT d3d11_swapchain_init(struct d3d11_swapchain *swapchain, struct dxgi_devi
cleanup: cleanup:
wined3d_private_store_cleanup(&swapchain->private_store); wined3d_private_store_cleanup(&swapchain->private_store);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
if (swapchain->factory) IWineDXGIFactory_Release(swapchain->factory);
IWineDXGIFactory_Release(swapchain->factory); IWineDXGIDevice_Release(swapchain->device);
if (swapchain->device)
IWineDXGIDevice_Release(swapchain->device);
return hr; return hr;
} }
......
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