diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2020-05-01 23:57:25 +0300 |
---|---|---|
committer | Christian Duerr <contact@christianduerr.com> | 2020-05-26 00:02:20 +0000 |
commit | a78e6c9cabd21a7d72051e4302522698416b9602 (patch) | |
tree | b83d660022216ca4cba1973a9dccd2ed2e6c6c09 | |
parent | ef5118e23decf5636395c45e42bdaf071942dba7 (diff) | |
download | alacritty-a78e6c9cabd21a7d72051e4302522698416b9602.tar.gz alacritty-a78e6c9cabd21a7d72051e4302522698416b9602.zip |
Call glFinish right after swap_buffers on X11
On X11 `swap_buffers` does not block for vsync. However the next OpenGl command
will block to synchronize (this is `glClear` in Alacritty), which causes a
permanent one frame delay.
Calling `glFinish` after swapping buffers forces Alacritty to finish the buffer
swap before returning control to the event loop.
Fixes #3061.
-rw-r--r-- | CHANGELOG.md | 8 | ||||
-rw-r--r-- | alacritty/src/display.rs | 26 | ||||
-rw-r--r-- | alacritty/src/renderer/mod.rs | 6 |
3 files changed, 38 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 321c3b92..878cf514 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Tabstops not being reset with `reset` - Selection not cleared when switching between main and alt grid - Fallback to `LC_CTYPE=UTF-8` on macOS without valid system locale +- Emoji colors blending with terminal background +- Fix escapes prematurely terminated by terminators in unicode glyphs +- Incorrect location when clicking inside an unfocused window on macOS +- Startup mode `Maximized` on Windows +- Crash when writing a fullwidth character in the last column with auto-wrap mode disabled +- Crashing at startup on Windows +- Resize lag on launch under some X11 wms +- Increased input latency due to vsync behavior on X11 ## 0.4.2 ### Fixed diff --git a/alacritty/src/display.rs b/alacritty/src/display.rs index 317c8758..0bac731f 100644 --- a/alacritty/src/display.rs +++ b/alacritty/src/display.rs @@ -118,6 +118,8 @@ pub struct Display { renderer: QuadRenderer, glyph_cache: GlyphCache, meter: Meter, + #[cfg(not(any(target_os = "macos", windows)))] + is_x11: bool, } impl Display { @@ -198,14 +200,20 @@ impl Display { api.clear(background_color); }); + #[cfg(not(any(target_os = "macos", windows)))] + let is_x11 = event_loop.is_x11(); + // We should call `clear` when window is offscreen, so when `window.show()` happens it // would be with background color instead of uninitialized surface. #[cfg(not(any(target_os = "macos", windows)))] { // On Wayland we can safely ignore this call, since the window isn't visible until you // actually draw something into it. - if event_loop.is_x11() { - window.swap_buffers() + if is_x11 { + window.swap_buffers(); + renderer.with_api(&config, &size_info, |api| { + api.finish(); + }); } } @@ -237,6 +245,8 @@ impl Display { size_info, urls: Urls::new(), highlighted_url: None, + #[cfg(not(any(target_os = "macos", windows)))] + is_x11, }) } @@ -475,6 +485,18 @@ impl Display { } self.window.swap_buffers(); + + #[cfg(not(any(target_os = "macos", windows)))] + { + if self.is_x11 { + // On X11 `swap_buffers` does not block for vsync. However the next OpenGl command + // will block to synchronize (this is `glClear` in Alacritty), which causes a + // permanent one frame delay. + self.renderer.with_api(&config, &size_info, |api| { + api.finish(); + }); + } + } } } diff --git a/alacritty/src/renderer/mod.rs b/alacritty/src/renderer/mod.rs index a099b0de..0328d982 100644 --- a/alacritty/src/renderer/mod.rs +++ b/alacritty/src/renderer/mod.rs @@ -917,6 +917,12 @@ impl<'a, C> RenderApi<'a, C> { } } + pub fn finish(&self) { + unsafe { + gl::Finish(); + } + } + fn render_batch(&mut self) { unsafe { gl::BufferSubData( |