pub fn update_buffers(
        &mut self,
        device: &wgpu::Device,
        queue: &wgpu::Queue,
        paint_jobs: &[egui::epaint::ClippedPrimitive],
        screen_descriptor: &ScreenDescriptor,
    ) {
        let screen_size_in_points = screen_descriptor.screen_size_in_points();

        self.update_buffer(
            device,
            queue,
            &BufferType::Uniform,
            0,
            bytemuck::cast_slice(&[UniformBuffer {
                screen_size_in_points,
            }]),
        );

        for (i, egui::ClippedPrimitive { primitive, .. }) in paint_jobs.iter().enumerate() {
            match primitive {
                Primitive::Mesh(mesh) => {
                    let data: &[u8] = bytemuck::cast_slice(&mesh.indices);
                    if i < self.index_buffers.len() {
                        self.update_buffer(device, queue, &BufferType::Index, i, data);
                    } else {
                        let buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
                            label: Some("egui_index_buffer"),
                            contents: data,
                            usage: wgpu::BufferUsages::INDEX | wgpu::BufferUsages::COPY_DST,
                        });
                        self.index_buffers.push(SizedBuffer {
                            buffer,
                            size: data.len(),
                        });
                    }

                    let data: &[u8] = bytemuck::cast_slice(&mesh.vertices);
                    if i < self.vertex_buffers.len() {
                        self.update_buffer(device, queue, &BufferType::Vertex, i, data);
                    } else {
                        let buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
                            label: Some("egui_vertex_buffer"),
                            contents: data,
                            usage: wgpu::BufferUsages::VERTEX | wgpu::BufferUsages::COPY_DST,
                        });

                        self.vertex_buffers.push(SizedBuffer {
                            buffer,
                            size: data.len(),
                        });
                    }
                }
                Primitive::Callback(_) => {
                    tracing::warn!("Painting callbacks not supported by egui-wgpu (yet)");
                }
            }
        }
    }
/// Uploads the uniform, vertex and index data used by the render pass.
/// Should be called before `execute()`.
Uploads the uniform, vertex and index data used by the render pass.
Should be called before `execute()`.
Uploads the uniform vertex and index data used by the render pass . Should be called before ` execute () ` .
pub fn update_buffers(
        &mut self,
        device: &wgpu::Device,
        queue: &wgpu::Queue,
        paint_jobs: &[egui::epaint::ClippedPrimitive],
        screen_descriptor: &ScreenDescriptor,
    ) {
        let screen_size_in_points = screen_descriptor.screen_size_in_points();
        self.update_buffer(
            device,
            queue,
            &BufferType::Uniform,
            0,
            bytemuck::cast_slice(&[UniformBuffer {
                screen_size_in_points,
            }]),
        );
        for (i, egui::ClippedPrimitive { primitive, .. }) in paint_jobs.iter().enumerate() {
            match primitive {
                Primitive::Mesh(mesh) => {
                    let data: &[u8] = bytemuck::cast_slice(&mesh.indices);
                    if i < self.index_buffers.len() {
                        self.update_buffer(device, queue, &BufferType::Index, i, data);
                    } else {
                        let buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
                            label: Some("egui_index_buffer"),
                            contents: data,
                            usage: wgpu::BufferUsages::INDEX | wgpu::BufferUsages::COPY_DST,
                        });
                        self.index_buffers.push(SizedBuffer {
                            buffer,
                            size: data.len(),
                        });
                    }
                    let data: &[u8] = bytemuck::cast_slice(&mesh.vertices);
                    if i < self.vertex_buffers.len() {
                        self.update_buffer(device, queue, &BufferType::Vertex, i, data);
                    } else {
                        let buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
                            label: Some("egui_vertex_buffer"),
                            contents: data,
                            usage: wgpu::BufferUsages::VERTEX | wgpu::BufferUsages::COPY_DST,
                        });
                        self.vertex_buffers.push(SizedBuffer {
                            buffer,
                            size: data.len(),
                        });
                    }
                }
                Primitive::Callback(_) => {
                    tracing::warn!("Painting callbacks not supported by egui-wgpu (yet)");
                }
            }
        }
    }
pub fn update_buffers ( & mut self , device : & wgpu :: Device , queue : & wgpu :: Queue , paint_jobs : & [ egui :: epaint :: ClippedPrimitive ] , screen_descriptor : & ScreenDescriptor , ) { let screen_size_in_points = screen_descriptor . screen_size_in_points ( ) ; self . update_buffer ( device , queue , & BufferType :: Uniform , 0 , bytemuck :: cast_slice ( & [ UniformBuffer { screen_size_in_points , } ] ) , ) ; for ( i , egui :: ClippedPrimitive { primitive , .. } ) in paint_jobs . iter ( ) . enumerate ( ) { match primitive { Primitive :: Mesh ( mesh ) => { let data : & [ u8 ] = bytemuck :: cast_slice ( & mesh . indices ) ; if i < self . index_buffers . len ( ) { self . update_buffer ( device , queue , & BufferType :: Index , i , data ) ; } else { let buffer = device . create_buffer_init ( & wgpu :: util :: BufferInitDescriptor { label : Some ( " " ) , contents : data , usage : wgpu :: BufferUsages :: INDEX | wgpu :: BufferUsages :: COPY_DST , } ) ; self . index_buffers . push ( SizedBuffer { buffer , size : data . len ( ) , } ) ; } let data : & [ u8 ] = bytemuck :: cast_slice ( & mesh . vertices ) ; if i < self . vertex_buffers . len ( ) { self . update_buffer ( device , queue , & BufferType :: Vertex , i , data ) ; } else { let buffer = device . create_buffer_init ( & wgpu :: util :: BufferInitDescriptor { label : Some ( " " ) , contents : data , usage : wgpu :: BufferUsages :: VERTEX | wgpu :: BufferUsages :: COPY_DST , } ) ; self . vertex_buffers . push ( SizedBuffer { buffer , size : data . len ( ) , } ) ; } } Primitive :: Callback ( _ ) => { tracing :: warn ! ( " " ) ; } } } }
Uploads the uniform, vertex and index data used by the render pass.
Uploads the uniform vertex and index data used by the render pass .
&mut self
device
&wgpu::Device
queue
&wgpu::Queue
paint_jobs
&[egui::epaint::ClippedPrimitive]
screen_descriptor
&ScreenDescriptor
&mut self
device
&wgpu::Device
queue
&wgpu::Queue
paint_jobs
&[egui::epaint::ClippedPrimitive]
screen_descriptor
&ScreenDescriptor