swapchain: Keep buffers on reset and wipe metadata

We make no guarantees about the buffer contents after a fresh allocation
in smithay anyway, so to avoid expensive recreation of a bunch of
resources, try to keep the buffers on reset and just wipe all its
metadata (most importantly the age).
This commit is contained in:
Victor Brekenfeld 2021-12-28 13:06:11 +01:00
parent 8536fa90a1
commit 64c535464a
1 changed files with 10 additions and 1 deletions

View File

@ -196,6 +196,15 @@ where
/// Remove all internally cached buffers to e.g. reset age values
pub fn reset_buffers(&mut self) {
self.slots = Default::default();
for slot in &mut self.slots {
if let Some(internal_slot) = Arc::get_mut(slot) {
*internal_slot = InternalSlot {
buffer: internal_slot.buffer.take(),
..Default::default()
};
} else {
*slot = Default::default();
}
}
}
}