diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2021-07-15 17:19:31 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2021-07-15 17:19:31 +0000 |
| commit | a486851bdd6bbf2fee9a5009c30770f22ca102ed (patch) | |
| tree | 6b644cb3ff068f7b8f1f86337ba71b4471794abf | |
| parent | wayland: win_destroy: unmap URL labels (diff) | |
shm: auto-purge when we have multiple buffers eligible for re-use
It may happen that we end up with multiple non-busy, same-sized
buffers for the same cookie (context), and thus eligible for re-use.
Before this patch, we would keep all those buffers around. This is
completely unnecessary. Under normal circumstances, we’ll either be
re-using a single buffer, or swap between two. In the second case, the
“other” buffer is always busy, and thus not eligible for re-use.
So, if we _do_ detect multiple, re-usable buffers, pick the one with
the lowest “age” (increasing the chance of applying damage tracking,
instead of re-drawing everything), and mark the other one for purging.
| -rw-r--r-- | shm.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -494,6 +494,15 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie, it->item.scroll_damage = NULL; xassert(it->item.pix_instances == pix_instances); cached = &it->item; + } else { + /* We have multiple buffers eligable for + * re-use. Pick the “youngest” one, and mark the + * other one for purging */ + if (it->item.age < cached->age) { + cached->purge = true; + cached = &it->item; + } else + it->item.purge = true; } } } |
