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

Improve logging around surface creation #6511

Merged
merged 4 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
33 changes: 29 additions & 4 deletions wgpu-core/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ impl Instance {
let hal_adapters = unsafe { instance.enumerate_adapters(None) };
for raw in hal_adapters {
let adapter = Adapter::new(raw);
log::info!("Adapter {:?}", adapter.raw.info);
log::debug!("Adapter {:?}", adapter.raw.info);
adapters.push(adapter);
}
}
Expand Down Expand Up @@ -336,8 +336,19 @@ impl Instance {
backend_adapters.retain(|exposed| exposed.info.device_type == wgt::DeviceType::Cpu);
}
if let Some(surface) = desc.compatible_surface {
backend_adapters
.retain(|exposed| surface.get_capabilities_with_raw(exposed).is_ok());
backend_adapters.retain(|exposed| {
let capabilities = surface.get_capabilities_with_raw(exposed);
if let Err(err) = capabilities {
log::debug!(
"Adapter {:?} not compatible with surface: {}",
exposed.info,
err
);
false
} else {
true
}
});
}
adapters.extend(backend_adapters);
}
Expand Down Expand Up @@ -378,8 +389,22 @@ impl Instance {
}
}

// `request_adapter` can be a bit of a black box.
// Shine some light on its decision in debug log.
if adapters.is_empty() {
log::debug!("Request adapter didn't find compatible adapters.");
} else {
log::debug!(
"Found {} compatible adapters. Sorted by preference:",
adapters.len()
);
for adapter in &adapters {
log::debug!("* {:?}", adapter.info);
}
}

if let Some(adapter) = adapters.into_iter().next() {
log::info!("Adapter {:?}", adapter.info);
log::debug!("Request adapter result {:?}", adapter.info);
let adapter = Adapter::new(adapter);
Ok(adapter)
} else {
Expand Down
4 changes: 2 additions & 2 deletions wgpu-hal/src/vulkan/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,11 @@ impl super::Instance {
callback_data: debug_utils_create_info.callback_data,
})
} else {
log::info!("Debug utils not enabled: extension not listed");
log::debug!("Debug utils not enabled: extension not listed");
None
}
} else {
log::info!(
log::debug!(
"Debug utils not enabled: \
debug_utils_user_data not passed to Instance::from_raw"
);
Expand Down
1 change: 1 addition & 0 deletions wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ pub struct RequestAdapterOptions<S> {
pub force_fallback_adapter: bool,
/// Surface that is required to be presentable with the requested adapter. This does not
/// create the surface, only guarantees that the adapter can present to said surface.
/// For WebGL, this is strictly required, as an adapter can not be created without a surface.
pub compatible_surface: Option<S>,
}

Expand Down
Loading