Return the proper texture format for GetPreferredCanvasFormat (#37073)

This follows firefox's implementation:
24d49101ce/dom/webgpu/Instance.h (L68)

It changes the default on most systems to `Bgra8Unorm` but leaves it as
`Rgba8Unorm` on android.

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
This commit is contained in:
Ashwin Naren 2025-05-21 13:07:00 -07:00 committed by GitHub
parent cdf5fdd2b4
commit 1d9204b4b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -86,8 +86,12 @@ impl GPUMethods<crate::DomTypeHolder> for GPU {
/// <https://gpuweb.github.io/gpuweb/#dom-gpu-getpreferredcanvasformat>
fn GetPreferredCanvasFormat(&self) -> GPUTextureFormat {
// TODO: real implementation
GPUTextureFormat::Rgba8unorm
// From https://github.com/mozilla-firefox/firefox/blob/24d49101ce17b78c3ba1217d00297fe2891be6b3/dom/webgpu/Instance.h#L68
if cfg!(target_os = "android") {
GPUTextureFormat::Rgba8unorm
} else {
GPUTextureFormat::Bgra8unorm
}
}
/// <https://www.w3.org/TR/webgpu/#dom-gpu-wgsllanguagefeatures>