Struct PhysicalDevice

Source
pub struct PhysicalDevice { /* private fields */ }
Expand description

A physical device abstracts away an actual device, like a graphics card or integrated graphics card. This struct stores its Vulkan handle, properties and requested queues.

Implementations§

Source§

impl PhysicalDevice

Source

pub fn select<Window: WindowInterface>( instance: &Instance, surface: Option<&Surface>, settings: &AppSettings<'_, Window>, ) -> Result<Self>

Selects the best available physical device from the given requirements and parameters.

Source

pub fn select_with_surface<Window: WindowInterface>( instance: &Instance, settings: &AppSettings<'_, Window>, ) -> Result<(Surface, Self)>

Selects the best available physical device and creates a surface on it.

Source

pub fn queue_families(&self) -> &[QueueFamilyProperties]

Get all queue families available on this device. This is different from Device::queue_families() since this knows about properties of each family, while the device function only knows about family indices.

Source

pub fn queues(&self) -> &[QueueInfo]

Get information on all requested queues.

§Example
fn list_queues(device: PhysicalDevice) {
    device.queues()
          .iter()
          .for_each(|info| {
                println!("Queue #{} supports {:#?} (dedicated = {}, can_present = {})", info.family_index, info.flags, info.dedicated, info.can_present);
          })
}
Source

pub unsafe fn handle(&self) -> PhysicalDevice

Get unsafe access to the physical device handle

§Safety

Any vulkan calls that mutate this physical device may leave the system in an undefined state.

Source

pub fn properties(&self) -> &PhysicalDeviceProperties

This is the same function as Device::properties()

Source

pub fn memory_properties(&self) -> &PhysicalDeviceMemoryProperties

Get the memory properties of this physical device, such as the different memory heaps available.

§Example
fn list_memory_heaps(device: PhysicalDevice) {
    let properties = device.memory_properties();
    for i in 0..properties.memory_heap_count {
        let heap = properties.memory_heaps[i as usize];
        println!("Heap #{i} has flags {:#?} and a size of {} bytes", heap.flags, heap.size);
    }
}

Trait Implementations§

Source§

impl Debug for PhysicalDevice

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PhysicalDevice

Source§

fn default() -> PhysicalDevice

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.