From 52193f3134933cd349029b8d3857c75cf73b8a34 Mon Sep 17 00:00:00 2001 From: jasper Date: Fri, 31 Jan 2025 20:31:09 +0100 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=91=A9=E2=80=8D=F0=9F=8F=ADMissing=20?= =?UTF-8?q?features=20required=20for=20metal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index f3728678..ef898cc3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,11 +38,13 @@ objc2 = { version = "0.5.2", default-features = false, optional = true } objc2-foundation = { version = "0.2", default-features = false, optional = true } objc2-metal = { version = "0.2.1", default-features = false, features = [ "MTLAccelerationStructure", + "MTLAllocation", "MTLBuffer", "MTLDevice", "MTLHeap", "MTLResource", "MTLTexture", + "MTLHeap", "std", ], optional = true } From 5abb240824f640a8ce3deedf92ae6566a8c8c1de Mon Sep 17 00:00:00 2001 From: jasper Date: Fri, 31 Jan 2025 20:34:13 +0100 Subject: [PATCH 2/4] update-objc2 --- Cargo.toml | 8 ++++---- examples/metal-buffer.rs | 8 ++++---- src/metal/mod.rs | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ef898cc3..5ceec002 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,9 +34,9 @@ egui = { version = ">=0.24, <=0.27", optional = true, default-features = false } egui_extras = { version = ">=0.24, <=0.27", optional = true, default-features = false } [target.'cfg(target_vendor = "apple")'.dependencies] -objc2 = { version = "0.5.2", default-features = false, optional = true } -objc2-foundation = { version = "0.2", default-features = false, optional = true } -objc2-metal = { version = "0.2.1", default-features = false, features = [ +objc2 = { version = "0.6", default-features = false, features = ["std"], optional = true } +objc2-foundation = { version = "0.3", default-features = false, features = ["std"], optional = true } +objc2-metal = { version = "0.3", default-features = false, features = [ "MTLAccelerationStructure", "MTLAllocation", "MTLBuffer", @@ -78,7 +78,7 @@ features = [ ] [target.'cfg(target_vendor = "apple")'.dev-dependencies] -objc2-metal = { version = "0.2.1", default-features = false, features = [ +objc2-metal = { version = "0.3", default-features = false, features = [ "MTLPixelFormat", ] } diff --git a/examples/metal-buffer.rs b/examples/metal-buffer.rs index 869f2871..adce3602 100644 --- a/examples/metal-buffer.rs +++ b/examples/metal-buffer.rs @@ -1,9 +1,9 @@ use gpu_allocator::metal::{AllocationCreateDesc, Allocator, AllocatorCreateDesc}; use log::info; -use objc2::rc::Id; +use objc2::{rc::Retained, runtime::ProtocolObject}; use objc2_foundation::NSArray; use objc2_metal::{ - MTLCreateSystemDefaultDevice, MTLDevice as _, MTLHeap, MTLPixelFormat, + MTLCreateSystemDefaultDevice, MTLDevice, MTLHeap, MTLPixelFormat, MTLPrimitiveAccelerationStructureDescriptor, MTLStorageMode, MTLTextureDescriptor, }; @@ -15,8 +15,8 @@ fn main() { #[link(name = "CoreGraphics", kind = "framework")] extern "C" {} - let device = - unsafe { Id::from_raw(MTLCreateSystemDefaultDevice()) }.expect("No MTLDevice found"); + let device: Retained> = + MTLCreateSystemDefaultDevice().expect("No MTLDevice found"); // Setting up the allocator let mut allocator = Allocator::new(&AllocatorCreateDesc { diff --git a/src/metal/mod.rs b/src/metal/mod.rs index 6909958e..7819d49d 100644 --- a/src/metal/mod.rs +++ b/src/metal/mod.rs @@ -20,9 +20,9 @@ use crate::{ fn memory_location_to_metal(location: MemoryLocation) -> MTLResourceOptions { match location { - MemoryLocation::GpuOnly => MTLResourceOptions::MTLResourceStorageModePrivate, + MemoryLocation::GpuOnly => MTLResourceOptions::StorageModePrivate, MemoryLocation::CpuToGpu | MemoryLocation::GpuToCpu | MemoryLocation::Unknown => { - MTLResourceOptions::MTLResourceStorageModeShared + MTLResourceOptions::StorageModeShared } } } From 4106b79af3eb9394e382b84a6d7a99d2054133b4 Mon Sep 17 00:00:00 2001 From: jasper Date: Fri, 31 Jan 2025 20:44:57 +0100 Subject: [PATCH 3/4] fix-docs --- src/lib.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index ce0b14a3..51356753 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -162,9 +162,7 @@ //! # #[cfg(feature = "metal")] //! # fn main() { //! use gpu_allocator::metal::*; -//! # use objc2::rc::Id; -//! # let device = unsafe { objc2_metal::MTLCreateSystemDefaultDevice() }; -//! # let device = unsafe { Id::from_raw(device) }.expect("No MTLDevice found"); +//! # let device = objc2_metal::MTLCreateSystemDefaultDevice().expect("No MTLDevice found"); //! let mut allocator = Allocator::new(&AllocatorCreateDesc { //! device: device.clone(), //! debug_settings: Default::default(), @@ -181,9 +179,7 @@ //! # fn main() { //! use gpu_allocator::metal::*; //! use gpu_allocator::MemoryLocation; -//! # use objc2::rc::Id; -//! # let device = unsafe { objc2_metal::MTLCreateSystemDefaultDevice() }; -//! # let device = unsafe { Id::from_raw(device) }.expect("No MTLDevice found"); +//! # let device = objc2_metal::MTLCreateSystemDefaultDevice().expect("No MTLDevice found"); //! # let mut allocator = Allocator::new(&AllocatorCreateDesc { //! # device: device.clone(), //! # debug_settings: Default::default(), From 77077fa524007f4447ffc9690fa07165aa0160d8 Mon Sep 17 00:00:00 2001 From: jasper Date: Fri, 31 Jan 2025 20:46:09 +0100 Subject: [PATCH 4/4] Bump MSRV --- .github/workflows/ci.yml | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 580075dc..a6058960 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,7 @@ name: CI jobs: check_msrv: - name: Check MSRV (1.70.0) + name: Check MSRV (1.71.0) strategy: matrix: include: @@ -20,7 +20,7 @@ jobs: - uses: dtolnay/rust-toolchain@nightly - name: Generate lockfile with minimal dependency versions run: cargo +nightly generate-lockfile -Zminimal-versions - - uses: dtolnay/rust-toolchain@1.70.0 + - uses: dtolnay/rust-toolchain@1.71.0 # Note that examples are extempt from the MSRV check, so that they can use newer Rust features - run: cargo check --workspace --features ${{ matrix.features }} --no-default-features diff --git a/Cargo.toml b/Cargo.toml index 5ceec002..67937944 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ homepage = "https://github.com/Traverse-Research/gpu-allocator" repository = "https://github.com/Traverse-Research/gpu-allocator" keywords = ["vulkan", "memory", "allocator"] documentation = "https://docs.rs/gpu-allocator/" -rust-version = "1.70" +rust-version = "1.71" include = [ "/README.md",