From da1e5ff55973242ba0562c93633d1f7d2515c479 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Sun, 1 Jul 2018 23:29:13 -0700 Subject: Added detailed reporting of render pass - PSO mismatch in Vulkan --- .../include/DeviceContextVkImpl.h | 2 + .../src/DeviceContextVkImpl.cpp | 45 ++++++++++++++++++++-- .../GraphicsEngineVulkan/src/TextureVkImpl.cpp | 11 ++++-- 3 files changed, 51 insertions(+), 7 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h index 057467c0..5242cce8 100644 --- a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h @@ -168,6 +168,8 @@ private: inline void DisposeCurrentCmdBuffer(Uint64 FenceValue); void ReleaseStaleContextResources(Uint64 SubmittedCmdBufferNumber, Uint64 SubmittedFenceValue, Uint64 CompletedFenceValue); + void DbgLogRenderPass_PSOMismatch(); + VulkanUtilities::VulkanCommandBuffer m_CommandBuffer; const Uint32 m_NumCommandsToFlush = 192; diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index 43f25a74..7ed86eb5 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -327,6 +327,46 @@ namespace Diligent m_State.CommittedVBsUpToDate = !DynamicBufferPresent; } + void DeviceContextVkImpl::DbgLogRenderPass_PSOMismatch() + { + std::stringstream ss; + ss << "Active render pass is incomaptible with PSO '" << m_pPipelineState->GetDesc().Name << "'. " + "This indicates the mismatch between the number and/or format of bound render targets and/or depth stencil buffer " + "and the PSO. Vulkand requires exact match.\n" + " Bound render targets (" << m_NumBoundRenderTargets << "):"; + Uint32 SampleCount = 0; + for(Uint32 rt = 0; rt < m_NumBoundRenderTargets; ++rt) + { + ss << ' '; + if(auto* pRTV = m_pBoundRenderTargets[rt].RawPtr()) + { + VERIFY_EXPR(SampleCount == 0 || SampleCount == pRTV->GetTexture()->GetDesc().SampleCount); + SampleCount = pRTV->GetTexture()->GetDesc().SampleCount; + ss << GetTextureFormatAttribs(pRTV->GetDesc().Format).Name; + } + else + ss << ""; + } + ss << "; DSV: "; + if(m_pBoundDepthStencil) + { + VERIFY_EXPR(SampleCount == 0 || SampleCount == m_pBoundDepthStencil->GetTexture()->GetDesc().SampleCount); + SampleCount = m_pBoundDepthStencil->GetTexture()->GetDesc().SampleCount; + ss << GetTextureFormatAttribs(m_pBoundDepthStencil->GetDesc().Format).Name; + } + else + ss << ""; + ss << "; Sample count: " << SampleCount; + + const auto& GrPipeline = m_pPipelineState->GetDesc().GraphicsPipeline; + ss << "\n PSO: render targets (" << Uint32{GrPipeline.NumRenderTargets} << "): "; + for(Uint32 rt = 0; rt < GrPipeline.NumRenderTargets; ++rt) + ss << ' ' << GetTextureFormatAttribs(GrPipeline.RTVFormats[rt]).Name; + ss << "; DSV: " << GetTextureFormatAttribs(GrPipeline.DSVFormat).Name; + ss << "; Sample count: " << Uint32{GrPipeline.SmplDesc.Count}; + + LOG_ERROR_MESSAGE(ss.str()); + } void DeviceContextVkImpl::Draw( DrawAttribs &DrawAttribs ) { @@ -390,9 +430,7 @@ namespace Diligent #ifdef _DEBUG if(pPipelineStateVk->GetVkRenderPass() != m_RenderPass) { - LOG_ERROR_MESSAGE("Committed render pass does not match render pass from the Pipeline State object. " - "This indicates the mismatch between the number and/or format of bound render targets and depth stencil buffer " - "and information used to initialize the PSO."); + DbgLogRenderPass_PSOMismatch(); } #endif @@ -949,6 +987,7 @@ namespace Diligent // Set the viewport to match the render target size SetViewports(1, nullptr, 0, 0); } + EnsureVkCmdBuffer(); CommitRenderPassAndFramebuffer(); } diff --git a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp index b488aefa..4d8135cd 100644 --- a/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/TextureVkImpl.cpp @@ -338,10 +338,13 @@ TextureVkImpl :: TextureVkImpl(IReferenceCounters* pRefCounters, Subresource.layerCount = VK_REMAINING_ARRAY_LAYERS; if(aspectMask == VK_IMAGE_ASPECT_COLOR_BIT) { - VkClearColorValue ClearColor = {}; - vkCmdClearColorImage(vkCmdBuff, m_VulkanImage, - m_CurrentLayout, // must be VK_IMAGE_LAYOUT_GENERAL or VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL - &ClearColor, 1, &Subresource); + if(FmtAttribs.ComponentType != COMPONENT_TYPE_COMPRESSED) + { + VkClearColorValue ClearColor = {}; + vkCmdClearColorImage(vkCmdBuff, m_VulkanImage, + m_CurrentLayout, // must be VK_IMAGE_LAYOUT_GENERAL or VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL + &ClearColor, 1, &Subresource); + } } else if(aspectMask == VK_IMAGE_ASPECT_DEPTH_BIT || aspectMask == (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT) ) -- cgit v1.2.3