Skip to content

Commit

Permalink
submit first so the GPU already has work by the time the CPU resumes
Browse files Browse the repository at this point in the history
  • Loading branch information
goeiecool9999 committed Aug 16, 2024
1 parent 0f73502 commit 05bc893
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Cafe/HW/Latte/Renderer/Vulkan/VulkanRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2640,6 +2640,7 @@ bool VulkanRenderer::AcquireNextSwapchainImage(bool mainWindow)
if (!UpdateSwapchainProperties(mainWindow))
return false;

// std::cout << "acquire" << std::endl;
bool result = chainInfo.AcquireImage();
if (!result)
return false;
Expand Down Expand Up @@ -2732,14 +2733,17 @@ void VulkanRenderer::SwapBuffer(bool mainWindow)
ClearColorImageRaw(chainInfo.m_swapchainImages[chainInfo.swapchainImageIndex], 0, 0, clearColor, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR);
}

WaitCommandBufferFinished(m_commandBufferIDOfPrevFrame);
m_commandBufferIDOfPrevFrame = GetCurrentCommandBufferId();
const size_t currentFrameCmdBufferID = GetCurrentCommandBufferId();

VkSemaphore presentSemaphore = chainInfo.m_presentSemaphores[chainInfo.swapchainImageIndex];
SubmitCommandBuffer(presentSemaphore); // submit all command and signal semaphore

cemu_assert_debug(m_numSubmittedCmdBuffers > 0);

// wait for the previous frame to finish rendering.
WaitCommandBufferFinished(m_commandBufferIDOfPrevFrame);
m_commandBufferIDOfPrevFrame = currentFrameCmdBufferID;

VkPresentIdKHR presentId = {};

VkPresentInfoKHR presentInfo = {};
Expand Down Expand Up @@ -2769,6 +2773,7 @@ void VulkanRenderer::SwapBuffer(bool mainWindow)
}
}

// std::cout << "swap" << std::endl;
VkResult result = vkQueuePresentKHR(m_presentQueue, &presentInfo);
if (result < 0 && result != VK_ERROR_OUT_OF_DATE_KHR)
{
Expand Down

0 comments on commit 05bc893

Please sign in to comment.