From 9e62ec0d4b9c7ea9d6fc3d19b9d29481dffb697c Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sat, 9 Nov 2019 22:17:46 -0800 Subject: Added 'ResolveTextureSubresource' device context command (API Version 240041) (not yet implemented in OpenGL backend) --- .../include/DeviceContextD3D11Impl.h | 5 +++++ .../src/DeviceContextD3D11Impl.cpp | 21 +++++++++++++++++++++ .../GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h index 3ecb3388..81d40cb4 100755 --- a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h +++ b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.h @@ -184,6 +184,11 @@ public: /// Implementation of IDeviceContext::TransitionResourceStates() in Direct3D11 backend. virtual void TransitionResourceStates(Uint32 BarrierCount, StateTransitionDesc* pResourceBarriers)override final; + /// Implementation of IDeviceContext::ResolveTextureSubresource() in Direct3D11 backend. + virtual void ResolveTextureSubresource(ITexture* pSrcTexture, + ITexture* pDstTexture, + const ResolveTextureSubresourceAttribs& ResolveAttribs)override final; + /// Implementation of IDeviceContext::FinishCommandList() in Direct3D11 backend. void FinishCommandList(class ICommandList** ppCommandList)override final; diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index 7a4c1762..93e7362c 100755 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -2051,6 +2051,27 @@ namespace Diligent } } + void DeviceContextD3D11Impl::ResolveTextureSubresource(ITexture* pSrcTexture, + ITexture* pDstTexture, + const ResolveTextureSubresourceAttribs& ResolveAttribs) + { + TDeviceContextBase::ResolveTextureSubresource(pSrcTexture, pDstTexture, ResolveAttribs); + + auto* pSrcTexD3D11 = ValidatedCast(pSrcTexture); + auto* pDstTexD3D11 = ValidatedCast(pDstTexture); + const auto& SrcTexDesc = pSrcTexD3D11->GetDesc(); + const auto& DstTexDesc = pDstTexD3D11->GetDesc(); + + auto Format = ResolveAttribs.Format; + if (Format == TEX_FORMAT_UNKNOWN) + Format = SrcTexDesc.Format; + + auto DXGIFmt = TexFormatToDXGI_Format(Format); + auto SrcSubresIndex = D3D11CalcSubresource(ResolveAttribs.SrcMipLevel, ResolveAttribs.SrcSlice, SrcTexDesc.MipLevels); + auto DstSubresIndex = D3D11CalcSubresource(ResolveAttribs.DstMipLevel, ResolveAttribs.DstSlice, DstTexDesc.MipLevels); + m_pd3d11DeviceContext->ResolveSubresource(pDstTexD3D11->GetD3D11Texture(), DstSubresIndex, pSrcTexD3D11->GetD3D11Texture(), SrcSubresIndex, DXGIFmt); + } + #ifdef VERIFY_CONTEXT_BINDINGS DEFINE_D3D11CTX_FUNC_POINTERS(GetCBMethods, GetConstantBuffers) DEFINE_D3D11CTX_FUNC_POINTERS(GetSRVMethods, GetShaderResources) diff --git a/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp index 4b6797e4..b11955f5 100644 --- a/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/SwapChainD3D11Impl.cpp @@ -91,7 +91,7 @@ void SwapChainD3D11Impl::CreateRTVandDSV() DepthBufferDesc.MipLevels = 1; DepthBufferDesc.ArraySize = 1; DepthBufferDesc.Format = m_SwapChainDesc.DepthBufferFormat; - DepthBufferDesc.SampleCount = m_SwapChainDesc.SamplesCount; + DepthBufferDesc.SampleCount = 1; DepthBufferDesc.Usage = USAGE_DEFAULT; DepthBufferDesc.BindFlags = BIND_DEPTH_STENCIL; DepthBufferDesc.CPUAccessFlags = CPU_ACCESS_NONE; -- cgit v1.2.3