pub fn create<T, D>(mut self, size: D, data: &[T]) -> crate::Texture<D>
    where
        T: bytemuck::Pod,
        D: crate::TextureDimensions,
    {
        self.texture.usage |= wgpu::TextureUsages::COPY_DST;
        self.texture.size = size.as_extent();
        self.texture.dimension = size.dim();

        let texture = self.gpu.device.create_texture(&self.texture);
        let view = texture.create_view(&self.view);

        self.gpu.queue.write_texture(
            texture.as_image_copy(),
            bytemuck::cast_slice(data),
            wgpu::ImageDataLayout {
                offset: 0,
                bytes_per_row: NonZeroU32::new(
                    self.texture.format.describe().block_size as u32 * size.width(),
                ),
                rows_per_image: NonZeroU32::new(size.height()),
            },
            self.texture.size,
        );

        crate::Texture {
            gpu: self.gpu,
            inner: texture,
            view,
            format: self.texture.format,
            size,
            usage: self.texture.usage,
        }
    }
/// Create the buffer with the given data as its contents.
/// Implicitly adds the `COPY_DST` usage if it is not present in the descriptor,
/// as it is required to be able to upload the data to the gpu.
Create the buffer with the given data as its contents.
Implicitly adds the `COPY_DST` usage if it is not present in the descriptor,
as it is required to be able to upload the data to the gpu.
Create the buffer with the given data as its contents . Implicitly adds the ` COPY_DST ` usage if it is not present in the descriptor as it is required to be able to upload the data to the gpu .
pub fn create<T, D>(mut self, size: D, data: &[T]) -> crate::Texture<D>
    where
        T: bytemuck::Pod,
        D: crate::TextureDimensions,
    {
        self.texture.usage |= wgpu::TextureUsages::COPY_DST;
        self.texture.size = size.as_extent();
        self.texture.dimension = size.dim();
        let texture = self.gpu.device.create_texture(&self.texture);
        let view = texture.create_view(&self.view);
        self.gpu.queue.write_texture(
            texture.as_image_copy(),
            bytemuck::cast_slice(data),
            wgpu::ImageDataLayout {
                offset: 0,
                bytes_per_row: NonZeroU32::new(
                    self.texture.format.describe().block_size as u32 * size.width(),
                ),
                rows_per_image: NonZeroU32::new(size.height()),
            },
            self.texture.size,
        );
        crate::Texture {
            gpu: self.gpu,
            inner: texture,
            view,
            format: self.texture.format,
            size,
            usage: self.texture.usage,
        }
    }
pub fn create < T , D > ( mut self , size : D , data : & [ T ] ) -> crate :: Texture < D > where T : bytemuck :: Pod , D : crate :: TextureDimensions , { self . texture . usage |= wgpu :: TextureUsages :: COPY_DST ; self . texture . size = size . as_extent ( ) ; self . texture . dimension = size . dim ( ) ; let texture = self . gpu . device . create_texture ( & self . texture ) ; let view = texture . create_view ( & self . view ) ; self . gpu . queue . write_texture ( texture . as_image_copy ( ) , bytemuck :: cast_slice ( data ) , wgpu :: ImageDataLayout { offset : 0 , bytes_per_row : NonZeroU32 :: new ( self . texture . format . describe ( ) . block_size as u32 * size . width ( ) , ) , rows_per_image : NonZeroU32 :: new ( size . height ( ) ) , } , self . texture . size , ) ; crate :: Texture { gpu : self . gpu , inner : texture , view , format : self . texture . format , size , usage : self . texture . usage , } }
Create the buffer with the given data as its contents.
Create the buffer with the given data as its contents .
mut self
size
D
data
&[T]
mut self
size
D
data
&[T]