mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-15 16:59:18 +01:00
Vulkan: Only submit init/upload command buffer when it has commands
This way we're not submitting empty buffers when it's unnecessary.
This commit is contained in:
parent
bac8c2d441
commit
5f66cf5ed7
@ -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);
|
||||
|
@ -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<VkCommandBuffer, 2> command_buffers;
|
||||
VkDescriptorPool descriptor_pool;
|
||||
VkFence fence;
|
||||
bool init_command_buffer_used;
|
||||
bool needs_fence_wait;
|
||||
|
||||
std::vector<DeferredResourceDestruction> cleanup_resources;
|
||||
|
Loading…
x
Reference in New Issue
Block a user