pub fn create(self, cx: &Context) -> Texture {
        let texture = cx.device.create_texture(&wgpu::TextureDescriptor {
            label: None,
            size: wgpu::Extent3d {
                width: self.width,
                height: self.height,
                depth_or_array_layers: 1,
            },
            mip_level_count: 1,
            sample_count: 1,
            dimension: wgpu::TextureDimension::D2,
            format: self.format,
            usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST,
        });

        let view = texture.create_view(&wgpu::TextureViewDescriptor::default());

        cx.queue.write_texture(
            texture.as_image_copy(),
            self.pixels.as_ref(),
            wgpu::ImageDataLayout {
                offset: 0,
                bytes_per_row: Some(
                    NonZeroU32::new(self.format.describe().block_size as u32 * self.width).unwrap(),
                ),
                rows_per_image: None,
            },
            wgpu::Extent3d {
                width: self.width,
                height: self.height,
                depth_or_array_layers: 1,
            },
        );

        Texture::new(Arc::new(texture), Arc::new(view))
    }
/// Creates a new [Texture] from the stored image texture.
Creates a new [Texture] from the stored image texture.
Creates a new [ Texture ] from the stored image texture .
pub fn create(self, cx: &Context) -> Texture {
        let texture = cx.device.create_texture(&wgpu::TextureDescriptor {
            label: None,
            size: wgpu::Extent3d {
                width: self.width,
                height: self.height,
                depth_or_array_layers: 1,
            },
            mip_level_count: 1,
            sample_count: 1,
            dimension: wgpu::TextureDimension::D2,
            format: self.format,
            usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST,
        });
        let view = texture.create_view(&wgpu::TextureViewDescriptor::default());
        cx.queue.write_texture(
            texture.as_image_copy(),
            self.pixels.as_ref(),
            wgpu::ImageDataLayout {
                offset: 0,
                bytes_per_row: Some(
                    NonZeroU32::new(self.format.describe().block_size as u32 * self.width).unwrap(),
                ),
                rows_per_image: None,
            },
            wgpu::Extent3d {
                width: self.width,
                height: self.height,
                depth_or_array_layers: 1,
            },
        );
        Texture::new(Arc::new(texture), Arc::new(view))
    }
pub fn create ( self , cx : & Context ) -> Texture { let texture = cx . device . create_texture ( & wgpu :: TextureDescriptor { label : None , size : wgpu :: Extent3d { width : self . width , height : self . height , depth_or_array_layers : 1 , } , mip_level_count : 1 , sample_count : 1 , dimension : wgpu :: TextureDimension :: D2 , format : self . format , usage : wgpu :: TextureUsages :: TEXTURE_BINDING | wgpu :: TextureUsages :: COPY_DST , } ) ; let view = texture . create_view ( & wgpu :: TextureViewDescriptor :: default ( ) ) ; cx . queue . write_texture ( texture . as_image_copy ( ) , self . pixels . as_ref ( ) , wgpu :: ImageDataLayout { offset : 0 , bytes_per_row : Some ( NonZeroU32 :: new ( self . format . describe ( ) . block_size as u32 * self . width ) . unwrap ( ) , ) , rows_per_image : None , } , wgpu :: Extent3d { width : self . width , height : self . height , depth_or_array_layers : 1 , } , ) ; Texture :: new ( Arc :: new ( texture ) , Arc :: new ( view ) ) }
Creates a new [Texture] from the stored image texture.
Creates a new [ Texture ] from the stored image texture .
self
cx
&Context
self
cx
&Context