From f3bccc7d0895b154ba8c7bc2aa1d189ff6bdfde1 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Thu, 1 Oct 2020 20:01:09 -0700 Subject: [PATCH] window: X/Wayland: Software frontend is now llvmpipe refs: https://github.com/wez/wezterm/issues/265#issuecomment-701882933 --- build.rs | 2 +- window/src/egl.rs | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/build.rs b/build.rs index baf98fbc9..ec85a5246 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,3 @@ -use anyhow::Context as _; use std::path::Path; use vergen::{generate_cargo_keys, ConstantsFlags}; @@ -68,6 +67,7 @@ fn main() { #[cfg(windows)] { + use anyhow::Context as _; use std::io::Write; let profile = std::env::var("PROFILE").unwrap(); let exe_output_dir = Path::new("target").join(profile); diff --git a/window/src/egl.rs b/window/src/egl.rs index 95a4a24ad..92c1cf256 100644 --- a/window/src/egl.rs +++ b/window/src/egl.rs @@ -1,3 +1,4 @@ +use crate::{is_swrast_preferred, prefer_swrast}; use anyhow::{anyhow, bail, ensure, Error}; use std::ffi::c_void; use std::rc::Rc; @@ -390,6 +391,11 @@ impl GlState { let mut errors = vec![]; for _ in 0..2 { + if is_swrast_preferred() { + // Assuming that we're using Mesa, set an environment + // variable that should select CPU based rendering. + std::env::set_var("LIBGL_ALWAYS_SOFTWARE", "true"); + } for path in &paths { if let Ok(lib) = libloading::Library::new(path) { match EglWrapper::load_egl(lib) { @@ -408,9 +414,8 @@ impl GlState { } } } - // If we're using Mesa, set some environment variables - // that should select CPU based rendering and try again - std::env::set_var("LIBGL_ALWAYS_SOFTWARE", "true"); + // Since we didn't yet succeed, try enabling software rasterization + prefer_swrast(); } bail!("with_egl_lib failed: {}", errors.join(", ")) }