From 19f741b33fe7cc959b2af4eab7968e4cba671014 Mon Sep 17 00:00:00 2001 From: Imbris Date: Wed, 16 Jun 2021 00:10:33 -0400 Subject: [PATCH] Show the graphics backend in the hud debug info and include the adapter info when panicking in the wgpu error handler --- voxygen/src/hud/mod.rs | 12 +++++++++++ voxygen/src/render/renderer.rs | 37 +++++++++++++++++++++------------- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 99710dda72..a012c63847 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -239,6 +239,7 @@ widget_ids! { num_lights, num_figures, num_particles, + graphics_backend, gpu_timings[], // Game Version @@ -2211,6 +2212,17 @@ impl Hud { .font_size(self.fonts.cyri.scale(14)) .set(self.ids.num_particles, ui_widgets); + // Graphics backend + Text::new(&format!( + "Graphics backend: {}", + global_state.window.renderer().graphics_backend(), + )) + .color(TEXT_COLOR) + .down_from(self.ids.num_particles, 5.0) + .font_id(self.fonts.cyri.conrod_id) + .font_size(self.fonts.cyri.scale(14)) + .set(self.ids.graphics_backend, ui_widgets); + // GPU timing for different pipelines let gpu_timings = global_state.window.renderer().timings(); if !gpu_timings.is_empty() { diff --git a/voxygen/src/render/renderer.rs b/voxygen/src/render/renderer.rs index d94fb5be73..8f2c3e8b94 100644 --- a/voxygen/src/render/renderer.rs +++ b/voxygen/src/render/renderer.rs @@ -139,6 +139,9 @@ pub struct Renderer { // This checks is added because windows resizes the window to 0,0 when // minimizing and this causes a bunch of validation errors is_minimized: bool, + + // To remember the backend info after initialization for debug purposes + graphics_backend: String, } impl Renderer { @@ -188,6 +191,17 @@ impl Renderer { )) .ok_or(RenderError::CouldNotFindAdapter)?; + let info = adapter.get_info(); + info!( + ?info.name, + ?info.vendor, + ?info.backend, + ?info.device, + ?info.device_type, + "selected graphics device" + ); + let graphics_backend = format!("{:?}", &info.backend); + let limits = wgpu::Limits { max_push_constant_size: 64, ..Default::default() @@ -213,12 +227,12 @@ impl Renderer { // Set error handler for wgpu errors // This is better for use than their default because it includes the error in // the panic message - device.on_uncaptured_error(|error| { + device.on_uncaptured_error(move |error| { error!("{}", &error); panic!( - "wgpu error (handling all wgpu errors as fatal): {:?}", - &error, - ) + "wgpu error (handling all wgpu errors as fatal):\n{:?}\n{:?}", + &error, &info, + ); }); let profiler_features_enabled = device @@ -231,16 +245,6 @@ impl Renderer { ); } - let info = adapter.get_info(); - info!( - ?info.name, - ?info.vendor, - ?info.backend, - ?info.device, - ?info.device_type, - "selected graphics device" - ); - let format = adapter .get_swap_chain_preferred_format(&surface) .expect("No supported swap chain format found"); @@ -402,9 +406,14 @@ impl Renderer { profiler_features_enabled, is_minimized: false, + + graphics_backend, }) } + /// Get the graphics backend being used + pub fn graphics_backend(&self) -> &str { &self.graphics_backend } + /// Check the status of the intial pipeline creation /// Returns `None` if complete /// Returns `Some((total, complete))` if in progress