Module: wine Branch: master Commit: 30a7487b702b47c42293942b5334685a159003e7 URL: https://gitlab.winehq.org/wine/wine/-/commit/30a7487b702b47c42293942b5334685...
Author: Zebediah Figura zfigura@codeweavers.com Date: Fri Apr 14 19:20:15 2023 -0500
d3d11: Hold a reference to the wined3d swapchain from d3d11 swapchain textures.
---
dlls/d3d11/d3d11_private.h | 1 + dlls/d3d11/texture.c | 9 +++++++++ 2 files changed, 10 insertions(+)
diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h index 226d7b6b4e1..6177f24afe3 100644 --- a/dlls/d3d11/d3d11_private.h +++ b/dlls/d3d11/d3d11_private.h @@ -138,6 +138,7 @@ struct d3d_texture2d
IUnknown *dxgi_resource; struct wined3d_texture *wined3d_texture; + struct wined3d_swapchain *swapchain; D3D11_TEXTURE2D_DESC desc; ID3D11Device2 *device; }; diff --git a/dlls/d3d11/texture.c b/dlls/d3d11/texture.c index 5cd7df11f1f..1221fa035ba 100644 --- a/dlls/d3d11/texture.c +++ b/dlls/d3d11/texture.c @@ -558,6 +558,8 @@ static ULONG STDMETHODCALLTYPE d3d11_texture2d_AddRef(ID3D11Texture2D *iface) { ID3D11Device2_AddRef(texture->device); wined3d_texture_incref(texture->wined3d_texture); + if (texture->swapchain) + wined3d_swapchain_incref(texture->swapchain); }
return refcount; @@ -573,6 +575,10 @@ static ULONG STDMETHODCALLTYPE d3d11_texture2d_Release(ID3D11Texture2D *iface) if (!refcount) { ID3D11Device2 *device = texture->device; + if (texture->swapchain) + wined3d_swapchain_decref(texture->swapchain); + /* Releasing the texture may free the d3d11 object, so do not access it + * after releasing the texture. */ wined3d_texture_decref(texture->wined3d_texture); /* Release the device last, it may cause the wined3d device to be * destroyed. */ @@ -984,6 +990,9 @@ HRESULT d3d_texture2d_create(struct d3d_device *device, const D3D11_TEXTURE2D_DE texture, &d3d_texture2d_wined3d_parent_ops); wined3d_texture_incref(wined3d_texture); texture->wined3d_texture = wined3d_texture; + + if ((texture->swapchain = wined3d_texture_get_swapchain(wined3d_texture))) + wined3d_swapchain_incref(texture->swapchain); } else {