pub fn execute_with_renderpass<'rpass>(
        &'rpass self,
        rpass: &mut wgpu::RenderPass<'rpass>,
        paint_jobs: &[egui::epaint::ClippedPrimitive],
        screen_descriptor: &ScreenDescriptor,
    ) {
        rpass.set_pipeline(&self.render_pipeline);

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

        let pixels_per_point = screen_descriptor.pixels_per_point;
        let size_in_pixels = screen_descriptor.size_in_pixels;

        for (
            (
                egui::ClippedPrimitive {
                    clip_rect,
                    primitive,
                },
                vertex_buffer,
            ),
            index_buffer,
        ) in paint_jobs
            .iter()
            .zip(&self.vertex_buffers)
            .zip(&self.index_buffers)
        {
            // Transform clip rect to physical pixels.
            let clip_min_x = pixels_per_point * clip_rect.min.x;
            let clip_min_y = pixels_per_point * clip_rect.min.y;
            let clip_max_x = pixels_per_point * clip_rect.max.x;
            let clip_max_y = pixels_per_point * clip_rect.max.y;

            // Make sure clip rect can fit within an `u32`.
            let clip_min_x = clip_min_x.clamp(0.0, size_in_pixels[0] as f32);
            let clip_min_y = clip_min_y.clamp(0.0, size_in_pixels[1] as f32);
            let clip_max_x = clip_max_x.clamp(clip_min_x, size_in_pixels[0] as f32);
            let clip_max_y = clip_max_y.clamp(clip_min_y, size_in_pixels[1] as f32);

            let clip_min_x = clip_min_x.round() as u32;
            let clip_min_y = clip_min_y.round() as u32;
            let clip_max_x = clip_max_x.round() as u32;
            let clip_max_y = clip_max_y.round() as u32;

            let width = (clip_max_x - clip_min_x).max(1);
            let height = (clip_max_y - clip_min_y).max(1);

            {
                // Clip scissor rectangle to target size.
                let x = clip_min_x.min(size_in_pixels[0]);
                let y = clip_min_y.min(size_in_pixels[1]);
                let width = width.min(size_in_pixels[0] - x);
                let height = height.min(size_in_pixels[1] - y);

                // Skip rendering with zero-sized clip areas.
                if width == 0 || height == 0 {
                    continue;
                }

                rpass.set_scissor_rect(x, y, width, height);
            }

            match primitive {
                Primitive::Mesh(mesh) => {
                    if let Some((_texture, bind_group)) = self.textures.get(&mesh.texture_id) {
                        rpass.set_bind_group(1, bind_group, &[]);
                        rpass.set_index_buffer(
                            index_buffer.buffer.slice(..),
                            wgpu::IndexFormat::Uint32,
                        );
                        rpass.set_vertex_buffer(0, vertex_buffer.buffer.slice(..));
                        rpass.draw_indexed(0..mesh.indices.len() as u32, 0, 0..1);
                    } else {
                        tracing::warn!("Missing texture: {:?}", mesh.texture_id);
                    }
                }
                Primitive::Callback(_) => {
                    // already warned about earlier
                }
            }
        }
    }
/// Executes the egui render pass onto an existing wgpu renderpass.
Executes the egui render pass onto an existing wgpu renderpass.
Executes the egui render pass onto an existing wgpu renderpass .
pub fn execute_with_renderpass<'rpass>(
        &'rpass self,
        rpass: &mut wgpu::RenderPass<'rpass>,
        paint_jobs: &[egui::epaint::ClippedPrimitive],
        screen_descriptor: &ScreenDescriptor,
    ) {
        rpass.set_pipeline(&self.render_pipeline);
        rpass.set_bind_group(0, &self.uniform_bind_group, &[]);
        let pixels_per_point = screen_descriptor.pixels_per_point;
        let size_in_pixels = screen_descriptor.size_in_pixels;
        for (
            (
                egui::ClippedPrimitive {
                    clip_rect,
                    primitive,
                },
                vertex_buffer,
            ),
            index_buffer,
        ) in paint_jobs
            .iter()
            .zip(&self.vertex_buffers)
            .zip(&self.index_buffers)
        {
            // Transform clip rect to physical pixels.
            let clip_min_x = pixels_per_point * clip_rect.min.x;
            let clip_min_y = pixels_per_point * clip_rect.min.y;
            let clip_max_x = pixels_per_point * clip_rect.max.x;
            let clip_max_y = pixels_per_point * clip_rect.max.y;
            // Make sure clip rect can fit within an `u32`.
            let clip_min_x = clip_min_x.clamp(0.0, size_in_pixels[0] as f32);
            let clip_min_y = clip_min_y.clamp(0.0, size_in_pixels[1] as f32);
            let clip_max_x = clip_max_x.clamp(clip_min_x, size_in_pixels[0] as f32);
            let clip_max_y = clip_max_y.clamp(clip_min_y, size_in_pixels[1] as f32);
            let clip_min_x = clip_min_x.round() as u32;
            let clip_min_y = clip_min_y.round() as u32;
            let clip_max_x = clip_max_x.round() as u32;
            let clip_max_y = clip_max_y.round() as u32;
            let width = (clip_max_x - clip_min_x).max(1);
            let height = (clip_max_y - clip_min_y).max(1);
            {
                // Clip scissor rectangle to target size.
                let x = clip_min_x.min(size_in_pixels[0]);
                let y = clip_min_y.min(size_in_pixels[1]);
                let width = width.min(size_in_pixels[0] - x);
                let height = height.min(size_in_pixels[1] - y);
                // Skip rendering with zero-sized clip areas.
                if width == 0 || height == 0 {
                    continue;
                }
                rpass.set_scissor_rect(x, y, width, height);
            }
            match primitive {
                Primitive::Mesh(mesh) => {
                    if let Some((_texture, bind_group)) = self.textures.get(&mesh.texture_id) {
                        rpass.set_bind_group(1, bind_group, &[]);
                        rpass.set_index_buffer(
                            index_buffer.buffer.slice(..),
                            wgpu::IndexFormat::Uint32,
                        );
                        rpass.set_vertex_buffer(0, vertex_buffer.buffer.slice(..));
                        rpass.draw_indexed(0..mesh.indices.len() as u32, 0, 0..1);
                    } else {
                        tracing::warn!("Missing texture: {:?}", mesh.texture_id);
                    }
                }
                Primitive::Callback(_) => {
                    // already warned about earlier
                }
            }
        }
    }
pub fn execute_with_renderpass < ' rpass > ( & ' rpass self , rpass : & mut wgpu :: RenderPass < ' rpass > , paint_jobs : & [ egui :: epaint :: ClippedPrimitive ] , screen_descriptor : & ScreenDescriptor , ) { rpass . set_pipeline ( & self . render_pipeline ) ; rpass . set_bind_group ( 0 , & self . uniform_bind_group , & [ ] ) ; let pixels_per_point = screen_descriptor . pixels_per_point ; let size_in_pixels = screen_descriptor . size_in_pixels ; for ( ( egui :: ClippedPrimitive { clip_rect , primitive , } , vertex_buffer , ) , index_buffer , ) in paint_jobs . iter ( ) . zip ( & self . vertex_buffers ) . zip ( & self . index_buffers ) { // Transform clip rect to physical pixels. let clip_min_x = pixels_per_point * clip_rect . min . x ; let clip_min_y = pixels_per_point * clip_rect . min . y ; let clip_max_x = pixels_per_point * clip_rect . max . x ; let clip_max_y = pixels_per_point * clip_rect . max . y ; // Make sure clip rect can fit within an `u32`. let clip_min_x = clip_min_x . clamp ( 0.0 , size_in_pixels [ 0 ] as f32 ) ; let clip_min_y = clip_min_y . clamp ( 0.0 , size_in_pixels [ 1 ] as f32 ) ; let clip_max_x = clip_max_x . clamp ( clip_min_x , size_in_pixels [ 0 ] as f32 ) ; let clip_max_y = clip_max_y . clamp ( clip_min_y , size_in_pixels [ 1 ] as f32 ) ; let clip_min_x = clip_min_x . round ( ) as u32 ; let clip_min_y = clip_min_y . round ( ) as u32 ; let clip_max_x = clip_max_x . round ( ) as u32 ; let clip_max_y = clip_max_y . round ( ) as u32 ; let width = ( clip_max_x - clip_min_x ) . max ( 1 ) ; let height = ( clip_max_y - clip_min_y ) . max ( 1 ) ; { // Clip scissor rectangle to target size. let x = clip_min_x . min ( size_in_pixels [ 0 ] ) ; let y = clip_min_y . min ( size_in_pixels [ 1 ] ) ; let width = width . min ( size_in_pixels [ 0 ] - x ) ; let height = height . min ( size_in_pixels [ 1 ] - y ) ; // Skip rendering with zero-sized clip areas. if width == 0 || height == 0 { continue ; } rpass . set_scissor_rect ( x , y , width , height ) ; } match primitive { Primitive :: Mesh ( mesh ) => { if let Some ( ( _texture , bind_group ) ) = self . textures . get ( & mesh . texture_id ) { rpass . set_bind_group ( 1 , bind_group , & [ ] ) ; rpass . set_index_buffer ( index_buffer . buffer . slice ( .. ) , wgpu :: IndexFormat :: Uint32 , ) ; rpass . set_vertex_buffer ( 0 , vertex_buffer . buffer . slice ( .. ) ) ; rpass . draw_indexed ( 0 .. mesh . indices . len ( ) as u32 , 0 , 0 .. 1 ) ; } else { tracing :: warn ! ( " " mesh texture_id ) ; } } Primitive :: Callback ( _ ) => { // already warned about earlier } } } }
Executes the egui render pass onto an existing wgpu renderpass.
Executes the egui render pass onto an existing wgpu renderpass .
&'rpass self
rpass
&mut wgpu::RenderPass<'rpass>
paint_jobs
&[egui::epaint::ClippedPrimitive]
screen_descriptor
&ScreenDescriptor
&'rpass self
rpass
&mut wgpu::RenderPass<'rpass>
paint_jobs
&[egui::epaint::ClippedPrimitive]
screen_descriptor
&ScreenDescriptor