mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-04 16:24:29 +01:00
[d3d11] Get strong reference to swap chain in swap chain back buffers
This commit is contained in:
parent
42edb62df8
commit
586948df1e
@ -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
|
||||
|
@ -1097,12 +1097,12 @@ namespace dxvk {
|
||||
const D3D11_COMMON_TEXTURE_DESC* pDesc,
|
||||
HANDLE hSharedHandle)
|
||||
: D3D11DeviceChild<ID3D11Texture2D1>(pDevice),
|
||||
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_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_swapChain (nullptr) {
|
||||
}
|
||||
|
||||
|
||||
@ -1112,11 +1112,28 @@ namespace dxvk {
|
||||
DXGI_USAGE DxgiUsage,
|
||||
VkImage vkImage)
|
||||
: D3D11DeviceChild<ID3D11Texture2D1>(pDevice),
|
||||
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_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_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;
|
||||
|
@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user