1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-24 13:52:55 +03:00

egl: try all configs one by one in case first choice fails

It's not clear why the first choice isn't always the right choice
for some users.

This commit changes the logic to try all potential configs,
one after the other, until we find one that sticks.

I don't know if this will work in practice: I suspect that
trying to configure one of them may prevent later configs from
being used.

But maybe it will, and it may reveal more information about
what the real cause of the problem is.

refs: #272
This commit is contained in:
Wez Furlong 2020-10-13 19:18:29 -07:00
parent 0a39328e9d
commit baebc81432

View File

@ -239,7 +239,7 @@ impl EglWrapper {
.map(surface_bits),
};
log::info!("{:?}", info);
log::info!("{:x?}", info);
}
pub fn choose_config(
@ -498,27 +498,49 @@ impl GlState {
],
)?;
let first_config = *configs
.first()
.ok_or_else(|| anyhow!("no compatible EGL configuration was found"))?;
if configs.is_empty() {
anyhow::bail!("no compatible EGL configuration was found");
}
let mut errors = String::new();
for config in configs {
let surface =
connection
match connection
.egl
.create_window_surface(connection.display, first_config, window)?;
.create_window_surface(connection.display, config, window)
{
Ok(s) => s,
Err(e) => {
errors.push_str(&format!("{:#} {:x?}\n", e, config));
continue;
}
};
let context = connection.egl.create_context(
let context = match connection.egl.create_context(
connection.display,
first_config,
config,
std::ptr::null(),
&[ffi::CONTEXT_MAJOR_VERSION, 3, ffi::NONE],
)?;
) {
Ok(c) => c,
Err(e) => {
errors.push_str(&format!("{:#} {:x?}\n", e, config));
continue;
}
};
Ok(Self {
log::trace!(
"Successfully created a surface using configuration {:x?}",
config
);
return Ok(Self {
connection: Rc::clone(connection),
context,
surface,
})
});
}
Err(anyhow!(errors))
}
}