extract Queue.maintain

This commit is contained in:
teoxoy 2024-10-15 13:16:24 +02:00 committed by Teodor Tanasoaia
parent 5061ae3e5e
commit 9e17e32686
2 changed files with 23 additions and 10 deletions

View File

@ -21,6 +21,7 @@ use crate::{
ParentDevice, ResourceErrorIdent, StagingBuffer, Texture, TextureInner, Trackable, ParentDevice, ResourceErrorIdent, StagingBuffer, Texture, TextureInner, Trackable,
}, },
resource_log, resource_log,
snatch::SnatchGuard,
track::{self, Tracker, TrackerIndex}, track::{self, Tracker, TrackerIndex},
FastHashMap, SubmissionIndex, FastHashMap, SubmissionIndex,
}; };
@ -107,6 +108,26 @@ impl Queue {
pub(crate) fn lock_life<'a>(&'a self) -> MutexGuard<'a, LifetimeTracker> { pub(crate) fn lock_life<'a>(&'a self) -> MutexGuard<'a, LifetimeTracker> {
self.life_tracker.lock() self.life_tracker.lock()
} }
pub(crate) fn maintain(
&self,
submission_index: u64,
snatch_guard: &SnatchGuard,
) -> (
SmallVec<[SubmittedWorkDoneClosure; 1]>,
Vec<super::BufferMapPendingClosure>,
bool,
) {
let mut life_tracker = self.lock_life();
let submission_closures =
life_tracker.triage_submissions(submission_index, &self.device.command_allocator);
let mapping_closures = life_tracker.handle_mapping(snatch_guard);
let queue_empty = life_tracker.queue_empty();
(submission_closures, mapping_closures, queue_empty)
}
} }
crate::impl_resource_type!(Queue); crate::impl_resource_type!(Queue);
@ -1505,7 +1526,7 @@ fn validate_command_buffer(
command_buffer: &CommandBuffer, command_buffer: &CommandBuffer,
queue: &Queue, queue: &Queue,
cmd_buf_data: &crate::command::CommandBufferMutable, cmd_buf_data: &crate::command::CommandBufferMutable,
snatch_guard: &crate::snatch::SnatchGuard<'_>, snatch_guard: &SnatchGuard,
submit_surface_textures_owned: &mut FastHashMap<*const Texture, Arc<Texture>>, submit_surface_textures_owned: &mut FastHashMap<*const Texture, Arc<Texture>>,
used_surface_textures: &mut track::TextureUsageScope, used_surface_textures: &mut track::TextureUsageScope,
) -> Result<(), QueueSubmitError> { ) -> Result<(), QueueSubmitError> {

View File

@ -443,15 +443,7 @@ impl Device {
let (submission_closures, mapping_closures, queue_empty) = let (submission_closures, mapping_closures, queue_empty) =
if let Some(queue) = self.get_queue() { if let Some(queue) = self.get_queue() {
let mut life_tracker = queue.lock_life(); queue.maintain(submission_index, &snatch_guard)
let submission_closures =
life_tracker.triage_submissions(submission_index, &self.command_allocator);
let mapping_closures = life_tracker.handle_mapping(&snatch_guard);
let queue_empty = life_tracker.queue_empty();
(submission_closures, mapping_closures, queue_empty)
} else { } else {
(SmallVec::new(), Vec::new(), true) (SmallVec::new(), Vec::new(), true)
}; };