diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-11-10 06:17:46 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-11-10 06:17:46 +0000 |
| commit | 9e62ec0d4b9c7ea9d6fc3d19b9d29481dffb697c (patch) | |
| tree | f9f26c569259ec3b83c9b19dbe0c40f472243ce6 /Graphics/GraphicsEngineD3D12 | |
| parent | Allowed swap chains without the depth buffer (diff) | |
| download | DiligentCore-9e62ec0d4b9c7ea9d6fc3d19b9d29481dffb697c.tar.gz DiligentCore-9e62ec0d4b9c7ea9d6fc3d19b9d29481dffb697c.zip | |
Added 'ResolveTextureSubresource' device context command (API Version 240041) (not yet implemented in OpenGL backend)
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
4 files changed, 39 insertions, 2 deletions
diff --git a/Graphics/GraphicsEngineD3D12/include/CommandContext.h b/Graphics/GraphicsEngineD3D12/include/CommandContext.h index b58e8f34..a8c95d41 100644 --- a/Graphics/GraphicsEngineD3D12/include/CommandContext.h +++ b/Graphics/GraphicsEngineD3D12/include/CommandContext.h @@ -97,6 +97,12 @@ public: void TransitionResource(const StateTransitionDesc& Barrier); //void BeginResourceTransition(GpuResource& Resource, D3D12_RESOURCE_STATES NewState, bool FlushImmediate = false); + void ResolveSubresource(ID3D12Resource *pDstResource, UINT DstSubresource, ID3D12Resource *pSrcResource, UINT SrcSubresource, DXGI_FORMAT Format) + { + FlushResourceBarriers(); + m_pCommandList->ResolveSubresource(pDstResource, DstSubresource, pSrcResource, SrcSubresource, Format); + } + void FlushResourceBarriers() { if (!m_PendingResourceBarriers.empty()) diff --git a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h index fb672aee..077fcd7c 100644 --- a/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h +++ b/Graphics/GraphicsEngineD3D12/include/DeviceContextD3D12Impl.h @@ -182,6 +182,11 @@ public: /// Implementation of IDeviceContext::TransitionResourceStates() in Direct3D12 backend. virtual void TransitionResourceStates(Uint32 BarrierCount, StateTransitionDesc* pResourceBarriers)override final; + /// Implementation of IDeviceContext::ResolveTextureSubresource() in Direct3D12 backend. + virtual void ResolveTextureSubresource(ITexture* pSrcTexture, + ITexture* pDstTexture, + const ResolveTextureSubresourceAttribs& ResolveAttribs)override final; + /// Implementation of IDeviceContext::FinishCommandList() in Direct3D12 backend. virtual void FinishCommandList(class ICommandList** ppCommandList)override final; diff --git a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp index 5cc74244..32a07203 100644 --- a/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp @@ -1760,4 +1760,30 @@ namespace Diligent auto& CmdCtx = GetCmdContext(); return CmdCtx.GetCommandList(); } + + void DeviceContextD3D12Impl::ResolveTextureSubresource(ITexture* pSrcTexture, + ITexture* pDstTexture, + const ResolveTextureSubresourceAttribs& ResolveAttribs) + { + TDeviceContextBase::ResolveTextureSubresource(pSrcTexture, pDstTexture, ResolveAttribs); + + auto* pSrcTexD3D12 = ValidatedCast<TextureD3D12Impl>(pSrcTexture); + auto* pDstTexD3D12 = ValidatedCast<TextureD3D12Impl>(pDstTexture); + const auto& SrcTexDesc = pSrcTexD3D12->GetDesc(); + const auto& DstTexDesc = pDstTexD3D12->GetDesc(); + + auto& CmdCtx = GetCmdContext(); + TransitionOrVerifyTextureState(CmdCtx, *pSrcTexD3D12, ResolveAttribs.SrcTextureTransitionMode, RESOURCE_STATE_RESOLVE_SOURCE, "Resolving multi-sampled texture (DeviceContextD3D12Impl::ResolveTextureSubresource)"); + TransitionOrVerifyTextureState(CmdCtx, *pDstTexD3D12, ResolveAttribs.DstTextureTransitionMode, RESOURCE_STATE_RESOLVE_DEST, "Resolving multi-sampled texture (DeviceContextD3D12Impl::ResolveTextureSubresource)"); + + auto Format = ResolveAttribs.Format; + if (Format == TEX_FORMAT_UNKNOWN) + Format = SrcTexDesc.Format; + + auto DXGIFmt = TexFormatToDXGI_Format(Format); + auto SrcSubresIndex = D3D12CalcSubresource(ResolveAttribs.SrcMipLevel, ResolveAttribs.SrcSlice, 0, SrcTexDesc.MipLevels, SrcTexDesc.ArraySize); + auto DstSubresIndex = D3D12CalcSubresource(ResolveAttribs.DstMipLevel, ResolveAttribs.DstSlice, 0, DstTexDesc.MipLevels, DstTexDesc.ArraySize); + + CmdCtx.ResolveSubresource(pDstTexD3D12->GetD3D12Resource(), DstSubresIndex, pSrcTexD3D12->GetD3D12Resource(), SrcSubresIndex, DXGIFmt); + } } diff --git a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp index ab9d3be6..9517c93f 100644 --- a/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/SwapChainD3D12Impl.cpp @@ -65,7 +65,7 @@ SwapChainD3D12Impl::~SwapChainD3D12Impl() void SwapChainD3D12Impl::InitBuffersAndViews() { m_pBackBufferRTV.resize(m_SwapChainDesc.BufferCount); - for(Uint32 backbuff = 0; backbuff < m_SwapChainDesc.BufferCount; ++backbuff) + for (Uint32 backbuff = 0; backbuff < m_SwapChainDesc.BufferCount; ++backbuff) { CComPtr<ID3D12Resource> pBackBuffer; auto hr = m_pSwapChain->GetBuffer(backbuff, __uuidof(pBackBuffer), reinterpret_cast<void**>( static_cast<ID3D12Resource**>(&pBackBuffer) )); @@ -97,7 +97,7 @@ void SwapChainD3D12Impl::InitBuffersAndViews() DepthBufferDesc.Width = m_SwapChainDesc.Width; DepthBufferDesc.Height = m_SwapChainDesc.Height; DepthBufferDesc.Format = m_SwapChainDesc.DepthBufferFormat; - DepthBufferDesc.SampleCount = m_SwapChainDesc.SamplesCount; + DepthBufferDesc.SampleCount = 1; DepthBufferDesc.Usage = USAGE_DEFAULT; DepthBufferDesc.BindFlags = BIND_DEPTH_STENCIL; |
