diff options
author | tcmal <me@aria.rip> | 2024-08-25 17:44:23 +0100 |
---|---|---|
committer | tcmal <me@aria.rip> | 2024-08-25 17:44:23 +0100 |
commit | 13d1d5214d7d7043f22dee0837fd6600aaa50797 (patch) | |
tree | d2adedb0c5a0986bab28855b10aa54e8575357d8 /stockton-render/src/queue_negotiator.rs | |
parent | 6ab13f2d0cb345795f761181a06777ade61ff09c (diff) |
refactor(all): various cleanup
Diffstat (limited to 'stockton-render/src/queue_negotiator.rs')
-rw-r--r-- | stockton-render/src/queue_negotiator.rs | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/stockton-render/src/queue_negotiator.rs b/stockton-render/src/queue_negotiator.rs index 65c7aa4..879a935 100644 --- a/stockton-render/src/queue_negotiator.rs +++ b/stockton-render/src/queue_negotiator.rs @@ -8,10 +8,12 @@ use std::{ sync::{Arc, RwLock}, }; +type SharedQueue = Arc<RwLock<QueueT>>; + /// Used to find appropriate queue families and share queues from them as needed. pub struct QueueNegotiator { family_ids: HashMap<TypeId, QueueFamilyId>, - already_allocated: HashMap<TypeId, (Vec<Arc<RwLock<QueueT>>>, usize)>, + already_allocated: HashMap<TypeId, (Vec<SharedQueue>, usize)>, all: Vec<QueueGroup>, } @@ -22,14 +24,6 @@ pub trait QueueFamilySelector: 'static { } impl QueueNegotiator { - pub fn new() -> Self { - QueueNegotiator { - family_ids: HashMap::new(), - already_allocated: HashMap::new(), - all: vec![], - } - } - pub fn find<T: QueueFamilySelector>(&mut self, adapter: &Adapter, filter: &T) -> Result<()> { if self.family_ids.contains_key(&TypeId::of::<T>()) { return Ok(()); @@ -113,7 +107,7 @@ impl QueueNegotiator { pub fn family_spec<'a, T: QueueFamilySelector>( &self, - queue_families: &'a Vec<QueueFamilyT>, + queue_families: &'a [QueueFamilyT], count: usize, ) -> Option<(&'a QueueFamilyT, Vec<f32>)> { let qf_id = self.family::<T>()?; @@ -125,6 +119,16 @@ impl QueueNegotiator { } } +impl Default for QueueNegotiator { + fn default() -> Self { + QueueNegotiator { + family_ids: HashMap::new(), + already_allocated: HashMap::new(), + all: vec![], + } + } +} + pub struct DrawQueue { pub surface: SurfaceT, } |