pub fn upload(
        &mut self,
        device: &wgpu::Device,
        encoder: &mut wgpu::CommandEncoder,
        data: &[T],
    ) {
        if data.is_empty() {
            self.len = 0;
            return;
        }

        if data.len() > self.capacity {
            self.buffer = device.create_buffer(&wgpu::BufferDescriptor {
                mapped_at_creation: false,
                label: None,
                size: (data.len() * std::mem::size_of::<T>()) as u64,
                usage: self.usage,
            });
            self.capacity = data.len();
        }

        let src_buffer = buffer_from_slice(
            device,
            wgpu::BufferUsage::COPY_SRC,
            to_u8_slice(data)
        );

        encoder.copy_buffer_to_buffer(
            &src_buffer,
            0,
            &self.buffer,
            0,
            (data.len() * std::mem::size_of::<T>()) as u64,
        );
        self.len = data.len();
    }
/// Update the data of the buffer, resizing if needed
Update the data of the buffer, resizing if needed
Update the data of the buffer resizing if needed
pub fn upload(
        &mut self,
        device: &wgpu::Device,
        encoder: &mut wgpu::CommandEncoder,
        data: &[T],
    ) {
        if data.is_empty() {
            self.len = 0;
            return;
        }
        if data.len() > self.capacity {
            self.buffer = device.create_buffer(&wgpu::BufferDescriptor {
                mapped_at_creation: false,
                label: None,
                size: (data.len() * std::mem::size_of::<T>()) as u64,
                usage: self.usage,
            });
            self.capacity = data.len();
        }
        let src_buffer = buffer_from_slice(
            device,
            wgpu::BufferUsage::COPY_SRC,
            to_u8_slice(data)
        );
        encoder.copy_buffer_to_buffer(
            &src_buffer,
            0,
            &self.buffer,
            0,
            (data.len() * std::mem::size_of::<T>()) as u64,
        );
        self.len = data.len();
    }
pub fn upload ( & mut self , device : & wgpu :: Device , encoder : & mut wgpu :: CommandEncoder , data : & [ T ] , ) { if data . is_empty ( ) { self . len = 0 ; return ; } if data . len ( ) > self . capacity { self . buffer = device . create_buffer ( & wgpu :: BufferDescriptor { mapped_at_creation : false , label : None , size : ( data . len ( ) * std :: mem :: size_of :: < T > ( ) ) as u64 , usage : self . usage , } ) ; self . capacity = data . len ( ) ; } let src_buffer = buffer_from_slice ( device , wgpu :: BufferUsage :: COPY_SRC , to_u8_slice ( data ) ) ; encoder . copy_buffer_to_buffer ( & src_buffer , 0 , & self . buffer , 0 , ( data . len ( ) * std :: mem :: size_of :: < T > ( ) ) as u64 , ) ; self . len = data . len ( ) ; }
Update the data of the buffer, resizing if needed
Update the data of the buffer resizing if needed
&mut self
device
&wgpu::Device
encoder
&mut wgpu::CommandEncoder
data
&[T]
&mut self
device
&wgpu::Device
encoder
&mut wgpu::CommandEncoder
data
&[T]