Wgpu-rs: Why wgpu::TextureFormat::Bgra8UnormSrgb in examples when creating a swapchain?

Created on 19 Nov 2019  路  9Comments  路  Source: gfx-rs/wgpu-rs

Is there anything special about this texture format? Is it related to the monitor's format?

question

Most helpful comment

fwiw, upstream WebGPU API has an async method called getSwapChainPreferredFormat. The users would use that format in order to avoid a potential extra blit by the implementation. We just need to provide something like this in wgpu-native and wgpu-rs, which would be better than just documenting a particular format.

All 9 comments

Yeah, it's the only texture format that is guaranteed to be natively supported by the swapchains of all the APIs/platforms. Is that a concern for your application?

I think what kvark said should be included in the documentation for wgpu::TextureFormat::Bgra8UnormSrgb

fwiw, upstream WebGPU API has an async method called getSwapChainPreferredFormat. The users would use that format in order to avoid a potential extra blit by the implementation. We just need to provide something like this in wgpu-native and wgpu-rs, which would be better than just documenting a particular format.

It's no problem for me @kvark I just didn't know why it was being used. I'll update my tutorial to add that fact

Ironically, Bgra8 does not seem to be supported by Vulkan on my Android device:

01-10 12:22:01.492 22964 23010 I RustStdoutStderr: thread '<unnamed>' panicked at 'requested format Bgra8Srgb is not in list of supported formats: [Rgba8Unorm, Rgba8Srgb, R5g6b5Unorm, A2b10g10r10Unorm, Rgba16Sfloat]', /Users/niklaskorz/.cargo/registry/src/github.com-1ecc6299db9ec823/wgpu-0.6.2/src/backend/direct.rs:1355:35

Interesting! I suppose this is solved by #693 now?

Yes, thankfully it is. 馃槃

Hm actually, it looks like device_get_swap_chain_preferred_format still just returns Bgra8UnormSrgb? So I suppose in that case it wouldn't work, as Bgra8UnormSrgb is not supported as surface format by my device.

Looking at a few other results, this appears to be the case for other (if not most?) SoC GPUs as well:

We need wgpu checking for this and returning a correct value in the preferred format. Could you make an issue in wgpu about this, please?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

donpdonp picture donpdonp  路  3Comments

dmilford picture dmilford  路  3Comments

JonathanWoollett-Light picture JonathanWoollett-Light  路  4Comments

bvssvni picture bvssvni  路  5Comments

m4b picture m4b  路  5Comments