Skip to content

Commit 1d9204b

Browse files
authored
Return the proper texture format for GetPreferredCanvasFormat (#37073)
This follows firefox's implementation: https://github.com/mozilla-firefox/firefox/blob/24d49101ce17b78c3ba1217d00297fe2891be6b3/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 <[email protected]>
1 parent cdf5fdd commit 1d9204b

File tree

1 file changed

+6
-2
lines changed
  • components/script/dom/webgpu

1 file changed

+6
-2
lines changed

components/script/dom/webgpu/gpu.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,12 @@ impl GPUMethods<crate::DomTypeHolder> for GPU {
8686

8787
/// <https://gpuweb.github.io/gpuweb/#dom-gpu-getpreferredcanvasformat>
8888
fn GetPreferredCanvasFormat(&self) -> GPUTextureFormat {
89-
// TODO: real implementation
90-
GPUTextureFormat::Rgba8unorm
89+
// From https://github.com/mozilla-firefox/firefox/blob/24d49101ce17b78c3ba1217d00297fe2891be6b3/dom/webgpu/Instance.h#L68
90+
if cfg!(target_os = "android") {
91+
GPUTextureFormat::Rgba8unorm
92+
} else {
93+
GPUTextureFormat::Bgra8unorm
94+
}
9195
}
9296

9397
/// <https://www.w3.org/TR/webgpu/#dom-gpu-wgsllanguagefeatures>

0 commit comments

Comments
 (0)