From 9e17e32686a142ba98408939adb5ee76a80d9fef Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Tue, 15 Oct 2024 13:16:24 +0200 Subject: [PATCH] extract `Queue.maintain` --- wgpu-core/src/device/queue.rs | 23 ++++++++++++++++++++++- wgpu-core/src/device/resource.rs | 10 +--------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/wgpu-core/src/device/queue.rs b/wgpu-core/src/device/queue.rs index afe763d77..c21395542 100644 --- a/wgpu-core/src/device/queue.rs +++ b/wgpu-core/src/device/queue.rs @@ -21,6 +21,7 @@ use crate::{ ParentDevice, ResourceErrorIdent, StagingBuffer, Texture, TextureInner, Trackable, }, resource_log, + snatch::SnatchGuard, track::{self, Tracker, TrackerIndex}, FastHashMap, SubmissionIndex, }; @@ -107,6 +108,26 @@ impl Queue { pub(crate) fn lock_life<'a>(&'a self) -> MutexGuard<'a, LifetimeTracker> { self.life_tracker.lock() } + + pub(crate) fn maintain( + &self, + submission_index: u64, + snatch_guard: &SnatchGuard, + ) -> ( + SmallVec<[SubmittedWorkDoneClosure; 1]>, + Vec, + 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); @@ -1505,7 +1526,7 @@ fn validate_command_buffer( command_buffer: &CommandBuffer, queue: &Queue, cmd_buf_data: &crate::command::CommandBufferMutable, - snatch_guard: &crate::snatch::SnatchGuard<'_>, + snatch_guard: &SnatchGuard, submit_surface_textures_owned: &mut FastHashMap<*const Texture, Arc>, used_surface_textures: &mut track::TextureUsageScope, ) -> Result<(), QueueSubmitError> { diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index 95274c4d0..2abc9ddaa 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -443,15 +443,7 @@ impl Device { let (submission_closures, mapping_closures, queue_empty) = if let Some(queue) = self.get_queue() { - let mut life_tracker = queue.lock_life(); - 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) + queue.maintain(submission_index, &snatch_guard) } else { (SmallVec::new(), Vec::new(), true) };