compositor: treat swapchain sample count 0 as 1 (fixes #369) - #398
compositor: treat swapchain sample count 0 as 1 (fixes #369)#398skryvel wants to merge 1 commit into
Conversation
| /// Like swapchain_info_for_texture, but with invalid values games are known | ||
| /// to submit fixed up. Callers creating or comparing swapchains should use | ||
| /// this to keep the create info consistent across frames. | ||
| fn checked_swapchain_info_for_texture( |
There was a problem hiding this comment.
Why is this a separate function? The only two users of swapchain_info_for_texture are changed to call the checked version in this PR, you could just do the clamp inside swapchain_info_for_texture
There was a problem hiding this comment.
Ah, nevermind I see why. Though I think having a 'checked' version is weird, I think swapchain_info_for_texture itself should be a wrapper around a trait function, since it's possible for someone to mistakenly call swapchain_info_for_texture and cause problems
There was a problem hiding this comment.
Indeed. Reworked. Backends now implement raw_swapchain_info_for_texture, and swapchain_info_for_texture is the trait wrapper that does the fixup so there's no unchecked version left to call by mistake. Turns out that overlay.rs was already making that exact mistake.
Games submit a sample count of 0 when MSAA is disabled (e.g. Half-Life 2: VR with antialiasing set to None). OpenXR requires a sample count of at least 1, so runtimes reject the swapchain and xrizer panics. Backends now implement raw_swapchain_info_for_texture, and the swapchain_info_for_texture everyone calls is a trait wrapper that fixes the value up, so every consumer (compositor and overlays, creation and comparison) sees the same clamped info and a 0 can't trigger per-frame recreation either. Fixes Supreeeme#369
1da3ef1 to
f31e989
Compare
Split out of #397 as its own change.
Games submit a sample count of 0 when MSAA is disabled — Half-Life 2: VR does it whenever antialiasing is set to None, either from the config file or the in-game setting. OpenXR requires at least 1, so the runtime rejects the swapchain and xrizer panics before the game ever renders.
Before: crash on startup with antialiasing set to None.
After: the game runs.
The clamp lives in a
checked_swapchain_info_for_texturewrapper on the backend trait, so there is a single place doing it and the fake backend used by the tests goes through it too. It is applied before the create info is compared against the current swapchain as well — clamping only at creation would leave a stored 1 mismatching the raw 0 arriving every frame, quietly recreating the swapchain on every submit.Covered by
zero_sample_count_texture. Tested with Half-Life 2: VR on a Quest 3 over WiVRn.