From 4abce86402906ee0d31561433ed151d20e087e66 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Thu, 12 Mar 2026 14:13:42 -0700 Subject: [PATCH 1/2] backend/wayland/vulkan: Fix use of Vulkan (correctly this time) It seems https://github.com/pop-os/cosmic-workspaces-epoch/pull/280 was just wrong. I didn't test it correctly, and it actually prevented crashes simply because the Vulkan instance failed to create. This failed because it's a device extension, not an instance extension (and we already check for the device extension). The *real* issue seems to be simply the fact this was using the `Instance` after dropping the `Entry`. Which is easy enough to address. --- src/backend/wayland/vulkan.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/wayland/vulkan.rs b/src/backend/wayland/vulkan.rs index 25dcedf..244a096 100644 --- a/src/backend/wayland/vulkan.rs +++ b/src/backend/wayland/vulkan.rs @@ -3,6 +3,7 @@ use std::{collections::HashMap, ffi::CStr}; pub struct Vulkan { instance: ash::Instance, + _entry: ash::Entry, // TODO purge cache at some point device_name_cache: HashMap>>, } @@ -14,14 +15,13 @@ impl Vulkan { api_version: vk::make_api_version(0, 1, 1, 0), ..Default::default() }; - let extensions = &[c"VK_EXT_physical_device_drm".as_ptr()]; let create_info = vk::InstanceCreateInfo { p_application_info: &app_info, ..Default::default() - } - .enabled_extension_names(extensions); + }; let instance = unsafe { entry.create_instance(&create_info, None).ok()? }; Some(Self { + _entry: entry, instance, device_name_cache: HashMap::new(), }) From 1ab2eba6578e37e7a8f6fa0d6a6b23645ef547df Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Thu, 12 Mar 2026 14:26:23 -0700 Subject: [PATCH 2/2] Add `log::info!`/`log::error!` for Vulkan issues --- src/backend/wayland/mod.rs | 10 +++++++++- src/backend/wayland/vulkan.rs | 11 +++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/backend/wayland/mod.rs b/src/backend/wayland/mod.rs index 4413c1d..cf0b3f1 100644 --- a/src/backend/wayland/mod.rs +++ b/src/backend/wayland/mod.rs @@ -283,6 +283,14 @@ fn start(conn: Connection) -> mpsc::Receiver { // spawn an executor using one additional thread. let thread_pool = ThreadPool::builder().pool_size(1).create().unwrap(); + let vulkan = vulkan::Vulkan::new(); + if let Err(err) = &vulkan { + log::info!( + "Unable to initialize Vulkan: {}. Assuming now GPU workarounds needed.", + err + ); + } + let registry_state = RegistryState::new(&globals); let mut app_data = AppData { qh: qh.clone(), @@ -300,7 +308,7 @@ fn start(conn: Connection) -> mpsc::Receiver { dmabuf_feedback: None, gbm_devices: GbmDevices::default(), thread_pool, - vulkan: vulkan::Vulkan::new(), + vulkan: vulkan.ok(), }; let (cmd_sender, cmd_channel) = calloop::channel::channel(); diff --git a/src/backend/wayland/vulkan.rs b/src/backend/wayland/vulkan.rs index 244a096..a177452 100644 --- a/src/backend/wayland/vulkan.rs +++ b/src/backend/wayland/vulkan.rs @@ -9,8 +9,8 @@ pub struct Vulkan { } impl Vulkan { - pub fn new() -> Option { - let entry = unsafe { ash::Entry::load().ok()? }; + pub fn new() -> anyhow::Result { + let entry = unsafe { ash::Entry::load()? }; let app_info = vk::ApplicationInfo { api_version: vk::make_api_version(0, 1, 1, 0), ..Default::default() @@ -19,8 +19,8 @@ impl Vulkan { p_application_info: &app_info, ..Default::default() }; - let instance = unsafe { entry.create_instance(&create_info, None).ok()? }; - Some(Self { + let instance = unsafe { entry.create_instance(&create_info, None)? }; + Ok(Self { _entry: entry, instance, device_name_cache: HashMap::new(), @@ -30,6 +30,9 @@ impl Vulkan { pub fn device_name(&mut self, dev: u64) -> VkResult> { if !self.device_name_cache.contains_key(&dev) { let value = self.device_name_uncached(dev); + if let Err(err) = &value { + log::error!("Failed to query Vulkan device properties: {}", err); + } self.device_name_cache.insert(dev, value); } self.device_name_cache