From aef7f38b073ce6e7fdb00544419b7f3291508017 Mon Sep 17 00:00:00 2001 From: assiduous Date: Fri, 7 Aug 2020 14:56:01 -0700 Subject: D3D11 backend: udpating resource states when calling NextSubpass --- .../include/DeviceContextD3D11Impl.hpp | 2 ++ .../src/DeviceContextD3D11Impl.cpp | 24 +++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'Graphics/GraphicsEngineD3D11') diff --git a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp index 27671d52..4df12602 100644 --- a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp +++ b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp @@ -390,6 +390,8 @@ private: /// Strong references to committed D3D11 shaders CComPtr m_CommittedD3DShaders[NumShaderTypes]; + RESOURCE_STATE_TRANSITION_MODE m_RenderPassAttachmentsTransitionMode = RESOURCE_STATE_TRANSITION_MODE_NONE; + const Uint32 m_DebugFlags; FixedBlockMemoryAllocator m_CmdListAllocator; diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp index ec985a1b..a40aa77a 100755 --- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp +++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp @@ -1430,7 +1430,7 @@ void DeviceContextD3D11Impl::UnbindTextureFromInput(TextureBaseD3D11* pTexture, if (!pTexture) return; UnbindResourceView(m_CommittedD3D11SRVs, m_CommittedD3D11SRVResources, m_NumCommittedSRVs, pd3d11Resource, SetSRVMethods); - pTexture->ClearState(RESOURCE_STATE_SHADER_RESOURCE); + pTexture->ClearState(RESOURCE_STATE_SHADER_RESOURCE | RESOURCE_STATE_INPUT_ATTACHMENT); } void DeviceContextD3D11Impl::UnbindBufferFromInput(BufferD3D11Impl* pBuffer, ID3D11Resource* pd3d11Buffer) @@ -1677,6 +1677,8 @@ void DeviceContextD3D11Impl::BeginRenderPass(const BeginRenderPassAttribs& Attri TDeviceContextBase::BeginRenderPass(Attribs); // BeginRenderPass() transitions resources to required states + m_RenderPassAttachmentsTransitionMode = Attribs.StateTransitionMode; + CommitRenderTargets(); // Set the viewport to match the framebuffer size @@ -1759,6 +1761,25 @@ void DeviceContextD3D11Impl::NextSubpass() TDeviceContextBase::NextSubpass(); + if (m_RenderPassAttachmentsTransitionMode == RESOURCE_STATE_TRANSITION_MODE_TRANSITION) + { + for (Uint32 att = 0; att < RPDesc.AttachmentCount; ++att) + { + auto* pTexView = ValidatedCast(FBDesc.ppAttachments[att]); + if (pTexView == nullptr) + continue; + + auto* pTex = ValidatedCast(pTexView->GetTexture()); + if (pTex->IsInKnownState()) + { + auto CurrState = m_pActiveRenderPass->GetAttachmentState(m_SubpassIndex, att); + if ((CurrState & RESOURCE_STATE_INPUT_ATTACHMENT) != 0) + CurrState |= RESOURCE_STATE_SHADER_RESOURCE; + pTex->SetState(CurrState); + } + } + } + CommitRenderTargets(); } @@ -1766,6 +1787,7 @@ void DeviceContextD3D11Impl::EndRenderPass(bool UpdateResourceStates) { EndSubpass(); TDeviceContextBase::EndRenderPass(UpdateResourceStates); + m_RenderPassAttachmentsTransitionMode = RESOURCE_STATE_TRANSITION_MODE_NONE; } -- cgit v1.2.3