diff options
Diffstat (limited to 'src/renderer.rs')
| -rw-r--r-- | src/renderer.rs | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/src/renderer.rs b/src/renderer.rs index 215dda8..e48f3e4 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -153,11 +153,15 @@ impl Renderer { config: &RenderWindowConfig, event_loop: &EventLoop<()>, ) -> Result<Self, NewRendererError> { + #[cfg(feature = "profile-with-tracy")] + profiling::tracy_client::Client::start(); + profiling::register_thread!("main"); + // build the window let window = config.to_window().build(event_loop)?; // the instance's main purpose is to create an adapter and a surface - let instance = wgpu::Instance::new(wgpu::Backends::all()); + let instance = wgpu::Instance::new(wgpu::Backends::VULKAN); // the surface is the part of the screen we'll draw to let surface = unsafe { instance.create_surface(&window) }; @@ -181,9 +185,15 @@ impl Renderer { .expect("there was no device with the selected features"); // configuration for the surface - let supported_present_modes = surface.get_supported_modes(&adapter).into_boxed_slice(); + let supported_present_modes = surface + .get_supported_present_modes(&adapter) + .into_boxed_slice(); + let supported_alpha_modes = surface + .get_supported_alpha_modes(&adapter) + .into_boxed_slice(); let surface_config = config.to_surface_configuration( - &surface.get_supported_modes(&adapter), + &supported_present_modes, + &supported_alpha_modes, surface.get_supported_formats(&adapter)[0], ); surface.configure(&device, &surface_config); @@ -344,11 +354,16 @@ impl Renderer { self.textures.texture_y(id) } + pub fn clear_textures(&mut self) { + self.textures.clear_textures(); + } + fn expand_instance_buffer(&mut self) { (self.instance_buffer, self.instance_buffer_size) = Self::new_instance_buffer(&self.device, &self.instances); } + #[profiling::function] fn fill_instance_buffer(&mut self) { if self.instances.len() > self.instance_buffer_size { self.expand_instance_buffer(); @@ -369,6 +384,7 @@ impl Renderer { /// trying to acquire the next frame. There may also be no more memory left /// that can be used for the new frame. // TODO this is too big + #[profiling::function] fn render(&mut self) -> Result<(), wgpu::SurfaceError> { // the new texture we can render to let output = self.surface.get_current_texture()?; @@ -394,6 +410,7 @@ impl Renderer { self.textures.fill_textures(&self.queue); { + profiling::scope!("encode render pass"); let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { label: Some("Render Pass"), color_attachments: &[Some(wgpu::RenderPassColorAttachment { @@ -418,6 +435,7 @@ impl Renderer { // render pass is dropped // submit the command buffer to the GPU + profiling::scope!("submit render"); self.queue.submit(std::iter::once(encoder.finish())); output.present(); @@ -450,7 +468,8 @@ impl Renderer { } // otherwise, we'll just log the error Err(e) => log::error!("{}", e), - } + }; + profiling::finish_frame!(); } _ => {} }) |
