Skip to content

Commit

Permalink
Warn if using software rasterizer (lavapipe or llvmpipe) (#3134)
Browse files Browse the repository at this point in the history
* Closes #3089

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/3134) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/3134)
- [Docs
preview](https://rerun.io/preview/7fe03de920836b35fab0903613a762a12e0ed4e2/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/7fe03de920836b35fab0903613a762a12e0ed4e2/examples)
<!--EXAMPLES-PREVIEW--><!--EXAMPLES-PREVIEW--><!--EXAMPLES-PREVIEW--><!--EXAMPLES-PREVIEW--><!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://ref.rerun.io/dev/bench/)
- [Wasm size tracking](https://ref.rerun.io/dev/sizes/)
  • Loading branch information
emilk committed Aug 30, 2023
1 parent ea543a1 commit d9207a2
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
55 changes: 55 additions & 0 deletions crates/re_viewer/src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions docs/content/getting-started/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.

Expand Down

1 comment on commit d9207a2

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Rust Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.25.

Benchmark suite Current: d9207a2 Previous: ea543a1 Ratio
datastore/num_rows=1000/num_instances=1000/packed=false/latest_at_missing/secondaries/default 449 ns/iter (± 11) 359 ns/iter (± 1) 1.25

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.