diff --git a/crates/re_viewer/src/native.rs b/crates/re_viewer/src/native.rs index 5748a5290a51..50d39886030b 100644 --- a/crates/re_viewer/src/native.rs +++ b/crates/re_viewer/src/native.rs @@ -15,12 +15,67 @@ 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; + + // 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:?}, \ + backend: {backend:?}, \ + driver: {driver:?}, \ + driver_info: {driver_info:?}" + ) + }; + + 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 + "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_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}"); + } +} + 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 3db7c188a046..017e34729e46 100644 --- a/docs/content/getting-started/troubleshooting.md +++ b/docs/content/getting-started/troubleshooting.md @@ -32,6 +32,7 @@ rerun reset ``` ## Graphics issues +<--! This section is linked to from `crates/re_viewer/src/native.rs` --> [Wgpu](https://github.com/gfx-rs/wgpu) (the graphics API we use) maintains a list of [known driver issues](https://github.com/gfx-rs/wgpu/wiki/Known-Driver-Issues) and workarounds for them. @@ -41,6 +42,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.