pub fn resize_with_copy(&mut self, size: D) {
        let new_usage = self.usage | wgpu::TextureUsages::COPY_DST;

        let new_texture = self.gpu.create_texture(&wgpu::TextureDescriptor {
            // TODO: update label for texture on resize
            label: None,
            size: size.as_extent(),
            // TODO: mip level count on resize??
            mip_level_count: 1,
            sample_count: 1,
            dimension: size.dim(),
            format: self.format,
            usage: new_usage,
        });

        // Don't copy depth buffer! (InvalidDepthTextureExtent)
        match self.format {
            wgpu::TextureFormat::Depth32Float
            | wgpu::TextureFormat::Depth24Plus
            | wgpu::TextureFormat::Depth24PlusStencil8 => {}
            _ => {
                let mut enc = self.gpu.create_command_encoder("Texture resize encoder");
                enc.copy_texture_to_texture(
                    self.inner.as_image_copy(),
                    new_texture.as_image_copy(),
                    self.size.as_extent(),
                );
                self.gpu.queue.submit([enc.finish()]);
            }
        }

        // Create a new view
        let view = new_texture.create_view(&Default::default());

        self.inner = new_texture;
        self.size = size;
        self.usage = new_usage;
        self.view = view;
    }
/// Resize the texture and copy the contents
Resize the texture and copy the contents
Resize the texture and copy the contents
pub fn resize_with_copy(&mut self, size: D) {
        let new_usage = self.usage | wgpu::TextureUsages::COPY_DST;
        let new_texture = self.gpu.create_texture(&wgpu::TextureDescriptor {
            // TODO: update label for texture on resize
            label: None,
            size: size.as_extent(),
            // TODO: mip level count on resize??
            mip_level_count: 1,
            sample_count: 1,
            dimension: size.dim(),
            format: self.format,
            usage: new_usage,
        });
        // Don't copy depth buffer! (InvalidDepthTextureExtent)
        match self.format {
            wgpu::TextureFormat::Depth32Float
            | wgpu::TextureFormat::Depth24Plus
            | wgpu::TextureFormat::Depth24PlusStencil8 => {}
            _ => {
                let mut enc = self.gpu.create_command_encoder("Texture resize encoder");
                enc.copy_texture_to_texture(
                    self.inner.as_image_copy(),
                    new_texture.as_image_copy(),
                    self.size.as_extent(),
                );
                self.gpu.queue.submit([enc.finish()]);
            }
        }
        // Create a new view
        let view = new_texture.create_view(&Default::default());
        self.inner = new_texture;
        self.size = size;
        self.usage = new_usage;
        self.view = view;
    }
pub fn resize_with_copy ( & mut self , size : D ) { let new_usage = self . usage | wgpu :: TextureUsages :: COPY_DST ; let new_texture = self . gpu . create_texture ( & wgpu :: TextureDescriptor { // TODO: update label for texture on resize label : None , size : size . as_extent ( ) , // TODO: mip level count on resize?? mip_level_count : 1 , sample_count : 1 , dimension : size . dim ( ) , format : self . format , usage : new_usage , } ) ; // Don't copy depth buffer! (InvalidDepthTextureExtent) match self . format { wgpu :: TextureFormat :: Depth32Float | wgpu :: TextureFormat :: Depth24Plus | wgpu :: TextureFormat :: Depth24PlusStencil8 => { } _ => { let mut enc = self . gpu . create_command_encoder ( " " ) ; enc . copy_texture_to_texture ( self . inner . as_image_copy ( ) , new_texture . as_image_copy ( ) , self . size . as_extent ( ) , ) ; self . gpu . queue . submit ( [ enc . finish ( ) ] ) ; } } // Create a new view let view = new_texture . create_view ( & Default :: default ( ) ) ; self . inner = new_texture ; self . size = size ; self . usage = new_usage ; self . view = view ; }
Resize the texture and copy the contents
Resize the texture and copy the contents
&mut self
size
D
&mut self
size
D