summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngine
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-08-01 21:22:47 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-08-02 19:21:43 +0000
commit89e1718309473686f1bae9ef46c501fc1d6e1520 (patch)
treea51034efdd9c7040c92a9bb27868c407c318e694 /Graphics/GraphicsEngine
parentImplemented BeginRenderPass/NextSubpass/EndRenderPass in Vulkan backend (diff)
downloadDiligentCore-89e1718309473686f1bae9ef46c501fc1d6e1520.tar.gz
DiligentCore-89e1718309473686f1bae9ef46c501fc1d6e1520.zip
Implemented ClearRenderTarget/ClearDepthStencil for inside render pass clears
Diffstat (limited to 'Graphics/GraphicsEngine')
-rw-r--r--Graphics/GraphicsEngine/include/DeviceContextBase.hpp94
1 files changed, 68 insertions, 26 deletions
diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp
index 74fc5966..8679f202 100644
--- a/Graphics/GraphicsEngine/include/DeviceContextBase.hpp
+++ b/Graphics/GraphicsEngine/include/DeviceContextBase.hpp
@@ -888,8 +888,6 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::ClearDepthSt
}
#ifdef DILIGENT_DEVELOPMENT
- VERIFY(m_pActiveRenderPass == nullptr, "ClearDepthStencil command must be used outside of render pass. Inside the render pass, use ClearDepthStencilAttachment command.");
-
{
const auto& ViewDesc = pView->GetDesc();
if (ViewDesc.ViewType != TEXTURE_VIEW_DEPTH_STENCIL)
@@ -899,21 +897,44 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::ClearDepthSt
return false;
}
- if (pView != m_pBoundDepthStencil)
+ if (m_pActiveRenderPass != nullptr)
{
- if (m_pDevice->GetDeviceCaps().IsGLDevice())
+ bool AttachmentFound = false;
+ if (m_pBoundFramebuffer != nullptr)
+ {
+ const auto& FBDesc = m_pBoundFramebuffer->GetDesc();
+ for (Uint32 i = 0; i < FBDesc.AttachmentCount && !AttachmentFound; ++i)
+ {
+ AttachmentFound = FBDesc.ppAttachments[i] == pView;
+ }
+ }
+
+ if (!AttachmentFound)
{
LOG_ERROR_MESSAGE("Depth-stencil view '", ViewDesc.Name,
- "' is not bound to the device context. ClearDepthStencil command requires "
- "depth-stencil view be bound to the device contex in OpenGL backend");
+ "' is not bound as framebuffer attachment. ClearDepthStencil command inside a render pass "
+ "requires depth-stencil view be bound as framebuffer attachment.");
return false;
}
- else
+ }
+ else
+ {
+ if (pView != m_pBoundDepthStencil)
{
- LOG_WARNING_MESSAGE("Depth-stencil view '", ViewDesc.Name,
- "' is not bound to the device context. "
- "ClearDepthStencil command is more efficient when depth-stencil "
- "view is bound to the context. In OpenGL backend this is a requirement.");
+ if (m_pDevice->GetDeviceCaps().IsGLDevice())
+ {
+ LOG_ERROR_MESSAGE("Depth-stencil view '", ViewDesc.Name,
+ "' is not bound to the device context. ClearDepthStencil command requires "
+ "depth-stencil view be bound to the device contex in OpenGL backend");
+ return false;
+ }
+ else
+ {
+ LOG_WARNING_MESSAGE("Depth-stencil view '", ViewDesc.Name,
+ "' is not bound to the device context. "
+ "ClearDepthStencil command is more efficient when depth-stencil "
+ "view is bound to the context. In OpenGL backend this is a requirement.");
+ }
}
}
}
@@ -932,8 +953,6 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::ClearRenderT
}
#ifdef DILIGENT_DEVELOPMENT
- VERIFY(m_pActiveRenderPass == nullptr, "ClearRenderTarget command must be used outside of render pass. Inside the render pass, use ClearRenderTargetAttachment command.");
-
{
const auto& ViewDesc = pView->GetDesc();
if (ViewDesc.ViewType != TEXTURE_VIEW_RENDER_TARGET)
@@ -943,25 +962,48 @@ inline bool DeviceContextBase<BaseInterface, ImplementationTraits>::ClearRenderT
return false;
}
- bool RTFound = false;
- for (Uint32 i = 0; i < m_NumBoundRenderTargets && !RTFound; ++i)
- {
- RTFound = m_pBoundRenderTargets[i] == pView;
- }
- if (!RTFound)
+ if (m_pActiveRenderPass != nullptr)
{
- if (m_pDevice->GetDeviceCaps().IsGLDevice())
+ bool AttachmentFound = false;
+ if (m_pBoundFramebuffer != nullptr)
+ {
+ const auto& FBDesc = m_pBoundFramebuffer->GetDesc();
+ for (Uint32 i = 0; i < FBDesc.AttachmentCount && !AttachmentFound; ++i)
+ {
+ AttachmentFound = FBDesc.ppAttachments[i] == pView;
+ }
+ }
+
+ if (!AttachmentFound)
{
LOG_ERROR_MESSAGE("Render target view '", ViewDesc.Name,
- "' is not bound to the device context. ClearRenderTarget command "
- "requires render target view be bound to the device contex in OpenGL backend");
+ "' is not bound as framebuffer attachment. ClearRenderTarget command inside a render pass "
+ "requires render target view be bound as framebuffer attachment.");
return false;
}
- else
+ }
+ else
+ {
+ bool RTFound = false;
+ for (Uint32 i = 0; i < m_NumBoundRenderTargets && !RTFound; ++i)
+ {
+ RTFound = m_pBoundRenderTargets[i] == pView;
+ }
+ if (!RTFound)
{
- LOG_WARNING_MESSAGE("Render target view '", ViewDesc.Name,
- "' is not bound to the device context. ClearRenderTarget command is more efficient "
- "if render target view is bound to the device context. In OpenGL backend this is a requirement.");
+ if (m_pDevice->GetDeviceCaps().IsGLDevice())
+ {
+ LOG_ERROR_MESSAGE("Render target view '", ViewDesc.Name,
+ "' is not bound to the device context. ClearRenderTarget command "
+ "requires render target view be bound to the device contex in OpenGL backend");
+ return false;
+ }
+ else
+ {
+ LOG_WARNING_MESSAGE("Render target view '", ViewDesc.Name,
+ "' is not bound to the device context. ClearRenderTarget command is more efficient "
+ "if render target view is bound to the device context. In OpenGL backend this is a requirement.");
+ }
}
}
}