From 354898decf45d32a09d9b4a15319413a5d199f2a Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sun, 1 Jul 2018 17:08:59 -0700 Subject: Reworked binding default frame buffer to keep references to current RTV and DSV instead of nulls. --- Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.h | 9 ++++++++- Graphics/GraphicsEngineD3D12/interface/SwapChainD3D12.h | 12 ------------ Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp | 8 ++++---- Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp | 7 ------- 4 files changed, 12 insertions(+), 24 deletions(-) (limited to 'Graphics/GraphicsEngineD3D12') diff --git a/Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.h index c186ff28..9cca636e 100644 --- a/Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/SwapChainD3D12Impl.h @@ -54,7 +54,14 @@ public: virtual void Resize( Uint32 NewWidth, Uint32 NewHeight )override final; virtual IDXGISwapChain* GetDXGISwapChain()override final{ return m_pSwapChain; } - virtual ITextureViewD3D12* GetCurrentBackBufferRTV()override final; + + virtual ITextureViewD3D12* GetCurrentBackBufferRTV()override final + { + auto CurrentBackBufferIndex = m_pSwapChain->GetCurrentBackBufferIndex(); + VERIFY_EXPR(CurrentBackBufferIndex >= 0 && CurrentBackBufferIndex < m_SwapChainDesc.BufferCount); + return m_pBackBufferRTV[CurrentBackBufferIndex]; + } + virtual ITextureViewD3D12* GetDepthBufferDSV()override final{return m_pDepthBufferDSV;} private: diff --git a/Graphics/GraphicsEngineD3D12/interface/SwapChainD3D12.h b/Graphics/GraphicsEngineD3D12/interface/SwapChainD3D12.h index b6a64831..91c221fb 100644 --- a/Graphics/GraphicsEngineD3D12/interface/SwapChainD3D12.h +++ b/Graphics/GraphicsEngineD3D12/interface/SwapChainD3D12.h @@ -48,18 +48,6 @@ public: /// The method does *NOT* call AddRef() on the returned interface, /// so Release() must not be called. virtual IDXGISwapChain* GetDXGISwapChain() = 0; - - /// Returns a pointer to the render target view of the current back buffer in the swap chain - - /// The method does *NOT* call AddRef() on the returned interface, - /// so Release() must not be called. - virtual ITextureViewD3D12* GetCurrentBackBufferRTV() = 0; - - /// Returns a pointer to the depth-stencil view of the depth buffer - - /// The method does *NOT* call AddRef() on the returned interface, - /// so Release() must not be called. - virtual ITextureViewD3D12* GetDepthBufferDSV() = 0; }; } diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp index a5385da7..d11dd975 100644 --- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp @@ -453,7 +453,7 @@ namespace Diligent { if (m_pSwapChain) { - pDSVD3D12 = m_pSwapChain.RawPtr()->GetDepthBufferDSV(); + pDSVD3D12 = ValidatedCast(m_pSwapChain.RawPtr()->GetDepthBufferDSV()); } else { @@ -485,7 +485,7 @@ namespace Diligent { if (m_pSwapChain) { - pd3d12RTV = m_pSwapChain.RawPtr()->GetCurrentBackBufferRTV(); + pd3d12RTV = ValidatedCast(m_pSwapChain.RawPtr()->GetCurrentBackBufferRTV()); } else { @@ -678,8 +678,8 @@ namespace Diligent { NumRenderTargets = 1; auto *pSwapChainD3D12 = m_pSwapChain.RawPtr(); - ppRTVs[0] = pSwapChainD3D12->GetCurrentBackBufferRTV(); - pDSV = pSwapChainD3D12->GetDepthBufferDSV(); + ppRTVs[0] = ValidatedCast(pSwapChainD3D12->GetCurrentBackBufferRTV()); + pDSV = ValidatedCast(pSwapChainD3D12->GetDepthBufferDSV()); } else { diff --git a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp index 3df583d7..f9b782f0 100644 --- a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp @@ -210,11 +210,4 @@ void SwapChainD3D12Impl::Resize( Uint32 NewWidth, Uint32 NewHeight ) } } -ITextureViewD3D12 *SwapChainD3D12Impl::GetCurrentBackBufferRTV() -{ - auto CurrentBackBufferIndex = m_pSwapChain->GetCurrentBackBufferIndex(); - VERIFY_EXPR(CurrentBackBufferIndex >= 0 && CurrentBackBufferIndex < m_SwapChainDesc.BufferCount); - return m_pBackBufferRTV[CurrentBackBufferIndex]; -} - } -- cgit v1.2.3