Show the graphics backend in the hud debug info and include the adapter info when panicking in the wgpu error handler

This commit is contained in:
Imbris 2021-06-16 00:10:33 -04:00
parent 09a914aa84
commit 19f741b33f
2 changed files with 35 additions and 14 deletions

View File

@ -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() {

View File

@ -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