diff --git a/ash-examples/src/lib.rs b/ash-examples/src/lib.rs index e1c2e2670..16446068c 100644 --- a/ash-examples/src/lib.rs +++ b/ash-examples/src/lib.rs @@ -228,7 +228,7 @@ impl ExampleBase { .to_vec(); extension_names.push(debug_utils::NAME.as_ptr()); - #[cfg(any(target_os = "macos", target_os = "ios"))] + #[cfg(target_vendor = "apple")] { extension_names.push(ash::khr::portability_enumeration::NAME.as_ptr()); // Enabling this extension is a requirement when using `VK_KHR_portability_subset` @@ -242,7 +242,7 @@ impl ExampleBase { .engine_version(0) .api_version(vk::make_api_version(0, 1, 0, 0)); - let create_flags = if cfg!(any(target_os = "macos", target_os = "ios")) { + let create_flags = if cfg!(target_vendor = "apple") { vk::InstanceCreateFlags::ENUMERATE_PORTABILITY_KHR } else { vk::InstanceCreateFlags::default() @@ -315,7 +315,7 @@ impl ExampleBase { let queue_family_index = queue_family_index as u32; let device_extension_names_raw = [ swapchain::NAME.as_ptr(), - #[cfg(any(target_os = "macos", target_os = "ios"))] + #[cfg(target_vendor = "apple")] ash::khr::portability_subset::NAME.as_ptr(), ]; let features = vk::PhysicalDeviceFeatures { diff --git a/ash-window/Cargo.toml b/ash-window/Cargo.toml index fc04e14a1..831e7a59f 100644 --- a/ash-window/Cargo.toml +++ b/ash-window/Cargo.toml @@ -22,8 +22,8 @@ rust-version = "1.69.0" ash = { path = "../ash", version = "0.38", default-features = false, features = ["std"] } raw-window-handle = "0.6" -[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies] -raw-window-metal = "0.4" +[target.'cfg(target_vendor = "apple")'.dependencies] +raw-window-metal = "1.0" [dev-dependencies] winit = { version = "0.29", features = ["rwh_06"] } diff --git a/ash-window/README.md b/ash-window/README.md index 307222874..2c3f00a79 100644 --- a/ash-window/README.md +++ b/ash-window/README.md @@ -41,7 +41,7 @@ ash = "0.37" - [x] Windows (`VK_KHR_win32_surface`) - [x] Unix (`VK_KHR_xlib_surface`/`VK_KHR_xcb_surface`/`VK_KHR_wayland_surface`) -- [x] MacOS/IOS (`VK_EXT_metal_surface`) +- [x] macOS/iOS/tvOS (`VK_EXT_metal_surface`) - [x] Android (`VK_KHR_android_surface`) ## License diff --git a/ash-window/src/lib.rs b/ash-window/src/lib.rs index edb001a29..857ec51a2 100644 --- a/ash-window/src/lib.rs +++ b/ash-window/src/lib.rs @@ -95,28 +95,20 @@ pub unsafe fn create_surface( surface_fn.create_android_surface(&surface_desc, allocation_callbacks) } - #[cfg(target_os = "macos")] - (RawDisplayHandle::AppKit(_), RawWindowHandle::AppKit(window)) => { - use raw_window_metal::{appkit, Layer}; + #[cfg(target_vendor = "apple")] + (RawDisplayHandle::AppKit(_), RawWindowHandle::AppKit(handle)) => { + let layer = raw_window_metal::Layer::from_ns_view(handle.ns_view); - let layer = match appkit::metal_layer_from_handle(window) { - Layer::Existing(layer) | Layer::Allocated(layer) => layer.cast(), - }; - - let surface_desc = vk::MetalSurfaceCreateInfoEXT::default().layer(&*layer); + let surface_desc = vk::MetalSurfaceCreateInfoEXT::default().layer(layer.as_ptr()); let surface_fn = metal_surface::Instance::new(entry, instance); surface_fn.create_metal_surface(&surface_desc, allocation_callbacks) } - #[cfg(target_os = "ios")] - (RawDisplayHandle::UiKit(_), RawWindowHandle::UiKit(window)) => { - use raw_window_metal::{uikit, Layer}; - - let layer = match uikit::metal_layer_from_handle(window) { - Layer::Existing(layer) | Layer::Allocated(layer) => layer.cast(), - }; + #[cfg(target_vendor = "apple")] + (RawDisplayHandle::UiKit(_), RawWindowHandle::UiKit(handle)) => { + let layer = raw_window_metal::Layer::from_ui_view(handle.ui_view); - let surface_desc = vk::MetalSurfaceCreateInfoEXT::default().layer(&*layer); + let surface_desc = vk::MetalSurfaceCreateInfoEXT::default().layer(layer.as_ptr()); let surface_fn = metal_surface::Instance::new(entry, instance); surface_fn.create_metal_surface(&surface_desc, allocation_callbacks) } diff --git a/ash/src/entry.rs b/ash/src/entry.rs index 3a26b18a9..4eb330578 100644 --- a/ash/src/entry.rs +++ b/ash/src/entry.rs @@ -64,19 +64,14 @@ impl Entry { #[cfg(all( unix, - not(any( - target_os = "macos", - target_os = "ios", - target_os = "android", - target_os = "fuchsia" - )) + not(any(target_vendor = "apple", target_os = "android", target_os = "fuchsia")) ))] const LIB_PATH: &str = "libvulkan.so.1"; #[cfg(any(target_os = "android", target_os = "fuchsia"))] const LIB_PATH: &str = "libvulkan.so"; - #[cfg(any(target_os = "macos", target_os = "ios"))] + #[cfg(target_vendor = "apple")] const LIB_PATH: &str = "libvulkan.dylib"; Self::load_from(LIB_PATH)