swapchain: Do not increase the age of 0-age slots

Slots with an age of 0 were never rendered to. This means
we should not increase their age, when others are submitted
or the renderer might wrongfully assume usuable contents are
available in the buffer.
This commit is contained in:
Victor Brekenfeld 2021-11-28 01:17:38 +01:00
parent a8bc2f4a50
commit 485aa2a9c7
1 changed files with 11 additions and 2 deletions

View File

@ -166,8 +166,17 @@ where
slot.0.age.store(1, Ordering::SeqCst);
for other_slot in &self.slots {
if !Arc::ptr_eq(other_slot, &slot.0) {
other_slot.age.fetch_add(1, Ordering::SeqCst);
if !Arc::ptr_eq(other_slot, &slot.0) && other_slot.buffer.is_some() {
assert!(other_slot
.age
.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |age| {
if age > 0 {
Some(age + 1)
} else {
Some(0)
}
})
.is_ok());
}
}
}