Skip to content

VUID-vkQueueSubmit-pSignalSemaphores-00067: incorrect use of renderFinishedSemaphores in the "frames in flight" chapter #407

@chuigda

Description

@chuigda

As stated in http://disq.us/p/32wdmkz, a recent Vulkan Validation Layer update exposed the problem that most Vulkan tutorials (also vkguide, and other derivative works of VulkanTutorial) and Vulkan programs (even vkcube) did not correctly make use of semaphores to synchronize presentation.

I am not a Vulkan professor, and here's my understanding. In the following code:

VkSemaphore signalSemaphores[] = {renderFinishedSemaphores[currentFrame]};
submitInfo.signalSemaphoreCount = 1;
submitInfo.pSignalSemaphores = signalSemaphores;
vkQueueSubmit(graphicsQueue, 1, &submitInfo, inFlightFences[currentFrame]);

Here we are actually expecting that the renderFinishedSemaphores[currentFrame] to have already been acquired/consumed by presentation queue during the several previous iterations. However there's no guarantee. So it is possible for the graphics queue to signal an already signaled semaphore.

To fix this problem, program should create the renderFinishedSemaphores array of swapChainImages.size() semaphores, and use the imageIndex returned from vkAcquireNextImageKHR to index into the array, ensuring that the semaphore has been acquired/consumed:

kennyalive/vulkan-base@27bcaad
JasonPhone/vrtr@c459d88
JorriFransen/v10@3652d32

I also made my personal fix on my own Java version tutorial: old -> new

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions