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 cf91d26
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 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!(target_os = "macos") {
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(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
2 changes: 1 addition & 1 deletion crates/yakui-vulkan/src/vulkan_texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl VulkanTexture {
mag_filter,
} = create_info;

let address_mode = vk::SamplerAddressMode::REPEAT;
let address_mode = vk::SamplerAddressMode::CLAMP_TO_EDGE;
let (image, memory) = unsafe { vulkan_context.create_image(resolution, format) };
unsafe {
queue.push(vulkan_context, image, resolution, image_data.as_ref());
Expand Down

0 comments on commit cf91d26

Please sign in to comment.