(
&mut self,
device: &Device,
format: TextureFormat,
camera_bgl: &BindGroupLayout,
sample_count: u32,
)
| 22 | |
| 23 | impl Grid { |
| 24 | pub(crate) fn ensure_pipeline( |
| 25 | &mut self, |
| 26 | device: &Device, |
| 27 | format: TextureFormat, |
| 28 | camera_bgl: &BindGroupLayout, |
| 29 | sample_count: u32, |
| 30 | ) { |
| 31 | if self.pipeline.is_some() { |
| 32 | return; |
| 33 | } |
| 34 | let shader = device.create_shader_module(include_wgsl!("shaders/grid.wgsl")); |
| 35 | let layout = device.create_pipeline_layout(&PipelineLayoutDescriptor { |
| 36 | label: Some("Grid Pipeline Layout"), |
| 37 | bind_group_layouts: &[camera_bgl], |
| 38 | push_constant_ranges: &[], |
| 39 | }); |
| 40 | let pipeline = device.create_render_pipeline(&RenderPipelineDescriptor { |
| 41 | label: Some("Grid Pipeline"), |
| 42 | layout: Some(&layout), |
| 43 | vertex: VertexState { |
| 44 | module: &shader, |
| 45 | entry_point: Some("vs_main"), |
| 46 | compilation_options: PipelineCompilationOptions::default(), |
| 47 | buffers: &[VertexBufferLayout { |
| 48 | array_stride: (std::mem::size_of::<[f32; 2]>() |
| 49 | + std::mem::size_of::<[f32; 4]>()) as u64, |
| 50 | step_mode: VertexStepMode::Vertex, |
| 51 | attributes: &[ |
| 52 | VertexAttribute { |
| 53 | offset: 0, |
| 54 | shader_location: 0, |
| 55 | format: VertexFormat::Float32x2, |
| 56 | }, |
| 57 | VertexAttribute { |
| 58 | offset: std::mem::size_of::<[f32; 2]>() as u64, |
| 59 | shader_location: 1, |
| 60 | format: VertexFormat::Float32x4, |
| 61 | }, |
| 62 | ], |
| 63 | }], |
| 64 | }, |
| 65 | fragment: Some(FragmentState { |
| 66 | module: &shader, |
| 67 | entry_point: Some("fs_main"), |
| 68 | compilation_options: PipelineCompilationOptions::default(), |
| 69 | targets: &[Some(ColorTargetState { |
| 70 | format, |
| 71 | blend: Some(BlendState::ALPHA_BLENDING), |
| 72 | write_mask: ColorWrites::ALL, |
| 73 | })], |
| 74 | }), |
| 75 | primitive: PrimitiveState { |
| 76 | topology: PrimitiveTopology::LineList, |
| 77 | strip_index_format: None, |
| 78 | front_face: FrontFace::Ccw, |
| 79 | cull_mode: None, |
| 80 | polygon_mode: PolygonMode::Fill, |
| 81 | unclipped_depth: false, |
no outgoing calls
no test coverage detected