Skip to content

Commit

Permalink
Fix build on macos
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexagon committed Feb 5, 2024
1 parent f914a5a commit 90a8404
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions vulkanalia/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
13 changes: 5 additions & 8 deletions vulkanalia/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
Expand Down Expand Up @@ -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};
Expand All @@ -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());
Expand All @@ -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::<c_void>();
Expand Down

0 comments on commit 90a8404

Please sign in to comment.