From: Zebediah Figura zfigura@codeweavers.com
--- dlls/dxgi/dxgi_private.h | 1 + dlls/dxgi/swapchain.c | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/dlls/dxgi/dxgi_private.h b/dlls/dxgi/dxgi_private.h index fa704d28b0f..e3ea0e52036 100644 --- a/dlls/dxgi/dxgi_private.h +++ b/dlls/dxgi/dxgi_private.h @@ -180,6 +180,7 @@ struct d3d11_swapchain struct wined3d_swapchain_state_parent state_parent; IWineDXGIDevice *device; IWineDXGIFactory *factory; + bool implicit;
IDXGIOutput *target; LONG present_count; diff --git a/dlls/dxgi/swapchain.c b/dlls/dxgi/swapchain.c index 0ba9db96108..9aa76f9e97a 100644 --- a/dlls/dxgi/swapchain.c +++ b/dlls/dxgi/swapchain.c @@ -231,15 +231,17 @@ static ULONG STDMETHODCALLTYPE d3d11_swapchain_Release(IDXGISwapChain1 *iface) if (!refcount) { IWineDXGIDevice *device = swapchain->device; + bool implicit = swapchain->implicit; + if (swapchain->target) { WARN("Releasing fullscreen swapchain.\n"); IDXGIOutput_Release(swapchain->target); } - if (swapchain->factory) + if (!implicit) IWineDXGIFactory_Release(swapchain->factory); wined3d_swapchain_decref(swapchain->wined3d_swapchain); - if (device) + if (!implicit) IWineDXGIDevice_Release(device); }
@@ -302,7 +304,7 @@ static HRESULT STDMETHODCALLTYPE d3d11_swapchain_GetDevice(IDXGISwapChain1 *ifac
TRACE("iface %p, riid %s, device %p.\n", iface, debugstr_guid(riid), device);
- if (!swapchain->device) + if (swapchain->implicit) { ERR("Implicit swapchain does not store reference to device.\n"); *device = NULL; @@ -889,6 +891,8 @@ HRESULT d3d11_swapchain_init(struct d3d11_swapchain *swapchain, struct dxgi_devi BOOL fullscreen; HRESULT hr;
+ swapchain->device = &device->IWineDXGIDevice_iface; + /* A reference to the implicit swapchain is held by the wined3d device. In * order to avoid circular references we do not keep a reference to the * device in the implicit swapchain. */ @@ -903,11 +907,10 @@ HRESULT d3d11_swapchain_init(struct d3d11_swapchain *swapchain, struct dxgi_devi WARN("Failed to get adapter parent, hr %#lx.\n", hr); return hr; } - IWineDXGIDevice_AddRef(swapchain->device = &device->IWineDXGIDevice_iface); + IWineDXGIDevice_AddRef(swapchain->device); } else { - swapchain->device = NULL; swapchain->factory = NULL; }
@@ -969,10 +972,11 @@ HRESULT d3d11_swapchain_init(struct d3d11_swapchain *swapchain, struct dxgi_devi cleanup: wined3d_private_store_cleanup(&swapchain->private_store); wined3d_mutex_unlock(); - if (swapchain->factory) + if (!swapchain->implicit) + { IWineDXGIFactory_Release(swapchain->factory); - if (swapchain->device) IWineDXGIDevice_Release(swapchain->device); + } return hr; }