diff options
author | Rolf Sievert <26115145+RolfSievert@users.noreply.github.com> | 2023-09-04 22:15:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-04 20:15:46 +0000 |
commit | 8eed17227a2d1541c54abdb8498d69ba25ef0df6 (patch) | |
tree | 2286cea275dcca3b76f6dd6624c118b3b59571fb | |
parent | 8d174429ee1e63e865a9203d7dfc4ce2cd25576d (diff) | |
download | alacritty-8eed17227a2d1541c54abdb8498d69ba25ef0df6.tar.gz alacritty-8eed17227a2d1541c54abdb8498d69ba25ef0df6.zip |
Add `prefer_egl` debug option
Some systems have rendering issues when using GLX rather than EGL. While this is
usually due to a driver bug, it is helpful to provide a workaround for this by
allowing people to prefer EGL over GLX.
This patch adds the new `debug.prefer_egl` option to provide this workaround.
Closes #7056.
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | alacritty/src/config/debug.rs | 4 | ||||
-rw-r--r-- | alacritty/src/renderer/platform.rs | 13 | ||||
-rw-r--r-- | alacritty/src/window_context.rs | 7 | ||||
-rw-r--r-- | extra/man/alacritty.5.scd | 7 |
5 files changed, 28 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 776a7358..894c998e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Copy global IPC options (`-w -1`) for new windows - Bindings to create and navigate tabs on macOS - Support startup notify protocol to raise initial window on Wayland/X11 +- Debug option `prefer_egl` to prioritize EGL over other display APIs ### Changed diff --git a/alacritty/src/config/debug.rs b/alacritty/src/config/debug.rs index fe0c78f1..a8be77d9 100644 --- a/alacritty/src/config/debug.rs +++ b/alacritty/src/config/debug.rs @@ -23,6 +23,9 @@ pub struct Debug { /// The renderer alacritty should be using. pub renderer: Option<RendererPreference>, + /// Use EGL as display API if the current platform allows it. + pub prefer_egl: bool, + /// Record ref test. #[config(skip)] pub ref_test: bool, @@ -38,6 +41,7 @@ impl Default for Debug { highlight_damage: Default::default(), ref_test: Default::default(), renderer: Default::default(), + prefer_egl: Default::default(), } } } diff --git a/alacritty/src/renderer/platform.rs b/alacritty/src/renderer/platform.rs index 495e837e..b31e6974 100644 --- a/alacritty/src/renderer/platform.rs +++ b/alacritty/src/renderer/platform.rs @@ -21,15 +21,24 @@ use winit::window::raw_window_handle::{RawDisplayHandle, RawWindowHandle}; pub fn create_gl_display( raw_display_handle: RawDisplayHandle, _raw_window_handle: Option<RawWindowHandle>, + _prefer_egl: bool, ) -> GlutinResult<Display> { #[cfg(target_os = "macos")] let preference = DisplayApiPreference::Cgl; #[cfg(windows)] - let preference = DisplayApiPreference::Wgl(Some(_raw_window_handle.unwrap())); + let preference = if _prefer_egl { + DisplayApiPreference::EglThenWgl(Some(_raw_window_handle.unwrap())) + } else { + DisplayApiPreference::WglThenEgl(Some(_raw_window_handle.unwrap())) + }; #[cfg(all(feature = "x11", not(any(target_os = "macos", windows))))] - let preference = DisplayApiPreference::GlxThenEgl(Box::new(x11::register_xlib_error_hook)); + let preference = if _prefer_egl { + DisplayApiPreference::EglThenGlx(Box::new(x11::register_xlib_error_hook)) + } else { + DisplayApiPreference::GlxThenEgl(Box::new(x11::register_xlib_error_hook)) + }; #[cfg(all(not(feature = "x11"), not(any(target_os = "macos", windows))))] let preference = DisplayApiPreference::Egl; diff --git a/alacritty/src/window_context.rs b/alacritty/src/window_context.rs index 84ce4457..332bdcd9 100644 --- a/alacritty/src/window_context.rs +++ b/alacritty/src/window_context.rs @@ -92,8 +92,11 @@ impl WindowContext { #[cfg(not(windows))] let raw_window_handle = None; - let gl_display = - renderer::platform::create_gl_display(raw_display_handle, raw_window_handle)?; + let gl_display = renderer::platform::create_gl_display( + raw_display_handle, + raw_window_handle, + config.debug.prefer_egl, + )?; let gl_config = renderer::platform::pick_gl_config(&gl_display, raw_window_handle)?; #[cfg(not(windows))] diff --git a/extra/man/alacritty.5.scd b/extra/man/alacritty.5.scd index 8d44e019..bc2c04f1 100644 --- a/extra/man/alacritty.5.scd +++ b/extra/man/alacritty.5.scd @@ -935,6 +935,13 @@ relied upon. Default: _false_ +*prefer_egl* <boolean> + + Use EGL as display API if the current platform allows it. Note that + transparency may not work with EGL on Linux/BSD. + + Default: _false_ + # SEE ALSO *alacritty*(1), *alacritty-msg*(1), *alacritty-bindings*(5) |