Shadowmapping: App does not synchronize the "offscreen" pass with the "draw" pass
(this issue is somewhat related to #69)
The application draws a frame in two steps
- A shadow map is rendered, using a command buffer recorded in buildOffscreenCommandBuffer()
- The scene is rendered to current frame's swapchain image, using one of the command buffers created in buildCommandBuffers():
The command buffers are submitted to the same command queue using a single vkQueueSubmit() call in draw():

As per spec, this means the scheduled command buffers may start executing at any time, including a situation where they both launch at the same time. This indicates we need to ensure proper synchronization is in place to prevent RAW hazards (that is: shadow map is sampled before the first command buffer finishes writing to it).
Sadly, the application does not seem to use any events to serialize execution of the two command buffers. Furthermore, I'm worried this problem affects more than just this application.
Sadly, the application does not seem to use any events to serialize execution of the two command buffers. Furthermore, I'm worried this problem affects more than just this application.
Yes, this is true for all examples that use multiple command buffers in one queue and mostly affects those that do offscreen rendering.
I'll try to address this as soon as possible. Thanks for hinting me at this.
Sorry for the late reply, but I finally got around tackling this issue.
I changed the code like this :

There is now an additional semaphore for the offscreen rendering and the offscreen command buffer is submitted separately.
The command buffer that does the final rendering using the offscreen texture (shadow map) will then wait for that semaphore.
Though it's hard to tell if this works as it has worked before without that semaphore on all devices I checked I think this should do the job?
If so I'll add this to all examples that submit multiple command buffers that rely on each other.
I'm also evaluating the use of events for synchronization. They are more light-weight and easier to put into the existing structure of the examples.
Hey Sacha. Yeah, semaphores are fine, thanks for fixing this :-)
Events would also fit in here, but they put the additional restriction where all command buffers you submit must be targeted at exactly the same command queue. Depending on your engine's architecture, this may or may not be a good fit for all use cases.
All examples that do some sort of offscreen rendering now use a separate semaphore to synchronize between the offscreen and final rendering command buffers.
As a positive side effect I also got rid of the separate texture targets for offscreen stuff and now sample directly from the color and depth attachments :smile: