/// Completely updates the draw data.
Completely updates the draw data.
Completely updates the draw data .
pub fn update(&mut self, cx: &Context, draws: &[D]) {
        let draws = draws
            .iter()
            .map(|draw| draw.clone().into().as_std430())
            .collect::<Vec<_>>();
        let size = GpuDraw::std430_size_static() as u64 * draws.len() as u64;
        self.len = draws.len();
        if size > self.capacity {
            self.buf = cx
                .device
                .create_buffer_init(&wgpu::util::BufferInitDescriptor {
                    label: None,
                    contents: unsafe {
                        std::slice::from_raw_parts(draws.as_ptr() as *const u8, size as _)
                    },
                    usage: wgpu::BufferUsages::STORAGE | wgpu::BufferUsages::COPY_DST,
                });
            self.capacity = size;
            self.id = NEXT_DRAW_ARRAY_ID.fetch_add(1, SeqCst);
        } else {
            cx.queue.write_buffer(&self.buf, 0, unsafe {
                std::slice::from_raw_parts(draws.as_ptr() as *const u8, size as _)
            });
        }
    }
pub fn update ( & mut self , cx : & Context , draws : & [ D ] ) { let draws = draws . iter ( ) . map ( | draw | draw . clone ( ) . into ( ) . as_std430 ( ) ) . collect :: < Vec < _ > > ( ) ; let size = GpuDraw :: std430_size_static ( ) as u64 * draws . len ( ) as u64 ; self . len = draws . len ( ) ; if size > self . capacity { self . buf = cx . device . create_buffer_init ( & wgpu :: util :: BufferInitDescriptor { label : None , contents : unsafe { std :: slice :: from_raw_parts ( draws . as_ptr ( ) as * const u8 , size as _ ) } , usage : wgpu :: BufferUsages :: STORAGE | wgpu :: BufferUsages :: COPY_DST , } ) ; self . capacity = size ; self . id = NEXT_DRAW_ARRAY_ID . fetch_add ( 1 , SeqCst ) ; } else { cx . queue . write_buffer ( & self . buf , 0 , unsafe { std :: slice :: from_raw_parts ( draws . as_ptr ( ) as * const u8 , size as _ ) } ) ; } }
Completely updates the draw data.
Completely updates the draw data .
&mut self
cx
&Context
draws
&[D]