/// Loads data from a png image in `path` directly into a staging buffer
Loads data from a png image in `path` directly into a staging buffer
Loads data from a png image in ` path ` directly into a staging buffer
pub fn load(allocator: &Rc<RefCell<vk_mem::Allocator>>, png: &mut Png) -> Self {
        let size = png.info.buffer_size().max(32);
        let usage = ash::vk::BufferUsageFlags::TRANSFER_SRC;
        // Create staging buffer
        let (buffer, allocation) = Self::create_buffer(
            &allocator.deref().borrow(),
            size as ash::vk::DeviceSize,
            usage,
        );
        let alloc = allocator.deref().borrow();
        let data = alloc
            .map_memory(&allocation)
            .expect("Failed to map Vulkan memory");
        // Allocate the output buffer
        let mut buf = unsafe { std::slice::from_raw_parts_mut(data, size) };
        // Read the next frame. An APNG might contain multiple frames.
        png.reader.next_frame(&mut buf).unwrap();
        alloc.unmap_memory(&allocation);
        Self {
            allocation,
            buffer,
            usage,
            size: size as ash::vk::DeviceSize,
            allocator: allocator.clone(),
        }
    }
pub fn load ( allocator : & Rc < RefCell < vk_mem :: Allocator > > , png : & mut Png ) -> Self { let size = png . info . buffer_size ( ) . max ( 32 ) ; let usage = ash :: vk :: BufferUsageFlags :: TRANSFER_SRC ; // Create staging buffer let ( buffer , allocation ) = Self :: create_buffer ( & allocator . deref ( ) . borrow ( ) , size as ash :: vk :: DeviceSize , usage , ) ; let alloc = allocator . deref ( ) . borrow ( ) ; let data = alloc . map_memory ( & allocation ) . expect ( " " ) ; // Allocate the output buffer let mut buf = unsafe { std :: slice :: from_raw_parts_mut ( data , size ) } ; // Read the next frame. An APNG might contain multiple frames. png . reader . next_frame ( & mut buf ) . unwrap ( ) ; alloc . unmap_memory ( & allocation ) ; Self { allocation , buffer , usage , size : size as ash :: vk :: DeviceSize , allocator : allocator . clone ( ) , } }
Loads data from a png image in `path` directly into a staging buffer
Loads data from a png image in ` path ` directly into a staging buffer
allocator
&Rc<RefCell<vk_mem::Allocator>>
png
&mut Png