Submit main command buffer before acquire. Fix sync bug.

This commit is contained in:
Henrik Rydgård 2022-09-20 17:52:35 +02:00
parent fff080202f
commit f6cb6c7695
2 changed files with 7 additions and 4 deletions

View file

@ -126,16 +126,16 @@ void FrameData::SubmitPending(VulkanContext *vulkan, FrameSubmitType type, Frame
hasInitCommands = false;
}
if ((hasMainCommands || hasPresentCommands) && type == FrameSubmitType::Sync) {
fenceToTrigger = readbackFence;
}
if (hasMainCommands) {
VkResult res = vkEndCommandBuffer(mainCmd);
_assert_msg_(res == VK_SUCCESS, "vkEndCommandBuffer failed (main)! result=%s", VulkanResultToString(res));
cmdBufs[numCmdBufs++] = mainCmd;
hasMainCommands = false;
if (type == FrameSubmitType::Sync) {
fenceToTrigger = readbackFence;
}
}
if (hasPresentCommands) {

View file

@ -563,6 +563,8 @@ void VulkanQueueRunner::RunSteps(FrameData &frameData, FrameDataShared &frameDat
switch (step.stepType) {
case VKRStepType::RENDER:
if (!step.render.framebuffer) {
frameData.SubmitPending(vulkan_, FrameSubmitType::Pending, frameDataShared);
// When stepping in the GE debugger, we can end up here multiple times in a "frame".
// So only acquire once.
if (!frameData.hasAcquired) {
@ -570,6 +572,7 @@ void VulkanQueueRunner::RunSteps(FrameData &frameData, FrameDataShared &frameDat
SetBackbuffer(framebuffers_[frameData.curSwapchainImage], swapchainImages_[frameData.curSwapchainImage].image);
}
_dbg_assert_(!frameData.hasPresentCommands);
// A RENDER step rendering to the backbuffer is normally the last step that happens in a frame,
// unless taking a screenshot, in which case there might be a READBACK_IMAGE after it.
// This is why we have to switch cmd to presentCmd, in this case.