From ce73fe5b16afb3228ef6352a5a3ec4a4f1c7f6a0 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 10 May 2019 01:53:09 +0200 Subject: [PATCH] - fix command buffer invalidation bug when DynamicSet is updated --- src/rendering/vulkan/renderer/vk_renderpass.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/rendering/vulkan/renderer/vk_renderpass.cpp b/src/rendering/vulkan/renderer/vk_renderpass.cpp index ea4738f637..fc06694192 100644 --- a/src/rendering/vulkan/renderer/vk_renderpass.cpp +++ b/src/rendering/vulkan/renderer/vk_renderpass.cpp @@ -165,6 +165,11 @@ void VkRenderPassManager::UpdateDynamicSet() { auto fb = GetVulkanFrameBuffer(); + // In some rare cases drawing commands may already have been created before VulkanFrameBuffer::BeginFrame is called. + // Make sure there there are no active command buffers using DynamicSet when we update it: + fb->GetRenderState()->EndRenderPass(); + fb->WaitForCommands(false); + WriteDescriptors update; update.addBuffer(DynamicSet.get(), 0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, fb->ViewpointUBO->mBuffer.get(), 0, sizeof(HWViewpointUniforms)); update.addBuffer(DynamicSet.get(), 1, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, fb->LightBufferSSO->mBuffer.get());