diff options
author | tcmal <me@aria.rip> | 2024-08-25 17:44:24 +0100 |
---|---|---|
committer | tcmal <me@aria.rip> | 2024-08-25 17:44:24 +0100 |
commit | 5e6396ed225be9a9991705de10174b3cf085f8f0 (patch) | |
tree | 90486e8fa38013a682cde84b3b1cb74fe097d704 /stockton-skeleton/src/context.rs | |
parent | 59b5e4463d6eec0de27d6da6c85f8c719674e966 (diff) |
refactor(skeleton): type phases of queue negotiation
Diffstat (limited to 'stockton-skeleton/src/context.rs')
-rw-r--r-- | stockton-skeleton/src/context.rs | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/stockton-skeleton/src/context.rs b/stockton-skeleton/src/context.rs index 348ddbd..bef9f9d 100644 --- a/stockton-skeleton/src/context.rs +++ b/stockton-skeleton/src/context.rs @@ -31,6 +31,7 @@ use crate::{ draw_passes::Singular, error::{EnvironmentError, LockPoisoned}, mem::MemoryPool, + queue_negotiator::QueueFamilyNegotiator, types::*, }; @@ -95,25 +96,18 @@ impl RenderingContext { let adapter = adapters.remove(0); // Queue Negotiator - let mut queue_families_specs = Vec::new(); - let (mut queue_negotiator, surface) = { + let (queue_negotiator, surface) = { let dq: DrawQueue = DrawQueue { surface }; - let mut qn = QueueNegotiator::default(); + let mut qn = QueueFamilyNegotiator::new(); // Draw Queue - qn.find(&adapter, &dq) + qn.find(&adapter, &dq, 1) .context("Couldn't find draw queue family")?; - queue_families_specs.push( - qn.family_spec::<DrawQueue>(&adapter.queue_families, 1) - .context("Couldn't find draw queue family")?, - ); // Auxiliary queues for DP - queue_families_specs.extend( - IDP::find_aux_queues(&adapter, &mut qn) - .context("Level pass couldn't populate queue negotiator")?, - ); + IDP::find_aux_queues(&adapter, &mut qn) + .context("Level pass couldn't populate queue family negotiator")?; (qn, dq.surface) }; @@ -123,30 +117,19 @@ impl RenderingContext { // TODO: This sucks, but hal is restrictive on how we can pass this specific argument. // Deduplicate families & convert to specific type. - let mut queue_families_specs_real = Vec::with_capacity(queue_families_specs.len()); - for (qf, ns) in queue_families_specs.iter_mut() { - if let Some(existing_family_spec) = queue_families_specs_real - .iter() - .position(|(qf2, _): &(&QueueFamilyT, &[f32])| qf2.id() == qf.id()) - { - ns.extend(queue_families_specs_real[existing_family_spec].1.iter()); - queue_families_specs_real[existing_family_spec] = (*qf, ns.as_slice()); - } else { - queue_families_specs_real.push((*qf, ns.as_slice())) - } - } + let open_spec = queue_negotiator.get_open_spec(&adapter); let gpu = unsafe { adapter .physical_device - .open(queue_families_specs_real.as_slice(), hal::Features::empty()) + .open(&open_spec.as_vec(), hal::Features::empty()) .context("Error opening logical device")? }; (Arc::new(RwLock::new(gpu.device)), gpu.queue_groups) }; - queue_negotiator.set_queue_groups(queue_groups); + let mut queue_negotiator = queue_negotiator.finish(queue_groups); // Context properties let properties = ContextProperties::find_best(&adapter, &surface) |