From fd4e7f4e466bcc4fc7f35bf65e23a8ee860a9edf Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Wed, 25 Jul 2018 21:32:33 -0700 Subject: Fixed major performance bug in Vk backend: removed unnecessary call to EndRenderPass() from SetPipelineState() that was forcing render pass to begin every time new PSO is bound causing more than 2x slowdown in Tutorials 9 & 10 Fixed typo --- .../include/DeviceContextVkImpl.h | 2 +- .../src/DeviceContextVkImpl.cpp | 23 +++++++++------------- 2 files changed, 10 insertions(+), 15 deletions(-) (limited to 'Graphics/GraphicsEngineVulkan') diff --git a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h index 4470c028..312bdaca 100644 --- a/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h +++ b/Graphics/GraphicsEngineVulkan/include/DeviceContextVkImpl.h @@ -221,7 +221,7 @@ private: // be submitted next Atomics::AtomicInt64 m_NextCmdBuffNumber; - PipelineLayout::DescriptorSetBindInfo m_DesrSetBindInfo; + PipelineLayout::DescriptorSetBindInfo m_DescrSetBindInfo; VulkanDynamicHeap m_DynamicHeap; std::shared_ptr m_GenerateMipsHelper; RefCntAutoPtr m_GenerateMipsSRB; diff --git a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp index dc04f2a2..a1e858e5 100644 --- a/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp +++ b/Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp @@ -189,11 +189,6 @@ namespace Diligent void DeviceContextVkImpl::SetPipelineState(IPipelineState *pPipelineState) { - if (m_CommandBuffer.GetState().RenderPass != VK_NULL_HANDLE) - { - m_CommandBuffer.EndRenderPass(); - } - // Never flush deferred context! if (!m_bIsDeferred && m_State.NumCommands >= m_NumCommandsToFlush) { @@ -251,7 +246,7 @@ namespace Diligent } } - m_DesrSetBindInfo.Reset(); + m_DescrSetBindInfo.Reset(); } void DeviceContextVkImpl::TransitionShaderResources(IPipelineState *pPipelineState, IShaderResourceBinding *pShaderResourceBinding) @@ -267,7 +262,7 @@ namespace Diligent if (!DeviceContextBase::CommitShaderResources(pShaderResourceBinding, Flags, 0 /*Dummy*/)) return; - m_pPipelineState->CommitAndTransitionShaderResources(pShaderResourceBinding, this, true, Flags, &m_DesrSetBindInfo); + m_pPipelineState->CommitAndTransitionShaderResources(pShaderResourceBinding, this, true, Flags, &m_DescrSetBindInfo); } void DeviceContextVkImpl::SetStencilRef(Uint32 StencilRef) @@ -423,8 +418,8 @@ namespace Diligent else CommitVkVertexBuffers(); - if (m_DesrSetBindInfo.DynamicOffsetCount != 0) - m_pPipelineState->BindDescriptorSetsWithDynamicOffsets(this, m_DesrSetBindInfo); + if (m_DescrSetBindInfo.DynamicOffsetCount != 0) + m_pPipelineState->BindDescriptorSetsWithDynamicOffsets(this, m_DescrSetBindInfo); #if 0 #ifdef _DEBUG else @@ -509,8 +504,8 @@ namespace Diligent if (m_CommandBuffer.GetState().RenderPass != VK_NULL_HANDLE) m_CommandBuffer.EndRenderPass(); - if (m_DesrSetBindInfo.DynamicOffsetCount != 0) - m_pPipelineState->BindDescriptorSetsWithDynamicOffsets(this, m_DesrSetBindInfo); + if (m_DescrSetBindInfo.DynamicOffsetCount != 0) + m_pPipelineState->BindDescriptorSetsWithDynamicOffsets(this, m_DescrSetBindInfo); #if 0 #ifdef _DEBUG else @@ -838,7 +833,7 @@ namespace Diligent ReleaseStaleContextResources(SubmittedCmdBuffNumber, SubmittedFenceValue, CompletedFenceValue); m_State = ContextState{}; - m_DesrSetBindInfo.Reset(); + m_DescrSetBindInfo.Reset(); m_CommandBuffer.Reset(); m_pPipelineState = nullptr; } @@ -858,7 +853,7 @@ namespace Diligent m_State = ContextState{}; m_RenderPass = VK_NULL_HANDLE; m_Framebuffer = VK_NULL_HANDLE; - m_DesrSetBindInfo.Reset(); + m_DescrSetBindInfo.Reset(); VERIFY(m_CommandBuffer.GetState().RenderPass == VK_NULL_HANDLE, "Invalidating context with unifinished render pass"); m_CommandBuffer.Reset(); } @@ -1229,7 +1224,7 @@ namespace Diligent m_CommandBuffer.Reset(); m_State = ContextState{}; - m_DesrSetBindInfo.Reset(); + m_DescrSetBindInfo.Reset(); m_pPipelineState = nullptr; InvalidateState(); -- cgit v1.2.3