1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-05 01:24:14 +01:00

[d3d11] Get strong reference to swap chain in swap chain back buffers

This commit is contained in:
Philip Rebohle 2022-03-22 19:48:13 +01:00
parent 42edb62df8
commit 586948df1e
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 68 additions and 12 deletions

View File

@ -490,7 +490,7 @@ namespace dxvk {
|| m_desc.SwapEffect == DXGI_SWAP_EFFECT_FLIP_DISCARD)
dxgiUsage |= DXGI_USAGE_DISCARD_ON_PRESENT;
m_backBuffer = new D3D11Texture2D(m_parent, &desc, dxgiUsage, VK_NULL_HANDLE);
m_backBuffer = new D3D11Texture2D(m_parent, this, &desc, dxgiUsage);
m_swapImage = GetCommonTexture(m_backBuffer.ptr())->GetImage();
// Create an image view that allows the

View File

@ -1100,9 +1100,9 @@ namespace dxvk {
m_texture (this, pDevice, pDesc, D3D11_RESOURCE_DIMENSION_TEXTURE2D, 0, VK_NULL_HANDLE, hSharedHandle),
m_interop (this, &m_texture),
m_surface (this, &m_texture),
m_resource(this),
m_d3d10 (this) {
m_resource (this),
m_d3d10 (this),
m_swapChain (nullptr) {
}
@ -1115,8 +1115,25 @@ namespace dxvk {
m_texture (this, pDevice, pDesc, D3D11_RESOURCE_DIMENSION_TEXTURE2D, DxgiUsage, vkImage, nullptr),
m_interop (this, &m_texture),
m_surface (this, &m_texture),
m_resource(this),
m_d3d10 (this) {
m_resource (this),
m_d3d10 (this),
m_swapChain (nullptr) {
}
D3D11Texture2D::D3D11Texture2D(
D3D11Device* pDevice,
IUnknown* pSwapChain,
const D3D11_COMMON_TEXTURE_DESC* pDesc,
DXGI_USAGE DxgiUsage)
: D3D11DeviceChild<ID3D11Texture2D1>(pDevice),
m_texture (this, pDevice, pDesc, D3D11_RESOURCE_DIMENSION_TEXTURE2D, DxgiUsage, VK_NULL_HANDLE, nullptr),
m_interop (this, &m_texture),
m_surface (this, &m_texture),
m_resource (this),
m_d3d10 (this),
m_swapChain (pSwapChain) {
}
@ -1126,6 +1143,34 @@ namespace dxvk {
}
ULONG STDMETHODCALLTYPE D3D11Texture2D::AddRef() {
uint32_t refCount = m_refCount++;
if (unlikely(!refCount)) {
if (m_swapChain)
m_swapChain->AddRef();
AddRefPrivate();
}
return refCount + 1;
}
ULONG STDMETHODCALLTYPE D3D11Texture2D::Release() {
uint32_t refCount = --m_refCount;
if (unlikely(!refCount)) {
if (m_swapChain)
m_swapChain->Release();
ReleasePrivate();
}
return refCount;
}
HRESULT STDMETHODCALLTYPE D3D11Texture2D::QueryInterface(REFIID riid, void** ppvObject) {
if (ppvObject == nullptr)
return E_POINTER;

View File

@ -613,8 +613,18 @@ namespace dxvk {
DXGI_USAGE DxgiUsage,
VkImage vkImage);
D3D11Texture2D(
D3D11Device* pDevice,
IUnknown* pSwapChain,
const D3D11_COMMON_TEXTURE_DESC* pDesc,
DXGI_USAGE DxgiUsage);
~D3D11Texture2D();
ULONG STDMETHODCALLTYPE AddRef();
ULONG STDMETHODCALLTYPE Release();
HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
void** ppvObject) final;
@ -647,6 +657,7 @@ namespace dxvk {
D3D11DXGISurface m_surface;
D3D11DXGIResource m_resource;
D3D10Texture2D m_d3d10;
IUnknown* m_swapChain;
};