From da6bb5d0d93e550a32da19550df21521ce2da505 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sat, 1 Dec 2018 11:45:38 -0800 Subject: Added explicit state transition control flags to CLEAR_DEPTH_STENCIL_FLAGS --- .../src/DeviceContextVkImpl.cpp | 25 +++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index db958c57..1be1f045 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -703,15 +703,30 @@ namespace Diligent auto* pTexture = pVkDSV->GetTexture(); auto* pTextureVk = ValidatedCast(pTexture); - // Image layout must be VK_IMAGE_LAYOUT_GENERAL or VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL (17.1) - if (pTextureVk->IsInKnownState()) + if (ClearFlags & CLEAR_DEPTH_STENCIL_TRANSITION_STATE_FLAG) + { + // Image layout must be VK_IMAGE_LAYOUT_GENERAL or VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL (17.1) + if (pTextureVk->IsInKnownState()) + { + 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); + } + } +#ifdef DEVELOPMENT + else if(ClearFlags & CLEAR_DEPTH_STENCIL_VERIFY_STATE_FLAG) { - if (!pTextureVk->CheckState(RESOURCE_STATE_COPY_DEST)) + if (pTextureVk->IsInKnownState() && !pTextureVk->CheckState(RESOURCE_STATE_COPY_DEST)) { - TransitionTextureState(*pTextureVk, RESOURCE_STATE_UNKNOWN, RESOURCE_STATE_COPY_DEST, true); + LOG_ERROR_MESSAGE("Depth-stencil buffer '", 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_DEPTH_STENCIL_TRANSITION_STATE_FLAG flag or explicitly transition the resource using IDeviceContext::TransitionResourceStates() method."); } - VERIFY_EXPR(pTextureVk->GetLayout() == VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); } +#endif + VkClearDepthStencilValue ClearValue; ClearValue.depth = fDepth; -- cgit v1.2.3