summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-12-01 18:42:38 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-12-01 18:42:38 +0000
commit97a72224ba1788ade4890b3f737f150b240610e1 (patch)
treed0dc4e3e2290ccd7368d97e49ba597b8dac19b80 /Graphics/GraphicsEngineVulkan
parentUpdated SetRenderTargets() in Vk backend to only transitin states. CommitRend... (diff)
downloadDiligentCore-97a72224ba1788ade4890b3f737f150b240610e1.tar.gz
DiligentCore-97a72224ba1788ade4890b3f737f150b240610e1.zip
Added explicit state transition mode to ClearRenderTarget() command
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h2
-rw-r--r--Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp24
-rw-r--r--Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp2
3 files changed, 21 insertions, 7 deletions
diff --git a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h
index 5f989858..28a6f10e 100644
--- a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h
+++ b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h
@@ -98,7 +98,7 @@ public:
virtual void ClearDepthStencil( ITextureView* pView, CLEAR_DEPTH_STENCIL_FLAGS ClearFlags, float fDepth, Uint8 Stencil)override final;
- virtual void ClearRenderTarget( ITextureView* pView, const float* RGBA )override final;
+ virtual void ClearRenderTarget( ITextureView* pView, const float* RGBA, CLEAR_RENDER_TARGET_STATE_TRANSITION_MODE StateTransitionMode )override final;
virtual void Flush()override final;
diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
index e9dd563d..db958c57 100644
--- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp
@@ -755,7 +755,7 @@ namespace Diligent
return ClearValue;
}
- void DeviceContextVkImpl::ClearRenderTarget( ITextureView *pView, const float *RGBA )
+ void DeviceContextVkImpl::ClearRenderTarget( ITextureView *pView, const float *RGBA, CLEAR_RENDER_TARGET_STATE_TRANSITION_MODE StateTransitionMode )
{
ITextureViewVk* pVkRTV = nullptr;
if ( pView != nullptr )
@@ -839,14 +839,28 @@ namespace Diligent
auto* pTextureVk = ValidatedCast<TextureVkImpl>(pTexture);
// Image layout must be VK_IMAGE_LAYOUT_GENERAL or VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL (17.1)
- if (pTextureVk->IsInKnownState())
+ if (StateTransitionMode == CLEAR_RENDER_TARGET_TRANSITION_STATE)
{
- if (!pTextureVk->CheckState(RESOURCE_STATE_COPY_DEST))
+ if (pTextureVk->IsInKnownState())
{
- TransitionTextureState(*pTextureVk, RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_COPY_DEST, true);
+ if (!pTextureVk->CheckState(RESOURCE_STATE_COPY_DEST))
+ {
+ TransitionTextureState(*pTextureVk, RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_COPY_DEST, true);
+ }
+ VERIFY_EXPR(pTextureVk->GetLayout() == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
}
- VERIFY_EXPR(pTextureVk->GetLayout() == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
}
+#ifdef DEVELOPMENT
+ else if (StateTransitionMode == CLEAR_RENDER_TARGET_VERIFY_STATE)
+ {
+ if (pTextureVk->IsInKnownState() && !pTextureVk->CheckState(RESOURCE_STATE_COPY_DEST))
+ {
+ LOG_ERROR_MESSAGE("Render target '", pTextureVk->GetDesc().Name, "' being cleared outside of render pass not transitioned to RESOURCE_STATE_COPY_DEST state. "
+ "Actual texture state: ", GetResourceStateString(pTexture->GetState()), ". "
+ "Use CLEAR_RENDER_TARGET_TRANSITION_STATE mode or explicitly transition the resource using IDeviceContext::TransitionResourceStates() method.");
+ }
+ }
+#endif
auto ClearValue = ClearValueToVkClearValue(RGBA, ViewDesc.Format);
VkImageSubresourceRange Subresource;
Subresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
diff --git a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp
index 5cdb4f4c..dafa664e 100644
--- a/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/SwapChainVkImpl.cpp
@@ -419,7 +419,7 @@ void SwapChainVkImpl::AcquireNextImage(DeviceContextVkImpl* pDeviceCtxVk)
{
// Vulkan validation layers do not like uninitialized memory.
// Clear back buffer first time we acquire it. This will use vkCmdClearColorImage()
- pDeviceCtxVk->ClearRenderTarget(GetCurrentBackBufferRTV(), nullptr);
+ pDeviceCtxVk->ClearRenderTarget(GetCurrentBackBufferRTV(), nullptr, CLEAR_RENDER_TARGET_TRANSITION_STATE);
m_SwapChainImagesInitialized[m_BackBufferIndex] = true;
}
}