Backends: DX11: Switch to DXGI_SWAP_EFFECT_FLIP_DISCARD #9031
+78
−46
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.
This PR is a follow-up to #8979 (comment)
It is split into two commits:
Use DXGI_SWAP_EFFECT_FLIP_DISCARD instead of DXGI_SWAP_EFFECT_DISCARD
Switching to DXGI_SWAP_EFFECT_FLIP_DISCARD is straightforward and requires changing only three lines. The buffer count was increased from 1 to 2, as DXGI_SWAP_EFFECT_FLIP_DISCARD requires a minimum of two buffers. According to the documentation, this swap effect is supported starting with Windows 10, which implies requiring the Windows 10 SDK.
Enable swapchain tearing
This part is largely similar to #8965. Adding support for tearing is significantly more involved, and here are the key changes:
Regarding SDK requirements, this bumps the dxgi version to 1.5 (required for CheckFeatureSupport). Dxgi 1.5 was introduced in the Windows 10 Anniversary SDK. According to Microsoft’s documentation, the tearing feature is nearly ubiquitous on recent versions of Windows 10 and on modern hardware.
If you’re considering whether this is too much of a change, note that tearing support is highly recommended by Microsoft when using flip-model swap effects with VSync disabled:
One aspect not yet addressed is how the user can provide the desired swap effect to the backend. It isn't strictly required, main and secondary viewports can happily operate with different swap effects. However, if we want to allow users to configure this behavior, it would likely require introducing an init info structure.