aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src
diff options
context:
space:
mode:
authorRolf Sievert <26115145+RolfSievert@users.noreply.github.com>2023-09-04 22:15:46 +0200
committerGitHub <noreply@github.com>2023-09-04 20:15:46 +0000
commit8eed17227a2d1541c54abdb8498d69ba25ef0df6 (patch)
tree2286cea275dcca3b76f6dd6624c118b3b59571fb /alacritty/src
parent8d174429ee1e63e865a9203d7dfc4ce2cd25576d (diff)
downloadr-alacritty-8eed17227a2d1541c54abdb8498d69ba25ef0df6.tar.gz
r-alacritty-8eed17227a2d1541c54abdb8498d69ba25ef0df6.tar.bz2
r-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.
Diffstat (limited to 'alacritty/src')
-rw-r--r--alacritty/src/config/debug.rs4
-rw-r--r--alacritty/src/renderer/platform.rs13
-rw-r--r--alacritty/src/window_context.rs7
3 files changed, 20 insertions, 4 deletions
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))]