mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06: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:
@ -83,6 +83,7 @@ bool CommandBufferManager::CreateCommandBuffers()
|
|||||||
|
|
||||||
for (FrameResources& resources : m_frame_resources)
|
for (FrameResources& resources : m_frame_resources)
|
||||||
{
|
{
|
||||||
|
resources.init_command_buffer_used = false;
|
||||||
resources.needs_fence_wait = false;
|
resources.needs_fence_wait = false;
|
||||||
|
|
||||||
VkCommandBufferAllocateInfo allocate_info = {
|
VkCommandBufferAllocateInfo allocate_info = {
|
||||||
@ -325,6 +326,13 @@ void CommandBufferManager::SubmitCommandBuffer(size_t index, VkSemaphore wait_se
|
|||||||
0,
|
0,
|
||||||
nullptr};
|
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)
|
if (wait_semaphore != VK_NULL_HANDLE)
|
||||||
{
|
{
|
||||||
submit_info.pWaitSemaphores = &wait_semaphore;
|
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
|
// Reset command buffer to beginning since we can re-use the memory now
|
||||||
VkCommandBufferBeginInfo begin_info = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr,
|
VkCommandBufferBeginInfo begin_info = {VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr,
|
||||||
VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, nullptr};
|
VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, nullptr};
|
||||||
|
resources.init_command_buffer_used = false;
|
||||||
for (VkCommandBuffer command_buffer : resources.command_buffers)
|
for (VkCommandBuffer command_buffer : resources.command_buffers)
|
||||||
{
|
{
|
||||||
res = vkResetCommandBuffer(command_buffer, 0);
|
res = vkResetCommandBuffer(command_buffer, 0);
|
||||||
|
@ -35,8 +35,9 @@ public:
|
|||||||
VkCommandPool GetCommandPool() const { return m_command_pool; }
|
VkCommandPool GetCommandPool() const { return m_command_pool; }
|
||||||
// These command buffers are allocated per-frame. They are valid until the command buffer
|
// These command buffers are allocated per-frame. They are valid until the command buffer
|
||||||
// is submitted, after that you should call these functions again.
|
// 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];
|
return m_frame_resources[m_current_frame].command_buffers[0];
|
||||||
}
|
}
|
||||||
VkCommandBuffer GetCurrentCommandBuffer() const
|
VkCommandBuffer GetCurrentCommandBuffer() const
|
||||||
@ -119,6 +120,7 @@ private:
|
|||||||
std::array<VkCommandBuffer, 2> command_buffers;
|
std::array<VkCommandBuffer, 2> command_buffers;
|
||||||
VkDescriptorPool descriptor_pool;
|
VkDescriptorPool descriptor_pool;
|
||||||
VkFence fence;
|
VkFence fence;
|
||||||
|
bool init_command_buffer_used;
|
||||||
bool needs_fence_wait;
|
bool needs_fence_wait;
|
||||||
|
|
||||||
std::vector<DeferredResourceDestruction> cleanup_resources;
|
std::vector<DeferredResourceDestruction> cleanup_resources;
|
||||||
|
Reference in New Issue
Block a user