mirror of
https://github.com/alacritty/alacritty
synced 2024-10-02 22:14:28 +00:00
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.
This commit is contained in:
parent
6b45780f3a
commit
38d20d0c39
|
@ -30,6 +30,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Tabstops not being reset with `reset`
|
- Tabstops not being reset with `reset`
|
||||||
- Selection not cleared when switching between main and alt grid
|
- Selection not cleared when switching between main and alt grid
|
||||||
- Fallback to `LC_CTYPE=UTF-8` on macOS without valid system locale
|
- Fallback to `LC_CTYPE=UTF-8` on macOS without valid system locale
|
||||||
|
- Resize lag on launch under some X11 wms
|
||||||
|
- Increased input latency due to vsync behavior on X11
|
||||||
|
|
||||||
## 0.4.2
|
## 0.4.2
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,8 @@ pub struct Display {
|
||||||
renderer: QuadRenderer,
|
renderer: QuadRenderer,
|
||||||
glyph_cache: GlyphCache,
|
glyph_cache: GlyphCache,
|
||||||
meter: Meter,
|
meter: Meter,
|
||||||
|
#[cfg(not(any(target_os = "macos", windows)))]
|
||||||
|
is_x11: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display {
|
impl Display {
|
||||||
|
@ -198,14 +200,20 @@ impl Display {
|
||||||
api.clear(background_color);
|
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
|
// We should call `clear` when window is offscreen, so when `window.show()` happens it
|
||||||
// would be with background color instead of uninitialized surface.
|
// would be with background color instead of uninitialized surface.
|
||||||
#[cfg(not(any(target_os = "macos", windows)))]
|
#[cfg(not(any(target_os = "macos", windows)))]
|
||||||
{
|
{
|
||||||
// On Wayland we can safely ignore this call, since the window isn't visible until you
|
// On Wayland we can safely ignore this call, since the window isn't visible until you
|
||||||
// actually draw something into it.
|
// actually draw something into it.
|
||||||
if event_loop.is_x11() {
|
if is_x11 {
|
||||||
window.swap_buffers()
|
window.swap_buffers();
|
||||||
|
renderer.with_api(&config, &size_info, |api| {
|
||||||
|
api.finish();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,6 +245,8 @@ impl Display {
|
||||||
size_info,
|
size_info,
|
||||||
urls: Urls::new(),
|
urls: Urls::new(),
|
||||||
highlighted_url: None,
|
highlighted_url: None,
|
||||||
|
#[cfg(not(any(target_os = "macos", windows)))]
|
||||||
|
is_x11,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -499,6 +509,18 @@ impl Display {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.window.swap_buffers();
|
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();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -923,6 +923,12 @@ impl<'a, C> RenderApi<'a, C> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn finish(&self) {
|
||||||
|
unsafe {
|
||||||
|
gl::Finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn render_batch(&mut self) {
|
fn render_batch(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
gl::BufferSubData(
|
gl::BufferSubData(
|
||||||
|
|
Loading…
Reference in a new issue