Skip to content

Commit

Permalink
wgpu: ensure that the srgb format is available before using it
Browse files Browse the repository at this point in the history
refs: wez#3032
  • Loading branch information
wez authored and imsnif committed Feb 11, 2023
1 parent a574c1a commit 80eef3b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions wezterm-gui/src/termwindow/webgpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,12 @@ impl WebGpuState {
let queue = Arc::new(queue);

// Explicitly request an SRGB format, if available
let format = caps.formats[0].add_srgb_suffix();
let pref_format_srgb = caps.formats[0].add_srgb_suffix();
let format = if caps.formats.contains(&pref_format_srgb) {
pref_format_srgb
} else {
caps.formats[0]
};

let config = wgpu::SurfaceConfiguration {
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
Expand All @@ -324,7 +329,7 @@ impl WebGpuState {
} else {
wgpu::CompositeAlphaMode::Auto
},
view_formats: vec![format, format.remove_srgb_suffix()],
view_formats: vec![format.add_srgb_suffix(), format.remove_srgb_suffix()],
};
surface.configure(&device, &config);

Expand Down

0 comments on commit 80eef3b

Please sign in to comment.