Skip to content

Conversation

@yzsolt
Copy link

@yzsolt yzsolt commented Jan 17, 2026

Objective

Adds support for querying supported MSAA sample counts on the current GPU, making possible for users to select only supported MSAA modes, thus avoiding fatal WGPU validation errors. Also exposes MSAAx16, which wasn't available before.

Solution

  1. At first I tried to put validation right before texture creation (TextureCache::get), since for some reason WebGPU ties max. sample count info to texture formats, and that's trivially available there. But max. sample count query also requires a RenderAdapter, and passing it to all callsites was not really feasible.
  2. Then I realized that the underlying graphics APIs provide max. sample count on the device level, so we can probably get away with using a dummy/default texture format, so query/validation can be put into Msaa implementation instead.
  • Msaa now exposes a method to retrieve supported sample counts on the given RenderAdapter. Usage is opt-in, Msaa::from_samples still won't check for actual GPU support.
  • A utility constructor is now also available to create Msaa with the highest supported sample count.
  • anti_aliasing example got adapted to these changes, to only show supported MSAA modes.

Testing

  • Tested using the improved anti_aliasing example:
    • On an M1 MacBook it correctly displays only MSAAx2 and MSAAx4
    • On the web it correctly displays only MSAAx4
    • On a Windows laptop it correctly displays MSAAx2, MSAAx4 and MSAAx8, according to the iGPU's capabilities
  • Not tested on MSAAx16 capable hardware (but there's not many such AFAIK anyway)

@github-actions
Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@yzsolt yzsolt force-pushed the msaa-sample-count-validation branch 2 times, most recently from 4dd0175 to 0fd45e8 Compare January 17, 2026 17:47
@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide labels Jan 17, 2026
@alice-i-cecile alice-i-cecile added C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 17, 2026
@github-actions
Copy link
Contributor

It looks like your PR is a breaking change, but you didn't provide a migration guide.

Please review the instructions for writing migration guides, then expand or revise the content in the migration guides directory to reflect your changes.

@yzsolt yzsolt force-pushed the msaa-sample-count-validation branch from a0da69a to 95f8841 Compare January 19, 2026 17:59
@yzsolt yzsolt changed the title Rework Msaa component to allow for querying supported sample counts Allow for querying supported sample counts in Msaa and expose 16 samples Jan 19, 2026
@yzsolt yzsolt force-pushed the msaa-sample-count-validation branch from 95f8841 to e47b468 Compare January 19, 2026 18:21
@yzsolt
Copy link
Author

yzsolt commented Jan 19, 2026

I reverted the API breaking enum -> struct change, as I realized it was unnecessary. The changeset is much cleaner now, sorry about the previous noise.
I'm not 100% happy with the naming of SupportedMsaaList in the example, but I have no better idea, and it's probably not that important anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior C-Usability A targeted quality-of-life change that makes Bevy easier to use M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

macos: anti_aliasing example crashes when MSAA is set to 8 samples MSAA with 8 samples crashes when using vulkan on windows 10

3 participants