wgpu: ensure that the srgb format is available before using it

refs: https://github.com/wez/wezterm/issues/3032
This commit is contained in:
Wez Furlong committed 2023-02-06 07:40:30 -07:00
1 parent 9945c04e8f
commit f031acfe43
1 file changed
+7 -2
+7 -2
View File
@@ -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);