summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-08-01 23:56:01 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-08-02 19:21:44 +0000
commit3aa36ab27691129b99702a4102f73afdd9f4c52b (patch)
tree4bfe1b0a103c658d68462485e59d8189885de502 /Graphics/GraphicsEngine
parentImplemented ClearRenderTarget/ClearDepthStencil for inside render pass clears (diff)
downloadDiligentCore-3aa36ab27691129b99702a4102f73afdd9f4c52b.tar.gz
DiligentCore-3aa36ab27691129b99702a4102f73afdd9f4c52b.zip
Fixed frame buffer attachment clear operations; updated clear render target tests
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/include/DeviceContextBase.hpp33
-rw-r--r--Graphics/GraphicsEngine/interface/DeviceContext.h3
2 files changed, 36 insertions, 0 deletions
diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp
index 8679f202..d217a115 100644
--- a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp
+++ b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp
@@ -855,10 +855,43 @@ inline void DeviceContextBase<BaseInterface, ImplementationTraits>::BeginRenderP
{
VERIFY(m_pActiveRenderPass == nullptr, "Attempting to begin render pass while another render pass ('", m_pActiveRenderPass->GetDesc().Name, "') is active.");
VERIFY(Attribs.pRenderPass != nullptr, "Render pass must not be null");
+ VERIFY(Attribs.pFramebuffer != nullptr, "Framebuffer must not be null");
ResetRenderTargets();
+
m_pActiveRenderPass = ValidatedCast<RenderPassImplType>(Attribs.pRenderPass);
m_pBoundFramebuffer = ValidatedCast<FramebufferImplType>(Attribs.pFramebuffer);
m_SubpassIndex = 0;
+
+ const auto& FBDesc = m_pBoundFramebuffer->GetDesc();
+ m_FramebufferWidth = FBDesc.Width;
+ m_FramebufferHeight = FBDesc.Height;
+ m_FramebufferSlices = FBDesc.NumArraySlices;
+
+ if (Attribs.StateTransitionMode != RESOURCE_STATE_TRANSITION_MODE_NONE)
+ {
+ const auto& RPDesc = m_pActiveRenderPass->GetDesc();
+ VERIFY(RPDesc.AttachmentCount <= FBDesc.AttachmentCount,
+ "The number of attachments (", FBDesc.AttachmentCount,
+ ") in currently bound framebuffer is smaller than the number of attachments in the render pass (", RPDesc.AttachmentCount, ")");
+ for (Uint32 i = 0; i < FBDesc.AttachmentCount; ++i)
+ {
+ auto* pView = FBDesc.ppAttachments[i];
+ if (pView == nullptr)
+ return;
+
+ auto* pTex = ValidatedCast<TextureImplType>(pView->GetTexture());
+ auto RequiredState = RPDesc.pAttachments[i].InitialState;
+ if (Attribs.StateTransitionMode == RESOURCE_STATE_TRANSITION_MODE_TRANSITION)
+ {
+ StateTransitionDesc Barrier{pTex, RESOURCE_STATE_UNKNOWN, RequiredState, true};
+ TransitionResourceStates(1, &Barrier);
+ }
+ else if (Attribs.StateTransitionMode == RESOURCE_STATE_TRANSITION_MODE_VERIFY)
+ {
+ DvpVerifyTextureState(*pTex, RequiredState, "BeginRenderPass");
+ }
+ }
+ }
}
template <typename BaseInterface, typename ImplementationTraits>
diff --git a/Graphics/GraphicsEngine/interface/DeviceContext.h b/Graphics/GraphicsEngine/interface/DeviceContext.h
index 5eca22a9..5b52cec0 100644
--- a/Graphics/GraphicsEngine/interface/DeviceContext.h
+++ b/Graphics/GraphicsEngine/interface/DeviceContext.h
@@ -632,6 +632,9 @@ struct BeginRenderPassAttribs
/// The array is indexed by attachment number. Only elements corresponding to cleared attachments are used.
/// Other elements of pClearValues are ignored.
OptimizedClearValue* pClearValues DEFAULT_INITIALIZER(nullptr);
+
+ /// Framebuffer attachments state transition mode.
+ RESOURCE_STATE_TRANSITION_MODE StateTransitionMode DEFAULT_INITIALIZER(RESOURCE_STATE_TRANSITION_MODE_NONE);
};
typedef struct BeginRenderPassAttribs BeginRenderPassAttribs;