-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
Hi,
I am working on your tutorial (thanks for this resource, it has been very informative.) I came across a validation layer error after completing the chapter 20. Using the code from the completed chapter,
I get multiple validation errors that all read like
ERROR 15_hello_triangle > (VALIDATION) vkQueueSubmit(): pSubmits[0].pSignalSemaphores[0] (VkSemaphore 0x1a000000001a) is being signaled by VkQueue 0x55f6b4a2e0f0, but it may still be in use by VkSwapchainKHR 0x30000000003.
Most recently acquired image indices: [0], 1, 2.
(Brackets mark the last use of VkSemaphore 0x1a000000001a in a presentation operation.)
Swapchain image 0 was presented but was not re-acquired, so VkSemaphore 0x1a000000001a may still be in use and cannot be safely reused with image index 2.
Vulkan insight: See https://docs.vulkan.org/guide/latest/swapchain_semaphore_reuse.html for details on swapchain semaphore reuse. Examples of possible approaches:
a) Use a separate semaphore per swapchain image. Index these semaphores using the index of the acquired image.
b) Consider the VK_KHR_swapchain_maintenance1 extension. It allows using a VkFence with the presentation operation.
The Vulkan spec states: Each binary semaphore element of the pSignalSemaphores member of any element of pSubmits must be unsignaled when the semaphore signal operation it defines is executed on the device (https://docs.vulkan.org/spec/latest/chapters/cmdbuffers.html#VUID-vkQueueSubmit-pSignalSemaphores-00067)
So I dug into it and came across this frequent problem with swapchain semaphore reuse. Reading this, I was able to fix these validation errors by doing the following:
- Save the min_image_count while we are creating the swapchain.
- In
fn create_sync_objects, create semaphores for eachmin_image_countof the swapchain
for _ in 0..data.swapchain_min_image_count {
data.image_available_semaphore.push(device.create_semaphore(&semaphore_info, None)?);
data.render_finished_semaphore.push(device.create_semaphore(&semaphore_info, None)?);
}- In
fn render, signal the semaphore of the acquired image index
let signal_semaphores = &[self.data.render_finished_semaphore[image_index]];As I am quite new to Vulkan, I don't really know if this is the right way to do what we are doing in this tutorial, but it makes sense. Let me know if I am not mistaken and I will submit a pull request.
Thanks a lot
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels