/// Fill the buffer with the provided slice
Fill the buffer with the provided slice
Fill the buffer with the provided slice
pub fn copy_from_slice<T: Copy>(&self, data: &[T]) -> Result<(), Error> {
        let element_offset = 0;
        let element_count = data.len();
        let element_size = mem::size_of::<T>();
        let data_size = element_size * element_count;
        let buffer_size = self.inner.descriptor.size as usize;
        let offset_bytes = element_size * element_offset;
        self.validate_mapping::<T>(element_offset, element_count, BufferUsage::MAP_WRITE)?;
        log::trace!(
            "map write data_size: offset_bytes: {}, {}, buffer_size: {}",
            offset_bytes,
            data_size,
            buffer_size
        );
        unsafe {
            let dst_ptr = self.data.add(offset_bytes);
            ptr::copy_nonoverlapping(data.as_ptr() as *const u8, dst_ptr, data_size);
            self.inner
                .device
                .allocator
                .flush_allocation(&self.inner.allocation, offset_bytes, data_size);
        }
        Ok(())
    }
pub fn copy_from_slice < T : Copy > ( & self , data : & [ T ] ) -> Result < ( ) , Error > { let element_offset = 0 ; let element_count = data . len ( ) ; let element_size = mem :: size_of :: < T > ( ) ; let data_size = element_size * element_count ; let buffer_size = self . inner . descriptor . size as usize ; let offset_bytes = element_size * element_offset ; self . validate_mapping :: < T > ( element_offset , element_count , BufferUsage :: MAP_WRITE ) ? ; log :: trace ! ( " " offset_bytes data_size buffer_size ) ; unsafe { let dst_ptr = self . data . add ( offset_bytes ) ; ptr :: copy_nonoverlapping ( data . as_ptr ( ) as * const u8 , dst_ptr , data_size ) ; self . inner . device . allocator . flush_allocation ( & self . inner . allocation , offset_bytes , data_size ) ; } Ok ( ( ) ) }
Fill the buffer with the provided slice
Fill the buffer with the provided slice
&self
data
&[T]