Skip to content

Commit d101c53

Browse files
committed
Update raw-window-metal to v1.0
Also improve support for tvOS, watchOS and visionOS.
1 parent c1f5ac7 commit d101c53

File tree

4 files changed

+15
-28
lines changed

4 files changed

+15
-28
lines changed

ash-examples/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl ExampleBase {
228228
.to_vec();
229229
extension_names.push(debug_utils::NAME.as_ptr());
230230

231-
#[cfg(any(target_os = "macos", target_os = "ios"))]
231+
#[cfg(target_vendor = "apple")]
232232
{
233233
extension_names.push(ash::khr::portability_enumeration::NAME.as_ptr());
234234
// Enabling this extension is a requirement when using `VK_KHR_portability_subset`
@@ -242,7 +242,7 @@ impl ExampleBase {
242242
.engine_version(0)
243243
.api_version(vk::make_api_version(0, 1, 0, 0));
244244

245-
let create_flags = if cfg!(any(target_os = "macos", target_os = "ios")) {
245+
let create_flags = if cfg!(target_vendor = "apple") {
246246
vk::InstanceCreateFlags::ENUMERATE_PORTABILITY_KHR
247247
} else {
248248
vk::InstanceCreateFlags::default()
@@ -315,7 +315,7 @@ impl ExampleBase {
315315
let queue_family_index = queue_family_index as u32;
316316
let device_extension_names_raw = [
317317
swapchain::NAME.as_ptr(),
318-
#[cfg(any(target_os = "macos", target_os = "ios"))]
318+
#[cfg(target_vendor = "apple")]
319319
ash::khr::portability_subset::NAME.as_ptr(),
320320
];
321321
let features = vk::PhysicalDeviceFeatures {

ash-window/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ rust-version = "1.69.0"
2222
ash = { path = "../ash", version = "0.38", default-features = false, features = ["std"] }
2323
raw-window-handle = "0.6"
2424

25-
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
26-
raw-window-metal = "0.4"
25+
[target.'cfg(target_vendor = "apple")'.dependencies]
26+
raw-window-metal = "1.0"
2727

2828
[dev-dependencies]
2929
winit = { version = "0.29", features = ["rwh_06"] }

ash-window/src/lib.rs

+8-16
Original file line numberDiff line numberDiff line change
@@ -95,28 +95,20 @@ pub unsafe fn create_surface(
9595
surface_fn.create_android_surface(&surface_desc, allocation_callbacks)
9696
}
9797

98-
#[cfg(target_os = "macos")]
99-
(RawDisplayHandle::AppKit(_), RawWindowHandle::AppKit(window)) => {
100-
use raw_window_metal::{appkit, Layer};
98+
#[cfg(target_vendor = "apple")]
99+
(RawDisplayHandle::AppKit(_), RawWindowHandle::AppKit(handle)) => {
100+
let layer = raw_window_metal::Layer::from_ns_view(handle.ns_view);
101101

102-
let layer = match appkit::metal_layer_from_handle(window) {
103-
Layer::Existing(layer) | Layer::Allocated(layer) => layer.cast(),
104-
};
105-
106-
let surface_desc = vk::MetalSurfaceCreateInfoEXT::default().layer(&*layer);
102+
let surface_desc = vk::MetalSurfaceCreateInfoEXT::default().layer(layer.as_ptr());
107103
let surface_fn = metal_surface::Instance::new(entry, instance);
108104
surface_fn.create_metal_surface(&surface_desc, allocation_callbacks)
109105
}
110106

111-
#[cfg(target_os = "ios")]
112-
(RawDisplayHandle::UiKit(_), RawWindowHandle::UiKit(window)) => {
113-
use raw_window_metal::{uikit, Layer};
114-
115-
let layer = match uikit::metal_layer_from_handle(window) {
116-
Layer::Existing(layer) | Layer::Allocated(layer) => layer.cast(),
117-
};
107+
#[cfg(target_vendor = "apple")]
108+
(RawDisplayHandle::UiKit(_), RawWindowHandle::UiKit(handle)) => {
109+
let layer = raw_window_metal::Layer::from_ui_view(handle.ui_view);
118110

119-
let surface_desc = vk::MetalSurfaceCreateInfoEXT::default().layer(&*layer);
111+
let surface_desc = vk::MetalSurfaceCreateInfoEXT::default().layer(layer.as_ptr());
120112
let surface_fn = metal_surface::Instance::new(entry, instance);
121113
surface_fn.create_metal_surface(&surface_desc, allocation_callbacks)
122114
}

ash/src/entry.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,14 @@ impl Entry {
6464

6565
#[cfg(all(
6666
unix,
67-
not(any(
68-
target_os = "macos",
69-
target_os = "ios",
70-
target_os = "android",
71-
target_os = "fuchsia"
72-
))
67+
not(any(target_vendor = "apple", target_os = "android", target_os = "fuchsia"))
7368
))]
7469
const LIB_PATH: &str = "libvulkan.so.1";
7570

7671
#[cfg(any(target_os = "android", target_os = "fuchsia"))]
7772
const LIB_PATH: &str = "libvulkan.so";
7873

79-
#[cfg(any(target_os = "macos", target_os = "ios"))]
74+
#[cfg(target_vendor = "apple")]
8075
const LIB_PATH: &str = "libvulkan.dylib";
8176

8277
Self::load_from(LIB_PATH)

0 commit comments

Comments
 (0)