aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Wilm <joe@jwilm.com>2017-02-14 21:33:57 -0800
committerJoe Wilm <jwilm@users.noreply.github.com>2017-02-15 10:03:46 -0800
commit62eb1e293898357ee46a9ba6c4e7cf87a6af1ea2 (patch)
tree0069a7015fc994e35454a023c7c6822efbba6eca
parentc49d4a936553135f6326e91e62445a5e04186a80 (diff)
downloadalacritty-62eb1e293898357ee46a9ba6c4e7cf87a6af1ea2.tar.gz
alacritty-62eb1e293898357ee46a9ba6c4e7cf87a6af1ea2.zip
Implement workaround for Mesa issue
This addresses the issue where systems running Mesa drivers would be an order of magnitude slower than other terminals. With this patch, performance is nearly as good as with proprietary drivers. There is one caveat where, since the cause of slowness hasn't been removed, there is less time available for rendering on Mesa systems. I've benchmarked this on my system (i5-3570 @ 3.4GHz, GTX 680) using `time find /usr` with the following results: * ~2.0 seconds average with proprietary driver * ~2.3 seconds average with Mesa driver cc #125
-rw-r--r--src/display.rs23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/display.rs b/src/display.rs
index 5946b33b..bdb5274c 100644
--- a/src/display.rs
+++ b/src/display.rs
@@ -202,6 +202,9 @@ impl Display {
// need to be in the callback.
let (tx, rx) = mpsc::channel();
+ // Clear screen
+ renderer.with_api(config, &size_info, 0. /* visual bell intensity */, |api| api.clear());
+
let mut display = Display {
window: window,
renderer: renderer,
@@ -276,10 +279,11 @@ impl Display {
self.window.set_title(&title);
}
+ let size_info = *terminal.size_info();
+ let visual_bell_intensity = terminal.visual_bell.intensity();
+
{
let glyph_cache = &mut self.glyph_cache;
- let size_info = *terminal.size_info();
- let visual_bell_intensity = terminal.visual_bell.intensity();
// Draw grid
{
@@ -291,8 +295,6 @@ impl Display {
// TODO I wonder if the renderable cells iter could avoid the
// mutable borrow
self.renderer.with_api(config, &size_info, visual_bell_intensity, |mut api| {
- api.clear();
-
// Draw the grid
api.render_cells(terminal.renderable_cells(config, selection), glyph_cache);
});
@@ -313,5 +315,18 @@ impl Display {
self.window
.swap_buffers()
.expect("swap buffers");
+
+ // Clear after swap_buffers when terminal mutex isn't held. Mesa for
+ // some reason takes a long time to call glClear(). The driver descends
+ // into xcb_connect_to_fd() which ends up calling __poll_nocancel()
+ // which blocks for a while.
+ //
+ // By keeping this outside of the critical region, the Mesa bug is
+ // worked around to some extent. Since this doesn't actually address the
+ // issue of glClear being slow, less time is available for input
+ // handling and rendering.
+ self.renderer.with_api(config, &size_info, visual_bell_intensity, |api| {
+ api.clear();
+ });
}
}