Struct vku::VMAImage

source ·
pub struct VMAImage {
    pub staging_buffer: VMABuffer,
    pub image: Image,
    pub extent: Extent3D,
    pub aspect_flags: ImageAspectFlags,
    pub image_view: ImageView,
    pub allocation: Allocation,
    pub current_layout: ImageLayout,
}
Expand description

Allocated image, image information, image view, allocation and allocation information.

Includes a host-visible staging buffer

Fields§

§staging_buffer: VMABuffer§image: Image§extent: Extent3D§aspect_flags: ImageAspectFlags§image_view: ImageView§allocation: Allocation§current_layout: ImageLayout

Implementations§

source§

impl VMAImage

source

pub fn destroy( &mut self, device: &Device, allocator: &mut Allocator ) -> Result<(), Error>

source

pub fn set_debug_object_name( &self, vk_init: &VkInit, base_name: String ) -> Result<(), Error>

source

pub fn create_empty_image( device: &Device, allocator: &mut Allocator, extent: Extent3D, format: Format, sizeof: usize, aspect_mask: ImageAspectFlags ) -> Result<VMAImage, Error>

Creates an empty image with specified format for transfer and sample operations.

let mut init = VkInit::new(Some(&window), Some(size), create_info)?;

let extent = Extent3D{width: 100, height: 100, depth: 1};
let format = Format::R8G8B8A8_UNORM;
let format_bytes = 4;
let aspect_flags = ImageAspectFlags::COLOR;

let image = init.create_empty_image(extent, format, format_bytes, aspect_flags)?;
source

pub fn create_depth_image( device: &Device, allocator: &mut Allocator, extent: Extent3D, format: Format, sizeof: usize ) -> Result<VMAImage, Error>

source

pub fn create_render_image( device: &Device, allocator: &mut Allocator, extent: Extent3D, format: Format, sizeof: usize ) -> Result<VMAImage, Error>

source

pub fn set_staging_data<T>(&self, data: &[T]) -> Result<(), Error>
where T: Sized + Copy + Clone,

Sets data for the staging buffer.

let extent = Extent3D{width: 100, height: 100, depth: 1};
let format = Format::R8G8B8A8_UNORM;
let format_bytes = 4;
let aspect_flags = ImageAspectFlags::COLOR;
let image = init.create_empty_image(extent, format, format_bytes, aspect_flags)?;
let data = [42_u32; 100*100];

image.set_staging_data(&data)?;
source

pub fn enque_copy_from_staging_buffer_to_image( &self, device: &Device, cmd_buffer: &CommandBuffer )

Enqueues cmd_copy_buffer_to_image from staging buffer to image.

No barriers are issued. Image needs to be in ImageLayout::TRANSFER_DST_OPTIMAL.

let mut image = init.create_empty_image(extent, format, format_bytes, aspect_flags)?;

let image_barrier = image.get_image_layout_transition_barrier2(
    ImageLayout::TRANSFER_DST_OPTIMAL,
    None,
    None,
    )?;

init.cmd_pipeline_barrier2(
    &setup_cmd_buffer,
    &[image_barrier],
    &[]
    );

let data = [42_u32; 100*100];
image.set_staging_data(&data)?;
image.enque_copy_from_staging_buffer_to_image(&init.device, &setup_cmd_buffer);

init.end_and_submit_cmd_buffer(
    &setup_cmd_buffer,
    CmdType::Any,
    &setup_fence,
    &[],
    &[],
    &[],    
)?;
source

pub fn get_image_layout_transition_barrier2( &mut self, dst_layout: ImageLayout, src_queue: Option<u32>, dst_queue: Option<u32> ) -> Result<ImageMemoryBarrier2, Error>

Gets appropriate ImageMemoryBarrier2 from current layout to dst_layout for this image.

Current layout is set to dst_layout after returning this barrier.

Defaults:

  • src_queue: 0
  • dst_queue: 0

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>,

§

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>,

§

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.