Surface formats guaranteed by WebGPU may not be supported on GLES #1925
Labels
area: documentation
Documentation for crate items, public or private
backend: gles
Issues with GLES or WebGL
help required
We need community help to make this happen.
type: bug
Something isn't working
Description
The WebGPU spec guarantees the features of various texture formats, and these features are baked-in as supported by wgpu, and are returned by
Adapter::get_texture_format_features.
Additionally SurfaceConfiguration::format metions that
Bgra8Unorm
andBgra8UnormSrgb
are guaranteed to be supported.However, the GL backend disagrees and, for example, may only support sRGB surfaces. Attempting to create the surface with an unsupported non-sRGB format will fail, even though there is no way to query what surface formats are truly supported by the backend.
Repro steps
Edit the hello-triangle example to use the GL backend:
let instance = wgpu::Instance::new(wgpu::Backends::GL);
Output this after adapter creation:
dbg!(adapter.get_texture_format_features(wgpu::TextureFormat::Bgra8Unorm));
Also replace the swapchain format:
let swapchain_format = surface.get_preferred_format(&adapter).unwrap();
Expected vs observed behavior
Observed:
The format is returned with various allowed usages:
However, the GL backend with certain hardware fails when actually trying to use this format for the surface:
requested format Bgra8Unorm is not in list of supported formats: [Rgba8UnormSrgb, Bgra8UnormSrgb]
There's currently no way to query whether a specific surface format is supported by the backend.
Surface::get_preferred_format
does correctly returnTextureFormat::Bgra8UnormSrgb
in this case, but it's possible the user wants to explicitly query whether a non-sRGB format if available.Expected:
There should be an API to query which formats are actually supported by the surface.
SurfaceConfiguration docs could be updated to specify that
Bgra8Unorm
andBgra8UnormSrgb
are not guaranteed on all backends.Extra materials
Sample repo:
https://github.com/Herschel/wgpu/tree/gl-tex-format
cargo run --example hello_triangle
wgpu @ 76bcd9c
Platform
OpenGL renderer string: Radeon RX 580 Series (POLARIS10, DRM 3.41.0, 5.13.13-200.fc34.x86_64, LLVM 12.0.1)
The text was updated successfully, but these errors were encountered: