summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-08-13 05:00:42 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-08-13 05:00:42 +0000
commit97b32f52cc123544a1352527c2509c804fd3d190 (patch)
tree6fe5dc267b8a9087df2afe9bca871f9607438391 /Graphics/GraphicsEngine
parentD3D11 backend: enabled multiple swap chain support (diff)
downloadDiligentCore-97b32f52cc123544a1352527c2509c804fd3d190.tar.gz
DiligentCore-97b32f52cc123544a1352527c2509c804fd3d190.zip
D3D12 backend: enabled multiple swap chain support
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/include/SwapChainBase.h50
-rw-r--r--Graphics/GraphicsEngine/interface/SwapChain.h3
2 files changed, 50 insertions, 3 deletions
diff --git a/Graphics/GraphicsEngine/include/SwapChainBase.h b/Graphics/GraphicsEngine/include/SwapChainBase.h
index 8b9aa86f..5a60c9ed 100644
--- a/Graphics/GraphicsEngine/include/SwapChainBase.h
+++ b/Graphics/GraphicsEngine/include/SwapChainBase.h
@@ -26,6 +26,8 @@
/// \file
/// Implementation of the Diligent::SwapChainBase template class
+#include <array>
+
#include "RenderDevice.h"
#include "DeviceContext.h"
#include "SwapChain.h"
@@ -89,13 +91,55 @@ protected:
return false;
}
-
+
+ template<typename DeviceContextImplType>
+ bool UnbindRenderTargets(DeviceContextImplType* pImmediateCtx,
+ ITextureView* ppBackBufferRTVs[],
+ Uint32 NumBackBufferRTVs,
+ ITextureView* pDSV)
+ {
+ bool RebindRenderTargets = false;
+ bool UnbindRenderTargets = false;
+ if (m_SwapChainDesc.IsPrimary)
+ {
+ RebindRenderTargets = UnbindRenderTargets = pImmediateCtx->IsDefaultFBBound();
+ }
+ else
+ {
+ std::array<ITextureView*, MaxRenderTargets> pBoundRTVs = {};
+ RefCntAutoPtr<ITextureView> pBoundDSV;
+ Uint32 NumRenderTargets = 0;
+ pImmediateCtx->GetRenderTargets(NumRenderTargets, pBoundRTVs.data(), &pBoundDSV);
+ for (Uint32 i=0; i < NumRenderTargets; ++i)
+ {
+ for (Uint32 j=0; j < NumBackBufferRTVs; ++j)
+ {
+ if (pBoundRTVs[i] == ppBackBufferRTVs[j])
+ UnbindRenderTargets = true;
+ }
+ }
+ if (pBoundDSV == pDSV)
+ UnbindRenderTargets = true;
+
+ for (auto pRTV : pBoundRTVs)
+ {
+ if (pRTV != nullptr)
+ pRTV->Release();
+ }
+ }
+
+ if (UnbindRenderTargets)
+ pImmediateCtx->ResetRenderTargets();
+
+ return RebindRenderTargets;
+ }
+
/// Strong reference to the render device
- Diligent::RefCntAutoPtr<IRenderDevice> m_pRenderDevice;
+ RefCntAutoPtr<IRenderDevice> m_pRenderDevice;
/// Weak references to the immediate device context. The context holds
/// the strong reference to the swap chain.
- Diligent::RefCntWeakPtr<IDeviceContext> m_wpDeviceContext;
+ RefCntWeakPtr<IDeviceContext> m_wpDeviceContext;
/// Swap chain description
SwapChainDesc m_SwapChainDesc;
diff --git a/Graphics/GraphicsEngine/interface/SwapChain.h b/Graphics/GraphicsEngine/interface/SwapChain.h
index 5e780292..164608e1 100644
--- a/Graphics/GraphicsEngine/interface/SwapChain.h
+++ b/Graphics/GraphicsEngine/interface/SwapChain.h
@@ -54,6 +54,9 @@ public:
/// \param [in] NewWidth - New swap chain width, in pixels
/// \param [in] NewHeight - New swap chain height, in pixels
+ ///
+ /// \note When resizing non-primary swap chains, the engine unbinds the
+ /// swap chain buffers from the output.
virtual void Resize( Uint32 NewWidth, Uint32 NewHeight ) = 0;
/// Sets fullscreen mode (only supported on Win32 platform)