From bdff88ab7c7c16e582a0d5b61a384d4c79d96a5e Mon Sep 17 00:00:00 2001 From: Imbris Date: Tue, 15 Jun 2021 23:18:25 -0400 Subject: [PATCH 1/5] Add note on the reasoning for the visual position interpolation rate value in voxygen --- voxygen/src/ecs/sys/interpolation.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/voxygen/src/ecs/sys/interpolation.rs b/voxygen/src/ecs/sys/interpolation.rs index 97dba3a071..9abe8af9c5 100644 --- a/voxygen/src/ecs/sys/interpolation.rs +++ b/voxygen/src/ecs/sys/interpolation.rs @@ -43,7 +43,11 @@ impl<'a> System<'a> for Sys { { // Update interpolation values, but don't interpolate far things or objects if i.pos.distance_squared(pos.0) < 64.0 * 64.0 && !matches!(body, Body::Object(_)) { - i.pos = Lerp::lerp(i.pos, pos.0 + vel.0 * 0.03, 10.0 * dt.0); + // Note, these values are specifically tuned for smoother motion with high + // network latency or low network sampling rate and for smooth + // block hopping (which is instantaneous) + const POS_LERP_RATE_FACTOR: f32 = 10.0; + i.pos = Lerp::lerp(i.pos, pos.0 + vel.0 * 0.03, POS_LERP_RATE_FACTOR * dt.0); i.ori = Ori::slerp(i.ori, *ori, base_ori_interp(body) * dt.0); } else { i.pos = pos.0; From 8e8e0a152237c80c3dc7c7ff9bec2b8ff6bb5bcd Mon Sep 17 00:00:00 2001 From: Imbris Date: Tue, 15 Jun 2021 23:28:04 -0400 Subject: [PATCH 2/5] Log format used for the swapchain --- voxygen/src/render/renderer.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/voxygen/src/render/renderer.rs b/voxygen/src/render/renderer.rs index d5e9f2157d..d94fb5be73 100644 --- a/voxygen/src/render/renderer.rs +++ b/voxygen/src/render/renderer.rs @@ -244,6 +244,7 @@ impl Renderer { let format = adapter .get_swap_chain_preferred_format(&surface) .expect("No supported swap chain format found"); + info!("Using {:?} as the swapchain format", format); let sc_desc = wgpu::SwapChainDescriptor { usage: wgpu::TextureUsage::RENDER_ATTACHMENT, From 295e58016ce1cb49c4b4dc80214397a855e4416d Mon Sep 17 00:00:00 2001 From: Imbris Date: Wed, 16 Jun 2021 00:10:33 -0400 Subject: [PATCH 3/5] 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 From 1dec2a9a05dac5a0d1a006290246108fe5408180 Mon Sep 17 00:00:00 2001 From: Imbris Date: Wed, 16 Jun 2021 00:24:47 -0400 Subject: [PATCH 4/5] Do some checks to make sure WGPU_TRACE_DIR is useable if set and exit early if it isn't to avoid the user not being aware that they are failing to collect a trace --- voxygen/src/render/renderer.rs | 57 ++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 16 deletions(-) diff --git a/voxygen/src/render/renderer.rs b/voxygen/src/render/renderer.rs index 8f2c3e8b94..06cf8b6386 100644 --- a/voxygen/src/render/renderer.rs +++ b/voxygen/src/render/renderer.rs @@ -207,22 +207,47 @@ impl Renderer { ..Default::default() }; - let (device, queue) = futures_executor::block_on( - adapter.request_device( - &wgpu::DeviceDescriptor { - // TODO - label: None, - features: wgpu::Features::DEPTH_CLAMPING - | wgpu::Features::ADDRESS_MODE_CLAMP_TO_BORDER - | wgpu::Features::PUSH_CONSTANTS - | (adapter.features() & wgpu_profiler::GpuProfiler::REQUIRED_WGPU_FEATURES), - limits, - }, - std::env::var_os("WGPU_TRACE_DIR") - .as_ref() - .map(|v| std::path::Path::new(v)), - ), - )?; + let (device, queue) = futures_executor::block_on(adapter.request_device( + &wgpu::DeviceDescriptor { + // TODO + label: None, + features: wgpu::Features::DEPTH_CLAMPING + | wgpu::Features::ADDRESS_MODE_CLAMP_TO_BORDER + | wgpu::Features::PUSH_CONSTANTS + | (adapter.features() & wgpu_profiler::GpuProfiler::REQUIRED_WGPU_FEATURES), + limits, + }, + std::env::var_os("WGPU_TRACE_DIR").as_ref().map(|v| { + let path = std::path::Path::new(v); + // We don't want to continue if we can't actually collect the api trace + if !path.exists() { + panic!( + "WGPU_TRACE_DIR is set to the path \"{}\" which doesn't exist", + path.display() + ); + } + if !path.is_dir() { + panic!( + "WGPU_TRACE_DIR is set to the path \"{}\" which is not a directory", + path.display() + ); + } + if path + .read_dir() + .expect("Could not read the directory that is specified by WGPU_TRACE_DIR") + .next() + .is_some() + { + panic!( + "WGPU_TRACE_DIR is set to the path \"{}\" which already contains other \ + files", + path.display() + ); + } + + path + }), + ))?; // Set error handler for wgpu errors // This is better for use than their default because it includes the error in From 85ffc33b8fdfd2b3321ef16a8896b80ecba9e4ec Mon Sep 17 00:00:00 2001 From: Imbris Date: Wed, 16 Jun 2021 00:39:26 -0400 Subject: [PATCH 5/5] Reset the slot 1 bind group to shadows when dropping the DebugDrawer --- voxygen/src/render/renderer/drawer.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/voxygen/src/render/renderer/drawer.rs b/voxygen/src/render/renderer/drawer.rs index 7e25c349d2..a41a1df1a7 100644 --- a/voxygen/src/render/renderer/drawer.rs +++ b/voxygen/src/render/renderer/drawer.rs @@ -5,7 +5,7 @@ use super::{ model::{DynamicModel, Model, SubModel}, pipelines::{ blit, clouds, debug, figure, fluid, lod_terrain, particle, shadow, skybox, sprite, - terrain, ui, ColLights, GlobalsBindGroup, + terrain, ui, ColLights, GlobalsBindGroup, ShadowTexturesBindGroup, }, }, Renderer, ShadowMap, ShadowMapRenderer, @@ -198,6 +198,7 @@ impl<'frame> Drawer<'frame> { borrow: &self.borrow, pipelines, globals: self.globals, + shadows: &shadow.bind, }) } @@ -522,6 +523,7 @@ pub struct FirstPassDrawer<'pass> { borrow: &'pass RendererBorrow<'pass>, pipelines: &'pass super::Pipelines, globals: &'pass GlobalsBindGroup, + shadows: &'pass ShadowTexturesBindGroup, } impl<'pass> FirstPassDrawer<'pass> { @@ -540,7 +542,10 @@ impl<'pass> FirstPassDrawer<'pass> { render_pass.set_pipeline(&self.pipelines.debug.pipeline); set_quad_index_buffer::(&mut render_pass, &self.borrow); - DebugDrawer { render_pass } + DebugDrawer { + render_pass, + shadows: self.shadows, + } } pub fn draw_lod_terrain<'data: 'pass>(&mut self, model: &'data Model) { @@ -613,6 +618,7 @@ impl<'pass> FirstPassDrawer<'pass> { pub struct DebugDrawer<'pass_ref, 'pass: 'pass_ref> { render_pass: Scope<'pass_ref, wgpu::RenderPass<'pass>>, + shadows: &'pass ShadowTexturesBindGroup, } impl<'pass_ref, 'pass: 'pass_ref> DebugDrawer<'pass_ref, 'pass> { @@ -627,6 +633,14 @@ impl<'pass_ref, 'pass: 'pass_ref> DebugDrawer<'pass_ref, 'pass> { } } +impl<'pass_ref, 'pass: 'pass_ref> Drop for DebugDrawer<'pass_ref, 'pass> { + fn drop(&mut self) { + // Maintain that the shadow bind group is set in + // slot 1 by default during the main pass + self.render_pass + .set_bind_group(1, &self.shadows.bind_group, &[]); + } +} pub struct FigureDrawer<'pass_ref, 'pass: 'pass_ref> { render_pass: Scope<'pass_ref, wgpu::RenderPass<'pass>>, }