| 637 | } |
| 638 | |
| 639 | fn ensure_target(&mut self, device: &Device) { |
| 640 | let need_new = self |
| 641 | .pick_texture |
| 642 | .as_ref() |
| 643 | .map(|t| { |
| 644 | let size = t.size(); |
| 645 | size.width != self.size_w || size.height != self.size_h |
| 646 | }) |
| 647 | .unwrap_or(true); |
| 648 | if need_new { |
| 649 | let tex = device.create_texture(&TextureDescriptor { |
| 650 | label: Some("pick texture"), |
| 651 | size: Extent3d { |
| 652 | width: self.size_w, |
| 653 | height: self.size_h, |
| 654 | depth_or_array_layers: 1, |
| 655 | }, |
| 656 | mip_level_count: 1, |
| 657 | sample_count: 1, |
| 658 | dimension: TextureDimension::D2, |
| 659 | format: TextureFormat::R32Uint, |
| 660 | usage: TextureUsages::RENDER_ATTACHMENT | TextureUsages::COPY_SRC, |
| 661 | view_formats: &[], |
| 662 | }); |
| 663 | let view = tex.create_view(&TextureViewDescriptor::default()); |
| 664 | self.pick_view = Some(view); |
| 665 | self.pick_texture = Some(tex); |
| 666 | } |
| 667 | } |
| 668 | |
| 669 | fn ensure_pipeline(&mut self, device: &Device, camera_bgl: &BindGroupLayout) { |
| 670 | if self.pipeline.is_some() { |