Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PresentFuture: Avoid flushing twice on flush error #1889

Merged
merged 1 commit into from
May 2, 2022

Conversation

LeonMatthes
Copy link
Contributor

See #1885.
When a then_swapchain_present is preceded by a then_signal_semaphore, it will cause the application to freeze, if the then_swapchain_present call fails (i.e. by a window resize returning an AcquireError::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.

  • Entries for Vulkano changelog:
    • 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 🤔

@LeonMatthes
Copy link
Contributor Author

Open Question: Is it valid to flush a future twice and expect different results?

@Rua
Copy link
Contributor

Rua commented May 2, 2022

I can't say immediately whether your changes have any flaws, as the GpuFuture code is one of the parts of Vulkano I'm least familiar with, and it also deviates quite significantly from how plain Vulkan does it. At some point I would like to bring it a bit closer to Vulkan's API, so that additions like timeline semaphores are easier to implement, but at the same time I don't want to sacrifice the ergonomics too much.

The documentation of flush says:

The implementation must remember that it was flushed. If the function is called multiple times, only the first time must result in a flush.

So I would assume that, if the first flush did anything, the second flush should do nothing.

@Rua Rua merged commit 799d99d into vulkano-rs:master May 2, 2022
Rua added a commit that referenced this pull request May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants