Skip to content

compositor: treat swapchain sample count 0 as 1 (fixes #369) - #398

Open
skryvel wants to merge 1 commit into
Supreeeme:mainfrom
skryvel:swapchain-sample-count
Open

compositor: treat swapchain sample count 0 as 1 (fixes #369)#398
skryvel wants to merge 1 commit into
Supreeeme:mainfrom
skryvel:swapchain-sample-count

Conversation

@skryvel

@skryvel skryvel commented Aug 8, 2026

Copy link
Copy Markdown

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_texture wrapper 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.

image

@skryvel skryvel changed the title compositor: treat swapchain sample count 0 as 1 compositor: treat swapchain sample count 0 as 1 (fixes #369) Aug 8, 2026
Comment thread src/graphics_backends.rs Outdated
/// 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(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@skryvel
skryvel force-pushed the swapchain-sample-count branch from 1da3ef1 to f31e989 Compare August 23, 2026 16:30
@skryvel
skryvel requested a review from ImSapphire August 23, 2026 16:32
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