summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D11
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-08-07 21:56:01 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-08-07 21:56:01 +0000
commitaef7f38b073ce6e7fdb00544419b7f3291508017 (patch)
treee71008e832b4c6fe59b0edf959f6e5879b7d3f0b /Graphics/GraphicsEngineD3D11
parentImplemented render pass resolve in D3D11 backend, added test (diff)
downloadDiligentCore-aef7f38b073ce6e7fdb00544419b7f3291508017.tar.gz
DiligentCore-aef7f38b073ce6e7fdb00544419b7f3291508017.zip
D3D11 backend: udpating resource states when calling NextSubpass
Diffstat (limited to 'Graphics/GraphicsEngineD3D11')
-rw-r--r--Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp2
-rwxr-xr-xGraphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp24
2 files changed, 25 insertions, 1 deletions
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<ID3D11DeviceChild> 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<TextureViewD3D11Impl>(FBDesc.ppAttachments[att]);
+ if (pTexView == nullptr)
+ continue;
+
+ auto* pTex = ValidatedCast<TextureBaseD3D11>(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;
}