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

vk: include Wayland in the Nvidia-Intel workaround #97

Merged
merged 1 commit into from
Mar 18, 2024
Merged
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
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(),

Choose a reason for hiding this comment

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

This only applies to Xorg. Wayland completely ignores this, but using it as an indication of desired behaviour may work here.

Choose a reason for hiding this comment

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

The general expected behaviour of desktop applications is that they default to igpu unless one of

PrefersNonDefaultGPU=false
X-KDE-RunOnDiscreteGpu=false

is set in the application.desktop file, or some desktops provide a method to offload with right-click menu.

However when it comes to games, typically vulkan defaults to dgpu. While opengl requires intervention.

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