From 80eef3bc2fbe4495a83948a031860cf2669a4dd9 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Mon, 6 Feb 2023 07:40:30 -0700 Subject: [PATCH] wgpu: ensure that the srgb format is available before using it refs: https://github.com/wez/wezterm/issues/3032 --- wezterm-gui/src/termwindow/webgpu.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wezterm-gui/src/termwindow/webgpu.rs b/wezterm-gui/src/termwindow/webgpu.rs index 35423dcb7031..43143dea4bc1 100644 --- a/wezterm-gui/src/termwindow/webgpu.rs +++ b/wezterm-gui/src/termwindow/webgpu.rs @@ -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, @@ -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);