don't check if the buffer is still "present" from the user's perspective in LifetimeTracker.handle_mapping

This change doesn't change behavior as `Global.buffer_drop` already unmaps the buffer.
This commit is contained in:
teoxoy 2024-07-04 17:50:31 +02:00 committed by Teodor Tanasoaia
parent 3cc6c2743a
commit 3fba403060
2 changed files with 52 additions and 63 deletions

View File

@ -710,7 +710,6 @@ impl<A: HalApi> LifetimeTracker<A> {
pub(crate) fn handle_mapping( pub(crate) fn handle_mapping(
&mut self, &mut self,
raw: &A::Device, raw: &A::Device,
trackers: &Mutex<Tracker<A>>,
snatch_guard: &SnatchGuard, snatch_guard: &SnatchGuard,
) -> Vec<super::BufferMapPendingClosure> { ) -> Vec<super::BufferMapPendingClosure> {
if self.ready_to_map.is_empty() { if self.ready_to_map.is_empty() {
@ -721,14 +720,7 @@ impl<A: HalApi> LifetimeTracker<A> {
for buffer in self.ready_to_map.drain(..) { for buffer in self.ready_to_map.drain(..) {
let tracker_index = buffer.tracker_index(); let tracker_index = buffer.tracker_index();
let is_removed = {
let mut trackers = trackers.lock();
trackers.buffers.remove_abandoned(tracker_index)
};
if is_removed {
*buffer.map_state.lock() = resource::BufferMapState::Idle;
log::trace!("Buffer ready to map {tracker_index:?} is not tracked anymore");
} else {
// This _cannot_ be inlined into the match. If it is, the lock will be held // This _cannot_ be inlined into the match. If it is, the lock will be held
// open through the whole match, resulting in a deadlock when we try to re-lock // open through the whole match, resulting in a deadlock when we try to re-lock
// the buffer back to active. // the buffer back to active.
@ -763,8 +755,7 @@ impl<A: HalApi> LifetimeTracker<A> {
Ok(ptr) => { Ok(ptr) => {
*buffer.map_state.lock() = resource::BufferMapState::Active { *buffer.map_state.lock() = resource::BufferMapState::Active {
ptr, ptr,
range: pending_mapping.range.start range: pending_mapping.range.start..pending_mapping.range.start + size,
..pending_mapping.range.start + size,
host, host,
}; };
Ok(()) Ok(())
@ -784,7 +775,6 @@ impl<A: HalApi> LifetimeTracker<A> {
}; };
pending_callbacks.push((pending_mapping.op, status)); pending_callbacks.push((pending_mapping.op, status));
} }
}
pending_callbacks pending_callbacks
} }
} }

View File

@ -430,8 +430,7 @@ impl<A: HalApi> Device<A> {
life_tracker.triage_mapped(); life_tracker.triage_mapped();
let mapping_closures = let mapping_closures = life_tracker.handle_mapping(self.raw(), &snatch_guard);
life_tracker.handle_mapping(self.raw(), &self.trackers, &snatch_guard);
let queue_empty = life_tracker.queue_empty(); let queue_empty = life_tracker.queue_empty();