pub fn encode(
        &mut self,
        device: &wgpu::Device,
        render_pass: &wgpu::RenderPassDescriptor,
        queue: &wgpu::Queue,
    ) {
        self.scenes[self.cur_scene].update(queue);
        self.uniforms.update(queue);

        let mut encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor {
            label: Some("vger encoder"),
        });

        self.glyph_cache.update(device, &mut encoder);

        {
            let mut rpass = encoder.begin_render_pass(render_pass);

            rpass.set_pipeline(&self.pipeline);

            rpass.set_bind_group(
                0,
                &self.scenes[self.cur_scene].bind_groups[self.cur_layer],
                &[], // dynamic offsets
            );

            rpass.set_bind_group(1, &self.uniform_bind_group, &[]);

            let n = self.scenes[self.cur_scene].prims[self.cur_layer].data.len();
            // println!("encoding {:?} prims", n);

            rpass.draw(/*vertices*/ 0..4, /*instances*/ 0..(n as u32))
        }
        queue.submit(Some(encoder.finish()));

        // If we're getting close to full, reset the glyph cache.
        let usage = self.glyph_cache.usage();
        // println!("glyph cache usage {}", usage);
        if usage > 0.7 {
            // println!("clearing glyph cache");
            self.glyph_cache.clear();
        }
    }
/// Encode all rendering to a command buffer.
Encode all rendering to a command buffer.
Encode all rendering to a command buffer .
pub fn encode(
        &mut self,
        device: &wgpu::Device,
        render_pass: &wgpu::RenderPassDescriptor,
        queue: &wgpu::Queue,
    ) {
        self.scenes[self.cur_scene].update(queue);
        self.uniforms.update(queue);
        let mut encoder = device.create_command_encoder(&wgpu::CommandEncoderDescriptor {
            label: Some("vger encoder"),
        });
        self.glyph_cache.update(device, &mut encoder);
        {
            let mut rpass = encoder.begin_render_pass(render_pass);
            rpass.set_pipeline(&self.pipeline);
            rpass.set_bind_group(
                0,
                &self.scenes[self.cur_scene].bind_groups[self.cur_layer],
                &[], // dynamic offsets
            );
            rpass.set_bind_group(1, &self.uniform_bind_group, &[]);
            let n = self.scenes[self.cur_scene].prims[self.cur_layer].data.len();
            // println!("encoding {:?} prims", n);
            rpass.draw(/*vertices*/ 0..4, /*instances*/ 0..(n as u32))
        }
        queue.submit(Some(encoder.finish()));
        // If we're getting close to full, reset the glyph cache.
        let usage = self.glyph_cache.usage();
        // println!("glyph cache usage {}", usage);
        if usage > 0.7 {
            // println!("clearing glyph cache");
            self.glyph_cache.clear();
        }
    }
pub fn encode ( & mut self , device : & wgpu :: Device , render_pass : & wgpu :: RenderPassDescriptor , queue : & wgpu :: Queue , ) { self . scenes [ self . cur_scene ] . update ( queue ) ; self . uniforms . update ( queue ) ; let mut encoder = device . create_command_encoder ( & wgpu :: CommandEncoderDescriptor { label : Some ( " " ) , } ) ; self . glyph_cache . update ( device , & mut encoder ) ; { let mut rpass = encoder . begin_render_pass ( render_pass ) ; rpass . set_pipeline ( & self . pipeline ) ; rpass . set_bind_group ( 0 , & self . scenes [ self . cur_scene ] . bind_groups [ self . cur_layer ] , & [ ] , // dynamic offsets ) ; rpass . set_bind_group ( 1 , & self . uniform_bind_group , & [ ] ) ; let n = self . scenes [ self . cur_scene ] . prims [ self . cur_layer ] . data . len ( ) ; // println!("encoding {:?} prims", n); rpass . draw ( /*vertices*/ 0 .. 4 , /*instances*/ 0 .. ( n as u32 ) ) } queue . submit ( Some ( encoder . finish ( ) ) ) ; // If we're getting close to full, reset the glyph cache. let usage = self . glyph_cache . usage ( ) ; // println!("glyph cache usage {}", usage); if usage > 0.7 { // println!("clearing glyph cache"); self . glyph_cache . clear ( ) ; } }
Encode all rendering to a command buffer.
Encode all rendering to a command buffer .
&mut self
device
&wgpu::Device
render_pass
&wgpu::RenderPassDescriptor
queue
&wgpu::Queue
&mut self
device
&wgpu::Device
render_pass
&wgpu::RenderPassDescriptor
queue
&wgpu::Queue