Skip to content

Commit

Permalink
Allow controlling the graphics backend & power preference through sta…
Browse files Browse the repository at this point in the history
…ndard wgpu env vars (#1332)

* Control wgpu backend via standard environment variable
* allow to configure gpu power preference through standard wgpu env var
  • Loading branch information
Wumpf authored Feb 16, 2023
1 parent afb9cae commit 6c2b291
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 11 additions & 5 deletions crates/re_renderer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,20 @@ pub struct RenderContextConfig {
///
/// Other backend might work as well, but lack of support isn't regarded as a bug.
pub fn supported_backends() -> wgpu::Backends {
// Native - we primarily test Vulkan & Metal
// DX12 is added since as of writing some Windows VMs provide DX12 but no Vulkan drivers.
// We want to keep this list small in order to keep variance low!
// Native.
// Only use Vulkan & Metal unless explicitly told so since this reduces surfaces and thus surprises.
//
// Bunch of cases where it's still useful to switch though:
// * Some Windows VMs only provide DX12 drivers, observed with Parallels on Apple Silicon
// * May run into Linux issues that warrant trying out the GL backend.
//
// For changing the backend we use standard wgpu env var, i.e. WGPU_BACKEND.
#[cfg(not(target_arch = "wasm32"))]
{
wgpu::Backends::VULKAN | wgpu::Backends::DX12 | wgpu::Backends::METAL
wgpu::util::backend_bits_from_env()
.unwrap_or(wgpu::Backends::VULKAN | wgpu::Backends::METAL)
}
// Web - we support only WebGL right now!
// Web - we support only WebGL right now, WebGPU should work but hasn't been tested.
#[cfg(target_arch = "wasm32")]
{
wgpu::Backends::GL
Expand Down
2 changes: 2 additions & 0 deletions crates/re_viewer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ pub(crate) fn wgpu_options() -> egui_wgpu::WgpuConfiguration {
}),
backends: re_renderer::config::supported_backends(),
device_descriptor: crate::hardware_tier().device_descriptor(),
// TODO(andreas): This should be the default for egui-wgpu.
power_preference: wgpu::util::power_preference_from_env().unwrap_or(wgpu::PowerPreference::HighPerformance),
..Default::default()
}
}
Expand Down

1 comment on commit 6c2b291

@github-actions
Copy link

Choose a reason for hiding this comment

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

Rust Benchmark

Benchmark suite Current: 6c2b291 Previous: afb9cae Ratio
datastore/insert/batch/rects/insert 542075 ns/iter (± 2135) 547430 ns/iter (± 2954) 0.99
datastore/latest_at/batch/rects/query 1746 ns/iter (± 11) 1748 ns/iter (± 3) 1.00
datastore/latest_at/missing_components/primary 351 ns/iter (± 3) 352 ns/iter (± 0) 1.00
datastore/latest_at/missing_components/secondaries 421 ns/iter (± 2) 422 ns/iter (± 2) 1.00
datastore/range/batch/rects/query 151060 ns/iter (± 678) 148609 ns/iter (± 820) 1.02
mono_points_arrow/generate_message_bundles 44393906 ns/iter (± 841219) 45149364 ns/iter (± 839058) 0.98
mono_points_arrow/generate_messages 124004286 ns/iter (± 1174796) 124918323 ns/iter (± 1119446) 0.99
mono_points_arrow/encode_log_msg 150148928 ns/iter (± 856983) 151483698 ns/iter (± 1592125) 0.99
mono_points_arrow/encode_total 318953411 ns/iter (± 1828873) 325515371 ns/iter (± 1877719) 0.98
mono_points_arrow/decode_log_msg 174140439 ns/iter (± 1420162) 174315158 ns/iter (± 821935) 1.00
mono_points_arrow/decode_message_bundles 62815775 ns/iter (± 987807) 63197718 ns/iter (± 913681) 0.99
mono_points_arrow/decode_total 234945776 ns/iter (± 1825477) 237927905 ns/iter (± 1772589) 0.99
batch_points_arrow/generate_message_bundles 320185 ns/iter (± 3306) 325420 ns/iter (± 1001) 0.98
batch_points_arrow/generate_messages 6033 ns/iter (± 51) 6126 ns/iter (± 16) 0.98
batch_points_arrow/encode_log_msg 349604 ns/iter (± 2738) 353428 ns/iter (± 1244) 0.99
batch_points_arrow/encode_total 702155 ns/iter (± 6691) 704287 ns/iter (± 2763) 1.00
batch_points_arrow/decode_log_msg 346729 ns/iter (± 2321) 347394 ns/iter (± 1214) 1.00
batch_points_arrow/decode_message_bundles 1955 ns/iter (± 31) 2002 ns/iter (± 11) 0.98
batch_points_arrow/decode_total 353363 ns/iter (± 2368) 352381 ns/iter (± 1194) 1.00
arrow_mono_points/insert 6001194736 ns/iter (± 21190424) 5971622692 ns/iter (± 24600582) 1.00
arrow_mono_points/query 1667082 ns/iter (± 9421) 1670009 ns/iter (± 11002) 1.00
arrow_batch_points/insert 2604618 ns/iter (± 10908) 2607611 ns/iter (± 10051) 1.00
arrow_batch_points/query 16558 ns/iter (± 103) 16782 ns/iter (± 79) 0.99
tuid/Tuid::random 34 ns/iter (± 0) 34 ns/iter (± 0) 1

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

Please sign in to comment.