Skip to content

Commit

Permalink
Use correct portability extensions on macOS
Browse files Browse the repository at this point in the history
Closes #163
  • Loading branch information
kanerogers committed May 17, 2024
1 parent 7dec672 commit 9c517b1
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions crates/yakui-vulkan/examples/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,23 @@ impl VulkanTest {
.engine_version(0)
.api_version(vk::make_api_version(0, 1, 3, 0));

let extension_names =
#[allow(unused_mut)]
let mut extension_names =
ash_window::enumerate_required_extensions(window.display_handle().unwrap().as_raw())
.unwrap()
.to_vec();

#[cfg(target_os = "macos")]
extension_names.push(ash::khr::portability_enumeration::NAME.as_ptr());

let create_flags = if cfg!(any(target_os = "macos", target_os = "ios")) {
vk::InstanceCreateFlags::ENUMERATE_PORTABILITY_KHR
} else {
vk::InstanceCreateFlags::default()
};

let create_info = vk::InstanceCreateInfo::default()
.flags(create_flags)
.application_info(&appinfo)
.enabled_extension_names(&extension_names);

Expand Down Expand Up @@ -337,7 +348,13 @@ impl VulkanTest {
.expect("Couldn't find suitable device.")
};
let queue_family_index = queue_family_index as u32;
let device_extension_names_raw = [ash::khr::swapchain::NAME.as_ptr()];

#[allow(unused_mut)]
let mut device_exts = vec![ash::khr::swapchain::NAME.as_ptr()];

#[cfg(any(target_os = "macos"))]
device_exts.push(ash::khr::portability_subset::NAME.as_ptr());

let priorities = [1.0];

let queue_info = vk::DeviceQueueCreateInfo::default()
Expand All @@ -350,7 +367,7 @@ impl VulkanTest {

let device_create_info = vk::DeviceCreateInfo::default()
.queue_create_infos(std::slice::from_ref(&queue_info))
.enabled_extension_names(&device_extension_names_raw)
.enabled_extension_names(&device_exts)
.push_next(&mut descriptor_indexing_features);

let device = unsafe {
Expand Down

0 comments on commit 9c517b1

Please sign in to comment.