PresentFuture: Avoid flushing twice on flush error #1889
Merged
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.
See #1885.
When a
then_swapchain_present
is preceded by athen_signal_semaphore
, it will cause the application to freeze, if thethen_swapchain_present
call fails (i.e. by a window resize returning anAcquireError::OutOfDate
).The problem is that when flushing the
PresentFuture
fails, it will not be marked as either finished, or flushed.In that case the
Drop
implementation of the PresentFuture will do another flush and then wait on the queue to finish.The second flush is in itself incorrect, as we now have two
vkQueuePresentKHR
calls for one future.Even more problematic is that both calls will wait on the previous semaphore.
As only one command can wait on a single Semaphore, the second command will never be signalled.
This then causes the application to freeze when the Drop implementation then waits for the queue to finish, as it never does.
This change always marks a
PresentFuture
as flushed when flush is called, even on failure.It furthermore changes the drop implementation to only flush, when this hasn't been attempted before.
Fix PresentFuture flushing twice if 'then_swapchain_present' fails
Disclaimer: I'm unsure how to test this. It would require at least one window resize. Also we don't really want the test to freeze if the test fails 🤔