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
impl VMAImage
pub fn destroy( &mut self, device: &Device, allocator: &mut Allocator ) -> Result<(), Error>
pub fn set_debug_object_name( &self, vk_init: &VkInit, base_name: String ) -> Result<(), Error>
sourcepub fn create_empty_image(
device: &Device,
allocator: &mut Allocator,
extent: Extent3D,
format: Format,
sizeof: usize,
aspect_mask: ImageAspectFlags
) -> Result<VMAImage, Error>
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)?;
pub fn create_depth_image( device: &Device, allocator: &mut Allocator, extent: Extent3D, format: Format, sizeof: usize ) -> Result<VMAImage, Error>
pub fn create_render_image( device: &Device, allocator: &mut Allocator, extent: Extent3D, format: Format, sizeof: usize ) -> Result<VMAImage, Error>
sourcepub fn set_staging_data<T>(&self, data: &[T]) -> Result<(), Error>
pub fn set_staging_data<T>(&self, data: &[T]) -> Result<(), Error>
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)?;
sourcepub fn enque_copy_from_staging_buffer_to_image(
&self,
device: &Device,
cmd_buffer: &CommandBuffer
)
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,
&[],
&[],
&[],
)?;
sourcepub fn get_image_layout_transition_barrier2(
&mut self,
dst_layout: ImageLayout,
src_queue: Option<u32>,
dst_queue: Option<u32>
) -> Result<ImageMemoryBarrier2, Error>
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§
impl RefUnwindSafe for VMAImage
impl Send for VMAImage
impl Sync for VMAImage
impl Unpin for VMAImage
impl UnwindSafe for VMAImage
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more