Skip to content

Commit

Permalink
Only keep preferred format as the first element
Browse files Browse the repository at this point in the history
  • Loading branch information
jinleili committed May 3, 2023
1 parent 4861ded commit 50d75f0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions wgpu/src/backend/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1114,14 +1114,20 @@ impl crate::context::Context for Context {
_adapter_data: &Self::AdapterData,
) -> wgt::SurfaceCapabilities {
let format = self.0.get_preferred_canvas_format();
let preferred_format = if map_texture_format(wgt::TextureFormat::Bgra8Unorm) == format {
wgt::TextureFormat::Bgra8Unorm
let (preferred, second) = if map_texture_format(wgt::TextureFormat::Bgra8Unorm) == format {
(
wgt::TextureFormat::Bgra8Unorm,
wgt::TextureFormat::Rgba8Unorm,
)
} else {
wgt::TextureFormat::Rgba8Unorm
(
wgt::TextureFormat::Rgba8Unorm,
wgt::TextureFormat::Bgra8Unorm,
)
};
wgt::SurfaceCapabilities {
// https://gpuweb.github.io/gpuweb/#supported-context-formats
formats: vec![preferred_format, wgt::TextureFormat::Rgba16Float],
formats: vec![preferred, second, wgt::TextureFormat::Rgba16Float],
// Doesn't really have meaning on the web.
present_modes: vec![wgt::PresentMode::Fifo],
alpha_modes: vec![wgt::CompositeAlphaMode::Opaque],
Expand Down

0 comments on commit 50d75f0

Please sign in to comment.