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.
This commit is contained in:
Ian Douglas Scott 2026-03-12 14:13:42 -07:00 committed by Michael Murphy
parent 9bab56ddfc
commit a990c89758

View file

@ -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<u64, VkResult<Option<String>>>,
}
@ -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(),
})