From a85f02688c141a4caf34b77375363eb69bf95c7b Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 29 Aug 2023 10:41:18 +0200 Subject: [PATCH 1/3] Warn if using software rasterizer (lavapipe or llvmpipe) * Closes https://github.com/rerun-io/rerun/issues/3089 --- crates/re_viewer/src/native.rs | 48 +++++++++++++++++++ .../getting-started/troubleshooting.md | 3 ++ 2 files changed, 51 insertions(+) diff --git a/crates/re_viewer/src/native.rs b/crates/re_viewer/src/native.rs index 3404e31dff7a..9bfc2e8ebd8b 100644 --- a/crates/re_viewer/src/native.rs +++ b/crates/re_viewer/src/native.rs @@ -12,12 +12,60 @@ pub fn run_native_app(app_creator: AppCreator) -> eframe::Result<()> { window_title, native_options, Box::new(move |cc| { + check_graphics_driver(cc.wgpu_render_state.as_ref()); let re_ui = crate::customize_eframe(cc); app_creator(cc, re_ui) }), ) } +fn check_graphics_driver(wgpu_render_state: Option<&egui_wgpu::RenderState>) { + let wgpu_render_state = wgpu_render_state.expect("Expected wgpu to be enabled"); + let info = wgpu_render_state.adapter.get_info(); + + let human_readable_summary = { + let wgpu::AdapterInfo { + name, + vendor: _, // skip integer id + device: _, // skip integer id + device_type, + driver, + driver_info, + backend, + } = &info; + + format!( + "wgpu adapter name: {name:?}, \ + device_type: {device_type:?}, \ + backend: {backend:?}, \ + driver: {driver:?}, \ + driver_info: {driver_info:?}" + ) + }; + + let is_known_software_rasterizer = { + // See https://github.com/rerun-io/rerun/issues/3089 + const KNOWN_SOFTWARE_RASTERIZERS: &[&str] = &[ + "lavapipe", // Vulkan software rasterizer + "llvmpipe", // OpenGL software rasterizer + ]; + + // I'm not sure where the incriminating string will appear, so check all fields at once: + let info_string = format!("{info:?}").to_lowercase(); + + KNOWN_SOFTWARE_RASTERIZERS + .iter() + .any(|&software_rasterizer| info_string.contains(software_rasterizer)) + }; + + if is_known_software_rasterizer { + re_log::warn!("Software rasterizer detected - expect poor performance and crashes. See: https://www.rerun.io/docs/getting-started/troubleshooting#graphics-issues"); + re_log::info!("{human_readable_summary}"); + } else { + re_log::debug!("{human_readable_summary}"); + } +} + pub fn eframe_options() -> eframe::NativeOptions { eframe::NativeOptions { // Controls where on disk the app state is persisted. diff --git a/docs/content/getting-started/troubleshooting.md b/docs/content/getting-started/troubleshooting.md index a508b5e76842..ddda41025922 100644 --- a/docs/content/getting-started/troubleshooting.md +++ b/docs/content/getting-started/troubleshooting.md @@ -24,6 +24,7 @@ On WSL2, in addition to the above packages for Linux, you also need to run: [TODO(#1250)](https://github.com/rerun-io/rerun/issues/1250): Running with the wayland window manager sometimes causes Rerun to crash. Try setting `WINIT_UNIX_BACKEND=x11` as a workaround. +<--! This section is linked to from `crates/re_viewer/src/native.rs` --> ## Graphics issues [Wgpu](https://github.com/gfx-rs/wgpu) (the graphics API we use) maintains a list of @@ -34,6 +35,8 @@ The following environment variables overwrite the config we choose for wgpu: Naturally, support depends on your OS. Default is `vulkan` everywhere except on Mac where we use `metal`. * `WGPU_POWER_PREF`: Overwrites the power setting used for choosing a graphics adapter, must be `high` or `low`. (Default is `high`) +For instance, you can try `WGPU_BACKEND=gl rerun`. + We recommend setting these only if you're asked to try them or know what you're doing, since we don't support all of these settings equally well. From fe6afe3a53ba014e76773a34bc427113ae4d9981 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 30 Aug 2023 10:27:26 +0200 Subject: [PATCH 2/3] Warn about all `device_type == Cpu` --- crates/re_viewer/src/native.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/re_viewer/src/native.rs b/crates/re_viewer/src/native.rs index 6784e2f70a28..c13409857c53 100644 --- a/crates/re_viewer/src/native.rs +++ b/crates/re_viewer/src/native.rs @@ -46,7 +46,7 @@ fn check_graphics_driver(wgpu_render_state: Option<&egui_wgpu::RenderState>) { ) }; - let is_known_software_rasterizer = { + let is_software_rasterizer_with_known_crashes = { // See https://github.com/rerun-io/rerun/issues/3089 const KNOWN_SOFTWARE_RASTERIZERS: &[&str] = &[ "lavapipe", // Vulkan software rasterizer @@ -61,9 +61,12 @@ fn check_graphics_driver(wgpu_render_state: Option<&egui_wgpu::RenderState>) { .any(|&software_rasterizer| info_string.contains(software_rasterizer)) }; - if is_known_software_rasterizer { + if is_software_rasterizer_with_known_crashes { re_log::warn!("Software rasterizer detected - expect poor performance and crashes. See: https://www.rerun.io/docs/getting-started/troubleshooting#graphics-issues"); re_log::info!("{human_readable_summary}"); + } else if info.device_type == wgpu::DeviceType::Cpu { + re_log::warn!("Software rasterizer detected - expect poor performance. See: https://www.rerun.io/docs/getting-started/troubleshooting#graphics-issues"); + re_log::info!("{human_readable_summary}"); } else { re_log::debug!("{human_readable_summary}"); } From 7fe03de920836b35fab0903613a762a12e0ed4e2 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 30 Aug 2023 11:18:08 +0200 Subject: [PATCH 3/3] Add example outputs --- crates/re_viewer/src/native.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/re_viewer/src/native.rs b/crates/re_viewer/src/native.rs index c13409857c53..50d39886030b 100644 --- a/crates/re_viewer/src/native.rs +++ b/crates/re_viewer/src/native.rs @@ -37,6 +37,10 @@ fn check_graphics_driver(wgpu_render_state: Option<&egui_wgpu::RenderState>) { backend, } = &info; + // Example outputs: + // > wgpu adapter name: "llvmpipe (LLVM 16.0.6, 256 bits)", device_type: Cpu, backend: Vulkan, driver: "llvmpipe", driver_info: "Mesa 23.1.6-arch1.4 (LLVM 16.0.6)" + // > wgpu adapter name: "Apple M1 Pro", device_type: IntegratedGpu, backend: Metal, driver: "", driver_info: "" + format!( "wgpu adapter name: {name:?}, \ device_type: {device_type:?}, \