Introduce semaphores and wait on submit #4946
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Connections
#4689, #4775, #4919
bevyengine/bevy#10792
Description
This is a WIP PR to gather feedback. I've yet to port all the examples or other backends than Vulkan to use semaphores and fill out the
SemaphoreDescriptor
fully.This introduces user-facing semaphores and allows one to be used to synchronize when a surface texture becomes available during submission.
It was suggested in #4775 that the fence blocking might be a driver bug. I don't necessarily think that's the case. The fence used is only required to trigger at some point in the future when the surface texture becomes available. Vulkan on Android for example (I can't recall where I read this) seems to hold onto the surface texture until a new frame is available from a call to submit. In that scenario it's understandable why the fence never signals in user facing code prior to that.
This might imply that wait semaphores are the only "correct" way to perform this synchronization when using
vkAcquireNextImageKHR
. So it might be a good idea to make this a user facing feature which is what this PR does.Alternative designs
It might be possible to keep track of the semaphores internally. I'm just not sure how that can be done right now while not limiting functionality.
TODO