Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log wgpu adapter on web #4414

Merged
merged 3 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions crates/re_renderer/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ impl RenderContext {
) -> Self {
re_tracing::profile_function!();

log_adapter_info(&adapter.get_info());

let mut gpu_resources = WgpuResourcePools::default();
let global_bindings = GlobalBindings::new(&mut gpu_resources, &device);

Expand Down Expand Up @@ -432,3 +434,66 @@ pub struct ActiveFrameContext {
/// Index of this frame. Is incremented for every render frame.
frame_index: u64,
}

fn log_adapter_info(info: &wgpu::AdapterInfo) {
re_tracing::profile_function!();

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))
};

let human_readable_summary = adapter_info_summary(info);

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!("wgpu adapter {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!("wgpu adapter {human_readable_summary}");
} else {
re_log::debug!("wgpu adapter {human_readable_summary}");
}
}

/// A human-readable summary about an adapter
fn adapter_info_summary(info: &wgpu::AdapterInfo) -> String {
let wgpu::AdapterInfo {
name,
vendor: _, // skip integer id
device: _, // skip integer id
device_type,
driver,
driver_info,
backend,
} = &info;

// Example values:
// > 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)"
// > name: "Apple M1 Pro", device_type: IntegratedGpu, backend: Metal, driver: "", driver_info: ""
// > name: "ANGLE (Apple, Apple M1 Pro, OpenGL 4.1)", device_type: IntegratedGpu, backend: Gl, driver: "", driver_info: ""

let mut summary = format!("backend: {backend:?}, device_type: {device_type:?}");

if !name.is_empty() {
summary += &format!(", name: {name:?}");
}
if !driver.is_empty() {
summary += &format!(", driver: {driver:?}");
}
if !driver_info.is_empty() {
summary += &format!(", driver_info: {driver_info:?}");
}

summary
}
56 changes: 0 additions & 56 deletions crates/re_viewer/src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,68 +15,12 @@ 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>) {
re_tracing::profile_function!();
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 {
re_tracing::profile_function!();
eframe::NativeOptions {
Expand Down
Loading