Struct VulkanRenderContext

Source
pub struct VulkanRenderContext<'a> {
    pub device: &'a Device,
    pub queue: Queue,
    pub queue_family_index: u32,
    pub command_pool: CommandPool,
    pub memory_properties: Option<&'a PhysicalDeviceMemoryProperties>,
}
Expand description

Borrowed Vulkan objects supplied by the host runtime.

The renderer never creates a session or owns the presented images. The host is responsible for frame lifecycle and passes the active Vulkan device/queue objects here.

§Examples

use ailloli_ui_render_vulkan::VulkanRenderContext;
use ash::vk;

fn borrow_host<'a>(
    device: &'a ash::Device,
    queue: vk::Queue,
    family: u32,
    pool: vk::CommandPool,
) -> VulkanRenderContext<'a> {
    VulkanRenderContext::new(device, queue, family, pool)
}

Fields§

§device: &'a Device

Logical device used to create and destroy renderer-owned resources.

§queue: Queue

Host queue used for renderer submissions.

§queue_family_index: u32

Index of the family owning Self::queue.

§command_pool: CommandPool

Host command pool used for transient frame command buffers.

§memory_properties: Option<&'a PhysicalDeviceMemoryProperties>

Physical-device memory types; required by rendering paths that allocate resources.

Implementations§

Source§

impl<'a> VulkanRenderContext<'a>

Constructors for borrowed host contexts.

Source

pub fn new( device: &'a Device, queue: Queue, queue_family_index: u32, command_pool: CommandPool, ) -> Self

Borrows device/queue objects without memory properties.

This form is suitable only until a path needs buffer or image allocation; VulkanRenderer::new then returns VulkanRendererError::MissingMemoryProperties.

§Examples
use ailloli_ui_render_vulkan::VulkanRenderContext;
use ash::vk;
fn make<'a>(device: &'a ash::Device, queue: vk::Queue, pool: vk::CommandPool) {
    let context = VulkanRenderContext::new(device, queue, 2, pool);
    assert_eq!(context.queue_family_index, 2);
    assert!(context.memory_properties.is_none());
}
Source

pub fn with_memory_properties( device: &'a Device, queue: Queue, queue_family_index: u32, command_pool: CommandPool, memory_properties: &'a PhysicalDeviceMemoryProperties, ) -> Self

Borrows device/queue objects and physical-device memory properties.

§Examples
use ailloli_ui_render_vulkan::VulkanRenderContext;
use ash::vk;
fn make<'a>(
    device: &'a ash::Device,
    queue: vk::Queue,
    pool: vk::CommandPool,
    memory: &'a vk::PhysicalDeviceMemoryProperties,
) {
    let context = VulkanRenderContext::with_memory_properties(device, queue, 2, pool, memory);
    assert!(context.memory_properties.is_some());
}

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> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> ErasedDestructor for T
where T: 'static,