From 538d0a89eccc71e0c0b3f520d71e73b04bed9d01 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Sun, 17 Mar 2024 22:31:31 -0700 Subject: [PATCH] vk: include Wayland in the Nvidia-Intel workaround --- blade-graphics/src/vulkan/init.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/blade-graphics/src/vulkan/init.rs b/blade-graphics/src/vulkan/init.rs index 676c309e..fc12b2a0 100644 --- a/blade-graphics/src/vulkan/init.rs +++ b/blade-graphics/src/vulkan/init.rs @@ -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 @@ -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; @@ -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()