1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-24 22:01:47 +03:00

egl: look for exactly 8bpc configurations

When running on a 30bpp display with 2 bit alpha, eglChooseConfig
will match and list the 10bpc configuration first, which don't match
the desired pixel format.

Filter the config list so that it only includes 8bpc configurations.

refs: https://github.com/wez/wezterm/issues/240
This commit is contained in:
Wez Furlong 2020-07-11 13:23:30 -07:00
parent 44918364c0
commit 30f0e5b2c1

View File

@ -257,6 +257,20 @@ impl EglWrapper {
self.log_config_info(display, *c); self.log_config_info(display, *c);
} }
// If we're running on a system with 30bpp color depth then ChooseConfig
// will bias towards putting 10bpc matches first, but we want 8-bit.
// Let's filter out matches that are too deep
configs.retain(|config| {
self.config_attrib(display, *config, ffi::RED_SIZE) == Some(8)
&& self.config_attrib(display, *config, ffi::GREEN_SIZE) == Some(8)
&& self.config_attrib(display, *config, ffi::BLUE_SIZE) == Some(8)
});
log::info!("Filtered down to these configuration(s):");
for c in &configs {
self.log_config_info(display, *c);
}
Ok(configs) Ok(configs)
} }
@ -362,10 +376,21 @@ impl GlState {
let configs = egl.choose_config( let configs = egl.choose_config(
egl_display, egl_display,
&[ &[
// Request at least 8bpc, 24bpp. The implementation may // We're explicitly asking for any alpha size; this is
// return a context capable of more than this // the default behavior but we're making it explicit here
// for the sake of documenting our intent.
// In general we want 32bpp with 8bpc, but for displays
// that are natively 10bpc we should be fine with relaxing
// this to 0 alpha bits, so by asking for 0 here we effectively
// indicate that we don't care.
// In our implementation of choose_config we will return
// only entries with 8bpc for red/green/blue so we should
// end up with either 24bpp/8bpc with no alpha, or 32bpp/8bpc
// with 8bpc alpha.
ffi::ALPHA_SIZE, ffi::ALPHA_SIZE,
0, 0,
// Request at least 8bpc, 24bpp. The implementation may
// return a context capable of more than this.
ffi::RED_SIZE, ffi::RED_SIZE,
8, 8,
ffi::GREEN_SIZE, ffi::GREEN_SIZE,