diff options
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, } |