From d71ef77989647954f7c2182b701a6cc21c7d380d Mon Sep 17 00:00:00 2001 From: Fabio Lagalla Date: Tue, 30 Jul 2024 10:22:32 +0200 Subject: [PATCH 1/2] Add `DeviceRef::new_texture_with_descriptor_and_iosurface` - https://developer.apple.com/documentation/metal/mtldevice/1433425-newtexturewithdescriptor --- Cargo.toml | 1 + src/device.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index ca1e9d6..bbe3eec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,6 +35,7 @@ block = "0.1.6" foreign-types = "0.5" dispatch = { version = "0.2", optional = true } paste = "1" +io-surface = { git = "https://github.com/servo/core-foundation-rs" } [dependencies.objc] version = "0.2.4" diff --git a/src/device.rs b/src/device.rs index 12e43ae..543c716 100644 --- a/src/device.rs +++ b/src/device.rs @@ -1985,6 +1985,19 @@ impl DeviceRef { unsafe { msg_send![self, newTextureWithDescriptor: descriptor] } } + pub fn new_texture_with_descriptor_and_iosurface( + &self, + descriptor: &TextureDescriptorRef, + iosurface: io_surface::IOSurfaceRef, + plane: NSUInteger, + ) -> Texture { + unsafe { + msg_send![self, newTextureWithDescriptor:descriptor + iosurface:iosurface + plane:plane] + } + } + pub fn new_sampler(&self, descriptor: &SamplerDescriptorRef) -> SamplerState { unsafe { msg_send![self, newSamplerStateWithDescriptor: descriptor] } } From 140bc63481282507bafe66abd53f142ff4abffb8 Mon Sep 17 00:00:00 2001 From: Fabio Lagalla Date: Thu, 10 Oct 2024 11:58:30 +0200 Subject: [PATCH 2/2] device: Add architecture name --- src/device.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/device.rs b/src/device.rs index 543c716..fa62d65 100644 --- a/src/device.rs +++ b/src/device.rs @@ -1542,6 +1542,14 @@ impl Device { } impl DeviceRef { + pub fn architecture_name(&self) -> &str { + unsafe { + let arch: *const NSObject = msg_send![self, architecture]; + let name = msg_send![arch, name]; + crate::nsstring_as_str(name) + } + } + pub fn name(&self) -> &str { unsafe { let name = msg_send![self, name];