Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing error, "Format Bgra8UnormSrgb can't be multisampled", needs better wording #4288

Closed
DevJac opened this issue Oct 23, 2023 · 1 comment · Fixed by #4294
Closed
Labels
area: validation Issues related to validation, diagnostics, and error handling type: enhancement New feature or request

Comments

@DevJac
Copy link
Contributor

DevJac commented Oct 23, 2023

I've been experimenting with MSAA multisampling for the first time.

It appears that, by default, WGPU (and also WebGPU) only support x4 multisampling for the Bgra8UnormSrgb texture format. I believe this because guaranteed_format_features says so:

wgpu::TextureFormat::Bgra8UnormSrgb.guaranteed_format_features(adapter.features()) = TextureFormatFeatures {
    allowed_usages: TextureUsages(
        COPY_SRC | COPY_DST | TEXTURE_BINDING | RENDER_ATTACHMENT,
    ),
    flags: TextureFormatFeatureFlags(
        FILTERABLE | MULTISAMPLE_X4 | MULTISAMPLE_RESOLVE | BLENDABLE,
    ),
}

This is all good so far; no complaints so far.

My complaint is that when I tried to use x8 multisampling I get the error "Format Bgra8UnormSrgb can't be multisampled" which is misleading. The statement is simply false, Bgra8UnormSrgb can be multisampled. The error message makes a simple statement that is false.

Fortunately, I chose to start by using x4 multisampling, so I got the multisampling to work without encountering this error. If I had encountered this error earlier I would have been very confused and would have probably started refactoring my code to use a different texture format.

I propose changing the wording of this error to something like "Format Bgra8UnormSrgb could not be multisampled". A more open-ended error message like this makes it clear that something else, besides the texture format, might be to blame for the multisampling failure. This would be a trivial change, simply changing one string to another.

If we want to go further, the error could say something like "Format Bgra8UnormSrgb does not support x8 multisampling". This would require more than changing just a couple of strings though.

I intend to investigate these changes myself, although anyone else is welcome to as well, no worries. I'm happy for any input or suggestions.

@cwfitzgerald
Copy link
Member

We'd love to have more descriptive error messages! The more information, and the more actionable the error message, the better!

It would be great to have the error message be "Format {} does not support x{} multisampling. Supported sample counts: {:?}". We use dataful enums to produce these error messages, so please add whatever data you need to make a good error.

@cwfitzgerald cwfitzgerald added type: enhancement New feature or request area: validation Issues related to validation, diagnostics, and error handling labels Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: validation Issues related to validation, diagnostics, and error handling type: enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants