fn render(
        &mut self,
        view: &wgpu::TextureView,
        device: &wgpu::Device,
        queue: &wgpu::Queue,
        _spawner: &framework::Spawner,
    ) {
        // create render pass descriptor and its color attachments
        let color_attachments = [wgpu::RenderPassColorAttachment {
            view,
            resolve_target: None,
            ops: wgpu::Operations {
                // Not clearing here in order to test wgpu's zero texture initialization on a surface texture.
                // Users should avoid loading uninitialized memory since this can cause additional overhead.
                load: wgpu::LoadOp::Load,
                store: true,
            },
        }];
        let render_pass_descriptor = wgpu::RenderPassDescriptor {
            label: None,
            color_attachments: &color_attachments,
            depth_stencil_attachment: None,
        };

        // get command encoder
        let mut command_encoder =
            device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });

        command_encoder.push_debug_group("compute boid movement");
        {
            // compute pass
            let mut cpass =
                command_encoder.begin_compute_pass(&wgpu::ComputePassDescriptor { label: None });
            cpass.set_pipeline(&self.compute_pipeline);
            cpass.set_bind_group(0, &self.particle_bind_groups[self.frame_num % 2], &[]);
            cpass.dispatch(self.work_group_count, 1, 1);
        }
        command_encoder.pop_debug_group();

        command_encoder.push_debug_group("render boids");
        {
            // render pass
            let mut rpass = command_encoder.begin_render_pass(&render_pass_descriptor);
            rpass.set_pipeline(&self.render_pipeline);
            // render dst particles
            rpass.set_vertex_buffer(0, self.particle_buffers[(self.frame_num + 1) % 2].slice(..));
            // the three instance-local vertices
            rpass.set_vertex_buffer(1, self.vertices_buffer.slice(..));
            rpass.draw(0..3, 0..NUM_PARTICLES);
        }
        command_encoder.pop_debug_group();

        // update frame count
        self.frame_num += 1;

        // done
        queue.submit(Some(command_encoder.finish()));
    }
/// render is called each frame, dispatching compute groups proportional
///   a TriangleList draw call for all NUM_PARTICLES at 3 vertices each
render is called each frame, dispatching compute groups proportional
a TriangleList draw call for all NUM_PARTICLES at 3 vertices each
render is called each frame dispatching compute groups proportional a TriangleList draw call for all NUM_PARTICLES at 3 vertices each
fn render(
        &mut self,
        view: &wgpu::TextureView,
        device: &wgpu::Device,
        queue: &wgpu::Queue,
        _spawner: &framework::Spawner,
    ) {
        // create render pass descriptor and its color attachments
        let color_attachments = [wgpu::RenderPassColorAttachment {
            view,
            resolve_target: None,
            ops: wgpu::Operations {
                // Not clearing here in order to test wgpu's zero texture initialization on a surface texture.
                // Users should avoid loading uninitialized memory since this can cause additional overhead.
                load: wgpu::LoadOp::Load,
                store: true,
            },
        }];
        let render_pass_descriptor = wgpu::RenderPassDescriptor {
            label: None,
            color_attachments: &color_attachments,
            depth_stencil_attachment: None,
        };
        // get command encoder
        let mut command_encoder =
            device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None });
        command_encoder.push_debug_group("compute boid movement");
        {
            // compute pass
            let mut cpass =
                command_encoder.begin_compute_pass(&wgpu::ComputePassDescriptor { label: None });
            cpass.set_pipeline(&self.compute_pipeline);
            cpass.set_bind_group(0, &self.particle_bind_groups[self.frame_num % 2], &[]);
            cpass.dispatch(self.work_group_count, 1, 1);
        }
        command_encoder.pop_debug_group();
        command_encoder.push_debug_group("render boids");
        {
            // render pass
            let mut rpass = command_encoder.begin_render_pass(&render_pass_descriptor);
            rpass.set_pipeline(&self.render_pipeline);
            // render dst particles
            rpass.set_vertex_buffer(0, self.particle_buffers[(self.frame_num + 1) % 2].slice(..));
            // the three instance-local vertices
            rpass.set_vertex_buffer(1, self.vertices_buffer.slice(..));
            rpass.draw(0..3, 0..NUM_PARTICLES);
        }
        command_encoder.pop_debug_group();
        // update frame count
        self.frame_num += 1;
        // done
        queue.submit(Some(command_encoder.finish()));
    }
fn render ( & mut self , view : & wgpu :: TextureView , device : & wgpu :: Device , queue : & wgpu :: Queue , _spawner : & framework :: Spawner , ) { // create render pass descriptor and its color attachments let color_attachments = [ wgpu :: RenderPassColorAttachment { view , resolve_target : None , ops : wgpu :: Operations { // Not clearing here in order to test wgpu's zero texture initialization on a surface texture. // Users should avoid loading uninitialized memory since this can cause additional overhead. load : wgpu :: LoadOp :: Load , store : true , } , } ] ; let render_pass_descriptor = wgpu :: RenderPassDescriptor { label : None , color_attachments : & color_attachments , depth_stencil_attachment : None , } ; // get command encoder let mut command_encoder = device . create_command_encoder ( & wgpu :: CommandEncoderDescriptor { label : None } ) ; command_encoder . push_debug_group ( " " ) ; { // compute pass let mut cpass = command_encoder . begin_compute_pass ( & wgpu :: ComputePassDescriptor { label : None } ) ; cpass . set_pipeline ( & self . compute_pipeline ) ; cpass . set_bind_group ( 0 , & self . particle_bind_groups [ self . frame_num % 2 ] , & [ ] ) ; cpass . dispatch ( self . work_group_count , 1 , 1 ) ; } command_encoder . pop_debug_group ( ) ; command_encoder . push_debug_group ( " " ) ; { // render pass let mut rpass = command_encoder . begin_render_pass ( & render_pass_descriptor ) ; rpass . set_pipeline ( & self . render_pipeline ) ; // render dst particles rpass . set_vertex_buffer ( 0 , self . particle_buffers [ ( self . frame_num + 1 ) % 2 ] . slice ( .. ) ) ; // the three instance-local vertices rpass . set_vertex_buffer ( 1 , self . vertices_buffer . slice ( .. ) ) ; rpass . draw ( 0 .. 3 , 0 .. NUM_PARTICLES ) ; } command_encoder . pop_debug_group ( ) ; // update frame count self . frame_num += 1 ; // done queue . submit ( Some ( command_encoder . finish ( ) ) ) ; }
render is called each frame, dispatching compute groups proportional
a TriangleList draw call for all NUM_PARTICLES at 3 vertices each
render is called each frame dispatching compute groups proportional a TriangleList draw call for all NUM_PARTICLES at 3 vertices each
&mut self
view
&wgpu::TextureView
device
&wgpu::Device
queue
&wgpu::Queue
_spawner
&framework::Spawner