Overv / VulkanTutorial

Tutorial for the Vulkan graphics and compute API
https://vulkan-tutorial.com
Creative Commons Attribution Share Alike 4.0 International
3.2k stars 527 forks source link

Swapchain recreation: Semaphore is left signaled #388

Open V-Fries opened 3 months ago

V-Fries commented 3 months ago

Inside the drawFrame() function in the chapter "Swap chain recreation" during the acquisition of the next image index:

VkResult result = vkAcquireNextImageKHR(device, swapChain, UINT64_MAX, imageAvailableSemaphores[currentFrame], VK_NULL_HANDLE, &imageIndex);

if (result == VK_ERROR_OUT_OF_DATE_KHR) {
    recreateSwapChain();
    return;
} else if (result != VK_SUCCESS && result != VK_SUBOPTIMAL_KHR) {
    throw std::runtime_error("failed to acquire swap chain image!");
}

In the case vkAcquireNextImageKHR() returns VK_ERROR_OUT_OF_DATE_KHR the drawFrame() function will return with imageAvailableSemaphores[currentFrame] being signaled which causes the following validation error during the next iteration:

[Validation layer][ERROR][VALIDATION]: "Validation Error: [ VUID-vkAcquireNextImageKHR-semaphore-01286 ] Object 0: handle = 0xe7f79a0000000005, type = VK_OBJECT_TYPE_SEMAPHORE; | MessageID = 0xe9e4b2a9 | vkAcquireNextImage
KHR():  Semaphore must not be currently signaled. The Vulkan spec states: If semaphore is not VK_NULL_HANDLE it must be unsignaled (https://vulkan.lunarg.com/doc/view/1.3.283.0/mac/1.3-extensions/vkspec.html#VUID-vkAcquire
NextImageKHR-semaphore-01286)"