Struct ccthw_ash_instance::QueueFamilyInfo
source · pub struct QueueFamilyInfo { /* private fields */ }
Expand description
The logical device constructor uses an array of these structs to build the Vulkan DeviceQueueCreateInfo structs.
It’s convenient to use this wrapper instead of the raw DeviceQueueCreateInfo structs because the raw structs include a pointer to an array of priorities. It can be unwieldy to handle the raw pointer without introducing memory safety problems, so this struct owns a vector of priority values.
Examples
use ccthw_ash_instance::QueueFamilyInfo;
let mut queue_family_info = QueueFamilyInfo::new(2);
queue_family_info.add_queue_priority(1.0);
// NOTE - create_info is only valid while QueueFamilyInfo exists and no
// additional calls to add_queue_priority are made.
let create_info = unsafe { queue_family_info.as_queue_create_info() };
println!("{:#?}", create_info);
Implementations§
source§impl QueueFamilyInfo
impl QueueFamilyInfo
sourcepub fn new(queue_family_index: u32) -> Self
pub fn new(queue_family_index: u32) -> Self
Create a new instance with no queue priorities.
Params
queue_family_index
- index for the underlying queue family. This comes from enumerating the physical devices queue family properties.
sourcepub fn add_queue_priority(&mut self, priority: f32)
pub fn add_queue_priority(&mut self, priority: f32)
Add a queue with the given priority.
Params
priority
- should be between 0.0 and 1.0. Implementations are allowed to give more resources to higher-priority queues, but it isn’t required. If you don’t have a good reason to do otherwise, 1.0 is a reasonable choice.
sourcepub unsafe fn as_queue_create_info(&self) -> DeviceQueueCreateInfo
pub unsafe fn as_queue_create_info(&self) -> DeviceQueueCreateInfo
Get a DeviceQueueCreateInfo struct based on the number of queue priorities specified for this queue family.
Safety
Unsafe because the device queue create info struct contains a pointer to the queue_priorities vector. This means that if any queue priorities are added AFTER calling this function, then using the struct will cause undefined behavior.
Trait Implementations§
source§impl Clone for QueueFamilyInfo
impl Clone for QueueFamilyInfo
source§fn clone(&self) -> QueueFamilyInfo
fn clone(&self) -> QueueFamilyInfo
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more