putting together a summary message, so anyone else doesn't need to read through the whole thread ๐
issue: (see tracy screenshot) I'm seeing alternating fence waits of ~30ms and ~1ms, even with extremely minimal CPU & GPU workloads
my current loop (stripped down for simplicity):
v0 loop()
{
vkWaitForFences(gvCore.device, 1, &gvLoop.frameResourceFences[gvLoop.curfif], VK_TRUE, UINT64_MAX);
u32 imageIndex;
VkResult swapchainResult = vkAcquireNextImageKHR(gvCore.device, gvWindow.swapchain, UINT64_MAX, gvLoop.frameImageAvailableSemaphores[gvLoop.curfif], VK_NULL_HANDLE, &imageIndex);
//in practice, swapchainResult = VK_SUCCESS and problem persists, so don't worry about it
vkResetFences(gvCore.device, 1, &gvLoop.frameResourceFences[gvLoop.curfif]);
uploadEnvBuffs();
VkCommandBuffer commandBuffer = startRenderCommandBuffer();
appendRenderCommands(commandBuffer);
endRenderCommandBuffer(commandBuffer);
VkSubmitInfo submitInfo={};
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
submitInfo.waitSemaphoreCount = 1;
submitInfo.pWaitSemaphores = &gvLoop.frameImageAvailableSemaphores[gvLoop.curfif];
VkPipelineStageFlags waitStages[] = {VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT};
submitInfo.pWaitDstStageMask = waitStages;
submitInfo.commandBufferCount = 1;
submitInfo.pCommandBuffers = &gvLoop.commandBuffers[gvLoop.curfif];
submitInfo.signalSemaphoreCount = 1;
submitInfo.pSignalSemaphores = &gvLoop.imageRenderFinishedSemaphores[imageIndex];
VkPresentInfoKHR presentInfo={};
presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
presentInfo.waitSemaphoreCount = 1;
presentInfo.pWaitSemaphores = &gvLoop.imageRenderFinishedSemaphores[imageIndex];
presentInfo.swapchainCount = 1;
presentInfo.pSwapchains = &gvWindow.swapchain;
presentInfo.pImageIndices = &imageIndex;
presentInfo.pResults = nul;
CHECK_VKCMD(vkQueueSubmit(gvCore.graphicsQueue, 1, &submitInfo, gvLoop.frameResourceFences[gvLoop.curfif]),"failed to submit draw command buffer");
swapchainResult = vkQueuePresentKHR(gvCore.presentQueue, &presentInfo);
gvLoop.curfif = (gvLoop.curfif+1)%gvConfig.nfif;
}
loop details:
- 2 fif (issue also occurs with 3)
- 3 swapchain images
VK_PRESENT_MODE_FIFO_KHR
- < 3ms CPU/frame, < 3ms GPU/frame
- no validation warnings
- disabled all layers
- updated graphics driver
- if I throw a
vkDeviceWaitIdle right before the wait for fences, I get a rock solid 60fps (but would obviously like to not need to do this)
what might I be doing wrong? I'd be willing to do anything (well, not anything...) to get to the bottom of this- if someone wants to zoom control my screen, or if you'd like compensation, etc...