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

Limit the Intel presentation bug to Xorg only #94

Merged
merged 1 commit into from
Mar 13, 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
31 changes: 19 additions & 12 deletions blade-graphics/src/vulkan/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,16 @@ struct AdapterCapabilities {
shader_info: bool,
}

struct SystemBugs {
/// https://gitlab.freedesktop.org/mesa/mesa/-/issues/4688
intel_unable_to_present_on_xorg: bool,
}

unsafe fn inspect_adapter(
phd: vk::PhysicalDevice,
instance: &super::Instance,
driver_api_version: u32,
supported_layers: &[&ffi::CStr],
bugs: &SystemBugs,
surface: Option<vk::SurfaceKHR>,
) -> Option<AdapterCapabilities> {
let supported_extension_properties = instance
Expand Down Expand Up @@ -99,11 +104,9 @@ unsafe fn inspect_adapter(
log::warn!("Rejected for not presenting to the window surface");
return None;
}
if cfg!(target_os = "linux")
if bugs.intel_unable_to_present_on_xorg
&& properties2_khr.properties.vendor_id == db::intel::VENDOR
&& supported_layers.contains(&layer::NV_OPTIMUS)
{
// https://gitlab.freedesktop.org/mesa/mesa/-/issues/4688
log::warn!("Rejecting Intel for not presenting when Nvidia is present (on Linux)");
return None;
}
Expand Down Expand Up @@ -332,6 +335,16 @@ 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
&& supported_layer_names.contains(&layer::NV_OPTIMUS),
};

let vk_surface = surface_handles.map(|(rwh, rdh)| {
ash_window::create_surface(&entry, &core_instance, rdh, rwh, None).unwrap()
});
Expand All @@ -354,14 +367,8 @@ impl super::Context {
let (physical_device, capabilities) = physical_devices
.into_iter()
.find_map(|phd| {
inspect_adapter(
phd,
&instance,
driver_api_version,
&supported_layer_names,
vk_surface,
)
.map(|caps| (phd, caps))
inspect_adapter(phd, &instance, driver_api_version, &bugs, vk_surface)
.map(|caps| (phd, caps))
})
.ok_or(crate::NotSupportedError)?;

Expand Down
Loading