Description
This comment #2711 (comment) has a much cleaner and easier to use api that I think we should use after a discussion.
Is your feature request related to a problem? Please describe.
The set of Immediate
, Fifo
, and Mailbox
isn't really representative of all the options that our backends provide us for swapchain management. It also forces us to explicitly fallback from Mailbox to FIFO when it isn't available. I've gotten requests for fallback to Immediate because what they wanted was "run at fast as possible" with "no tearing" as a benefit.
Thinking about a design, let's look at the options that are available to us.
Vulkan:
- Immediate: No Wait, Tearing,
- Fifo: Waiting, Tearing.
- Fifo-Relaxed: Waiting if fast, tearing if slow.
- Mailbox: No wait, no tearing
Metal:
- Sync On: Waiting, No Tearing.
- Sync Off: No Waiting, Tearing.
DXGI:
- Sync Interval 0: No Waiting, No Tearing
- Sync Interval 1: Waiting, No Tearing
- Sync Interval 0 Allow Tearing: No Waiting, No Tearing (this has something to do with VFR, figuring this out now)
GL:
- Swap Interval 0: No Waiting, Tearing,
- Swap Interval 1: Waiting, No Tearing
Describe the solution you'd like
I want an api which allows the user to express their preferences for waiting and tearing.
enum PresentModeTearing {
AllowTearing,
NoTearing,
}
enum PresentModeWaiting {
WaitForSync,
AllowNoWait,
}
struct PresentMode {
tearing: PresentModeTearing,
sync: PresentModeWaiting,
}
Which will result in the following:
Tearing, Sync | Vulkan | DXGI | GL | Metal |
---|---|---|---|---|
NoTearing, AllowNoWait | [Mailbox, FIFO] | Sync 0 | Swap 1 | Sync On |
NoTearing, WaitForSync | [FIFO] | Sync 1 | Swap 1 | Sync On |
AllowTearing, AllowNoWait | [Mailbox, Immediate, FIFO, FIFO_Relaxed] | Sync 0 | Swap 0 | Sync Off |
AllowTearing, WaitForSync | [FIFO_RELAXED, FIFO] | Sync 1 | Swap 0 | Sync Off |
Describe alternatives you've considered
It isn't very representative to allow the user to directly be able to choice modes when there are so many different ways to represent the combinations and the possible fallbacks. These two enums communicate intent so we can make the right decision.