diff --git a/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp b/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp index d3d84a3a04..537c21c514 100644 --- a/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp +++ b/Source/Core/VideoBackends/Vulkan/CommandBufferManager.cpp @@ -83,6 +83,7 @@ bool CommandBufferManager::CreateCommandBuffers() for (FrameResources& resources : m_frame_resources) { + resources.init_command_buffer_used = false; resources.needs_fence_wait = false; VkCommandBufferAllocateInfo allocate_info = { @@ -325,6 +326,13 @@ void CommandBufferManager::SubmitCommandBuffer(size_t index, VkSemaphore wait_se 0, nullptr}; + // If the init command buffer did not have any commands recorded, don't submit it. + if (!m_frame_resources[index].init_command_buffer_used) + { + submit_info.commandBufferCount = 1; + submit_info.pCommandBuffers = &m_frame_resources[index].command_buffers[1]; + } + if (wait_semaphore != VK_NULL_HANDLE) { submit_info.pWaitSemaphores = &wait_semaphore; @@ -407,6 +415,7 @@ void CommandBufferManager::ActivateCommandBuffer() // Reset command buffer to beginning since we can re-use the memory now VkCommandBufferBeginInfo begin_info = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr, VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, nullptr}; + resources.init_command_buffer_used = false; for (VkCommandBuffer command_buffer : resources.command_buffers) { res = vkResetCommandBuffer(command_buffer, 0); diff --git a/Source/Core/VideoBackends/Vulkan/CommandBufferManager.h b/Source/Core/VideoBackends/Vulkan/CommandBufferManager.h index 73ab126f97..3f0148db9c 100644 --- a/Source/Core/VideoBackends/Vulkan/CommandBufferManager.h +++ b/Source/Core/VideoBackends/Vulkan/CommandBufferManager.h @@ -35,8 +35,9 @@ public: VkCommandPool GetCommandPool() const { return m_command_pool; } // These command buffers are allocated per-frame. They are valid until the command buffer // is submitted, after that you should call these functions again. - VkCommandBuffer GetCurrentInitCommandBuffer() const + VkCommandBuffer GetCurrentInitCommandBuffer() { + m_frame_resources[m_current_frame].init_command_buffer_used = true; return m_frame_resources[m_current_frame].command_buffers[0]; } VkCommandBuffer GetCurrentCommandBuffer() const @@ -119,6 +120,7 @@ private: std::array command_buffers; VkDescriptorPool descriptor_pool; VkFence fence; + bool init_command_buffer_used; bool needs_fence_wait; std::vector cleanup_resources;