Skip to content

Commit 8f1373c

Browse files
committed
desktop: Prefer non-sRGB surface formats
1 parent 7d2e558 commit 8f1373c

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

desktop/src/gui/controller.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,23 @@ impl GuiController {
7575
adapter_info.name,
7676
adapter_info.device_type
7777
);
78-
let surface_format = surface
79-
.get_capabilities(&adapter)
80-
.formats
81-
.first()
82-
.cloned()
83-
.expect("At least one format should be supported");
78+
let preferred_formats = [
79+
// by egui
80+
wgpu::TextureFormat::Rgba8Unorm,
81+
wgpu::TextureFormat::Bgra8Unorm,
82+
];
83+
let supported_formats = surface.get_capabilities(&adapter).formats;
84+
let surface_format = preferred_formats
85+
.iter()
86+
.find(|format| supported_formats.contains(format))
87+
.copied()
88+
.unwrap_or_else(|| {
89+
supported_formats
90+
.first()
91+
.copied()
92+
.expect("At least one format should be supported")
93+
});
94+
tracing::info!("Using surface format {:?}", surface_format);
8495
let size = window.inner_size();
8596
surface.configure(
8697
&device,

0 commit comments

Comments
 (0)