Skip to content

Commit

Permalink
vk: include Wayland in the Nvidia-Intel workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
kvark committed Mar 18, 2024
1 parent 94ed644 commit 538d0a8
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions blade-graphics/src/vulkan/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ struct AdapterCapabilities {
shader_info: bool,
}

#[derive(Debug)]
struct SystemBugs {
/// https://gitlab.freedesktop.org/mesa/mesa/-/issues/4688
intel_unable_to_present_on_xorg: bool,
intel_unable_to_present: bool,
}

// See https://github.com/canonical/nvidia-prime/blob/587c5012be9dddcc17ab4d958f10a24fa3342b4d/prime-select#L56
Expand Down Expand Up @@ -110,8 +111,7 @@ unsafe fn inspect_adapter(
log::warn!("Rejected for not presenting to the window surface");
return None;
}
if bugs.intel_unable_to_present_on_xorg
&& properties2_khr.properties.vendor_id == db::intel::VENDOR
if bugs.intel_unable_to_present && properties2_khr.properties.vendor_id == db::intel::VENDOR
{
log::warn!("Rejecting Intel for not presenting when Nvidia is present (on Linux)");
return None;
Expand Down Expand Up @@ -341,14 +341,13 @@ impl super::Context {
entry.create_instance(&create_info, None).unwrap()
};

let is_xorg = match surface_handles {
Some((_, raw_window_handle::RawDisplayHandle::Xlib(_))) => true,
Some((_, raw_window_handle::RawDisplayHandle::Xcb(_))) => true,
_ => false,
};
let bugs = SystemBugs {
intel_unable_to_present_on_xorg: is_xorg && is_nvidia_prime_forced(),
//Note: this is somewhat broad across X11/Wayland and different drivers.
// It could be narrower, but at the end of the day if the user forced Prime
// for GLX it should be safe to assume they want it for Vulkan as well.
intel_unable_to_present: is_nvidia_prime_forced(),
};
log::debug!("Bugs {:#?}", bugs);

let vk_surface = surface_handles.map(|(rwh, rdh)| {
ash_window::create_surface(&entry, &core_instance, rdh, rwh, None).unwrap()
Expand Down

0 comments on commit 538d0a8

Please sign in to comment.