diff --git a/vulkanalia/Cargo.toml b/vulkanalia/Cargo.toml index 4fba8f4..d72d305 100644 --- a/vulkanalia/Cargo.toml +++ b/vulkanalia/Cargo.toml @@ -36,8 +36,8 @@ vulkanalia-sys = { version = "0.22", path = "../vulkanalia-sys", default-feature [target.'cfg(target_os = "macos")'.dependencies] -cocoa = { version = "0.24", optional = true } -metal = { version = "0.21", optional = true } +cocoa = { version = "0.25", optional = true } +metal = { version = "0.27", optional = true } objc = { version = "0.2", optional = true } [package.metadata.docs.rs] diff --git a/vulkanalia/src/window.rs b/vulkanalia/src/window.rs index 8fef38e..fd265eb 100644 --- a/vulkanalia/src/window.rs +++ b/vulkanalia/src/window.rs @@ -47,13 +47,13 @@ pub fn get_required_instance_extensions( ], // macOS #[cfg(target_os = "macos")] - Ok(RawWindowHandle::AppKit(window)) => &[ + Ok(RawWindowHandle::AppKit(_window)) => &[ &vk::KHR_SURFACE_EXTENSION.name, &vk::EXT_METAL_SURFACE_EXTENSION.name, ], // Windows #[cfg(target_os = "windows")] - Ok(RawWindowHandle::Win32(_)) => &[ + Ok(RawWindowHandle::Win32(_window)) => &[ &vk::KHR_SURFACE_EXTENSION.name, &vk::KHR_WIN32_SURFACE_EXTENSION.name, ], @@ -138,7 +138,6 @@ pub unsafe fn create_surface( // macOS #[cfg(target_os = "macos")] (Ok(RawDisplayHandle::AppKit(_)), Ok(RawWindowHandle::AppKit(window))) => { - use std::mem; use std::os::raw::c_void; use cocoa::appkit::{NSView, NSWindow}; @@ -147,10 +146,8 @@ pub unsafe fn create_surface( use objc::runtime::YES; use vk::ExtMetalSurfaceExtension; - let (view, layer) = { - let id = mem::transmute::<_, id>(window.ns_window); - - let view = id.contentView(); + let layer = { + let view = window.ns_view.as_ptr() as id; let layer = MetalLayer::new(); layer.set_contents_scale(view.backingScaleFactor()); @@ -162,7 +159,7 @@ pub unsafe fn create_surface( view.setLayer(layer_ref as *mut objc::runtime::Object); view.setWantsLayer(YES); - (&mut *window.ns_view, layer) + layer }; let layer = (layer.as_ref() as *const MetalLayerRef).cast::();