diff --git a/src/renderer.rs b/src/renderer.rs index 93246c8..012caeb 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use crawl::wgpu; +use crawl::{wgpu, wgpu_profiler::GpuProfiler}; use crate::camera::CameraController; @@ -106,29 +106,41 @@ impl VoxelRenderer { } impl crawl::Pass for VoxelRenderer { - fn execute(&self, encoder: &mut wgpu::CommandEncoder, view: &wgpu::TextureView) { + fn execute( + &self, + profiler: &GpuProfiler, + device: &wgpu::Device, + encoder: &mut wgpu::CommandEncoder, + view: &wgpu::TextureView, + ) { + let mut scope = profiler.scope("Rendering", encoder, device); + let size = self.render_texture.attributes.size; - let mut compute_pass = encoder.begin_compute_pass(&wgpu::ComputePassDescriptor::default()); + let mut compute_pass = scope.scoped_compute_pass("Ray gen", device); compute_pass.set_pipeline(&self.raygen_pipeline); compute_pass.set_bind_group(0, &self.raygen_bind_group, &[]); compute_pass.dispatch_workgroups(size.width / 8, size.height / 8, 1); drop(compute_pass); - let mut compute_pass = encoder.begin_compute_pass(&wgpu::ComputePassDescriptor::default()); + let mut compute_pass = scope.scoped_compute_pass("Ray cast", device); compute_pass.set_pipeline(&self.raycast_pipeline); compute_pass.set_bind_group(0, &self.raygen_bind_group, &[]); compute_pass.dispatch_workgroups(size.width / 8, size.height / 8, 1); drop(compute_pass); - let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { - label: Some("Render Pass"), - color_attachments: &[Some(wgpu::RenderPassColorAttachment { - view, - resolve_target: None, - ops: wgpu::Operations::default(), - })], - ..Default::default() - }); + let mut render_pass = scope.scoped_render_pass( + "Quad render", + device, + wgpu::RenderPassDescriptor { + label: Some("Render Pass"), + color_attachments: &[Some(wgpu::RenderPassColorAttachment { + view, + resolve_target: None, + ops: wgpu::Operations::default(), + })], + ..Default::default() + }, + ); render_pass.set_pipeline(&self.render_pipeline); render_pass.set_bind_group(0, &self.render_texture.bind_group, &[]); render_pass.draw(0..6, 0..1);