mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-20 14:31:08 +01:00
fix(core): Don't overlap QUEUE_PENDING_WRITES and QUEUE_LIFE_TRACKER locks
This commit is contained in:
1 parent
458d310916
commit
90dd7435e9
2 files changed
+31
-20
No files matched your search
@@ -220,7 +220,7 @@ impl Queue {
|
||||
};
|
||||
|
||||
self.submit_with_pending_writes(
|
||||
&mut pending_writes,
|
||||
pending_writes,
|
||||
Vec::new(),
|
||||
surface_textures,
|
||||
fence.as_mut(),
|
||||
@@ -1435,10 +1435,10 @@ impl Queue {
|
||||
}
|
||||
}
|
||||
|
||||
let mut pending_writes = self.pending_writes.lock();
|
||||
let pending_writes = self.pending_writes.lock();
|
||||
|
||||
if let Err(e) = self.submit_with_pending_writes(
|
||||
&mut pending_writes,
|
||||
pending_writes,
|
||||
active_executions,
|
||||
submit_surface_textures_owned,
|
||||
fence.as_mut(),
|
||||
@@ -1450,8 +1450,6 @@ impl Queue {
|
||||
|
||||
drop(command_index_guard);
|
||||
|
||||
drop(pending_writes);
|
||||
|
||||
profiling::scope!("cleanup");
|
||||
|
||||
// This will schedule destruction of all resources that are no longer needed
|
||||
@@ -1497,7 +1495,7 @@ impl Queue {
|
||||
/// Advances `last_successful_submission_index` and registers the submission with the lifetime tracker.
|
||||
fn submit_with_pending_writes(
|
||||
&self,
|
||||
pending_writes: &mut PendingWrites,
|
||||
mut pending_writes: MutexGuard<'_, PendingWrites>,
|
||||
mut active_executions: Vec<EncoderInFlight>,
|
||||
mut surface_textures: FastHashMap<*const Texture, Arc<Texture>>,
|
||||
fence: &mut dyn hal::DynFence,
|
||||
@@ -1578,6 +1576,9 @@ impl Queue {
|
||||
.last_successful_submission_index
|
||||
.fetch_max(submit_index, Ordering::SeqCst);
|
||||
}
|
||||
|
||||
drop(pending_writes);
|
||||
|
||||
// this will register the new submission to the life time tracker
|
||||
self.lock_life()
|
||||
.track_submission(submit_index, active_executions);
|
||||
|
||||
+24
-14
@@ -1019,18 +1019,23 @@ impl Buffer {
|
||||
})
|
||||
};
|
||||
|
||||
if let Some(queue) = device.get_queue() {
|
||||
let Some(queue) = device.get_queue() else {
|
||||
return;
|
||||
};
|
||||
|
||||
{
|
||||
let mut pending_writes = queue.pending_writes.lock();
|
||||
if pending_writes.contains_buffer(self) {
|
||||
pending_writes.consume_temp(temp);
|
||||
} else {
|
||||
let mut life_lock = queue.lock_life();
|
||||
let last_submit_index = life_lock.get_buffer_latest_submission_index(self);
|
||||
if let Some(last_submit_index) = last_submit_index {
|
||||
life_lock.schedule_resource_destruction(temp, last_submit_index);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let mut life_lock = queue.lock_life();
|
||||
let last_submit_index = life_lock.get_buffer_latest_submission_index(self);
|
||||
if let Some(last_submit_index) = last_submit_index {
|
||||
life_lock.schedule_resource_destruction(temp, last_submit_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1516,18 +1521,23 @@ impl Texture {
|
||||
})
|
||||
};
|
||||
|
||||
if let Some(queue) = device.get_queue() {
|
||||
let Some(queue) = device.get_queue() else {
|
||||
return;
|
||||
};
|
||||
|
||||
{
|
||||
let mut pending_writes = queue.pending_writes.lock();
|
||||
if pending_writes.contains_texture(self) {
|
||||
pending_writes.consume_temp(temp);
|
||||
} else {
|
||||
let mut life_lock = queue.lock_life();
|
||||
let last_submit_index = life_lock.get_texture_latest_submission_index(self);
|
||||
if let Some(last_submit_index) = last_submit_index {
|
||||
life_lock.schedule_resource_destruction(temp, last_submit_index);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let mut life_lock = queue.lock_life();
|
||||
let last_submit_index = life_lock.get_texture_latest_submission_index(self);
|
||||
if let Some(last_submit_index) = last_submit_index {
|
||||
life_lock.schedule_resource_destruction(temp, last_submit_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user