Skip to content

Commit ba9a268

Browse files
authored
Upgrade to objc2 0.6 and objc2-metal 0.3 (#261)
* Upgrade to `objc2 0.6` and `objc2-metal 0.3` The `MTLCreateSystemDefaultDevice()` function finally has a high-level wrapper that constructs a `Retained` protocol object for us. Note also that a new `MTLAllocation` interface was added to Metal. Even if that interface is _optional_, current `objc2` design requires this trait to be part of the hierarchy (and the feature explicitly enabled) to get access to all "descendant" interfaces (`MTLResource`, which provides `MTLBuffer` and `MTLTexture`). * Bump MSRV to 1.71 for `objc2`
1 parent 5d4b861 commit ba9a268

File tree

7 files changed

+17
-22
lines changed

7 files changed

+17
-22
lines changed

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: CI
44

55
jobs:
66
check_msrv:
7-
name: Check MSRV (1.70.0)
7+
name: Check MSRV (1.71.0)
88
strategy:
99
matrix:
1010
include:
@@ -20,7 +20,7 @@ jobs:
2020
- uses: dtolnay/rust-toolchain@nightly
2121
- name: Generate lockfile with minimal dependency versions
2222
run: cargo +nightly generate-lockfile -Zminimal-versions
23-
- uses: dtolnay/rust-toolchain@1.70.0
23+
- uses: dtolnay/rust-toolchain@1.71.0
2424
# Note that examples are extempt from the MSRV check, so that they can use newer Rust features
2525
- run: cargo check --workspace --features ${{ matrix.features }} --no-default-features
2626

Cargo.toml

+6-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ homepage = "https://github.com/Traverse-Research/gpu-allocator"
1010
repository = "https://github.com/Traverse-Research/gpu-allocator"
1111
keywords = ["vulkan", "memory", "allocator"]
1212
documentation = "https://docs.rs/gpu-allocator/"
13-
rust-version = "1.70"
13+
rust-version = "1.71"
1414

1515
include = [
1616
"/README.md",
@@ -34,10 +34,11 @@ egui = { version = ">=0.24, <=0.27", optional = true, default-features = false }
3434
egui_extras = { version = ">=0.24, <=0.27", optional = true, default-features = false }
3535

3636
[target.'cfg(target_vendor = "apple")'.dependencies]
37-
objc2 = { version = "0.5.2", default-features = false, optional = true }
38-
objc2-foundation = { version = "0.2", default-features = false, optional = true }
39-
objc2-metal = { version = "0.2.1", default-features = false, features = [
37+
objc2 = { version = "0.6", default-features = false, optional = true }
38+
objc2-foundation = { version = "0.3", default-features = false, optional = true }
39+
objc2-metal = { version = "0.3", default-features = false, features = [
4040
"MTLAccelerationStructure",
41+
"MTLAllocation",
4142
"MTLBuffer",
4243
"MTLDevice",
4344
"MTLHeap",
@@ -76,7 +77,7 @@ features = [
7677
]
7778

7879
[target.'cfg(target_vendor = "apple")'.dev-dependencies]
79-
objc2-metal = { version = "0.2.1", default-features = false, features = [
80+
objc2-metal = { version = "0.3", default-features = false, features = [
8081
"MTLPixelFormat",
8182
] }
8283

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE-MIT)
77
[![LICENSE](https://img.shields.io/badge/license-apache-blue.svg?logo=apache)](LICENSE-APACHE)
88
[![Contributor Covenant](https://img.shields.io/badge/contributor%20covenant-v1.4%20adopted-ff69b4.svg)](../main/CODE_OF_CONDUCT.md)
9-
[![MSRV](https://img.shields.io/badge/rustc-1.70.0+-ab6000.svg)](https://blog.rust-lang.org/2023/06/01/Rust-1.70.0.html)
9+
[![MSRV](https://img.shields.io/badge/rustc-1.71.0+-ab6000.svg)](https://blog.rust-lang.org/2023/07/13/Rust-1.71.0.html)
1010

1111
[![Banner](banner.png)](https://traverseresearch.nl)
1212

@@ -169,7 +169,7 @@ allocator.free(&allocation).unwrap();
169169

170170
## Minimum Supported Rust Version
171171

172-
The MSRV for this crate and the `vulkan`, `d3d12` and `metal` features is Rust 1.70. Any other features such as the `visualizer` (with all the `egui` dependencies) may have a higher requirement and are not tested in our CI.
172+
The MSRV for this crate and the `vulkan`, `d3d12` and `metal` features is Rust 1.71. Any other features such as the `visualizer` (with all the `egui` dependencies) may have a higher requirement and are not tested in our CI.
173173

174174
## License
175175

README.tpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE-MIT)
77
[![LICENSE](https://img.shields.io/badge/license-apache-blue.svg?logo=apache)](LICENSE-APACHE)
88
[![Contributor Covenant](https://img.shields.io/badge/contributor%20covenant-v1.4%20adopted-ff69b4.svg)](../main/CODE_OF_CONDUCT.md)
9-
[![MSRV](https://img.shields.io/badge/rustc-1.70.0+-ab6000.svg)](https://blog.rust-lang.org/2023/06/01/Rust-1.70.0.html)
9+
[![MSRV](https://img.shields.io/badge/rustc-1.71.0+-ab6000.svg)](https://blog.rust-lang.org/2023/07/13/Rust-1.71.0.html)
1010

1111
[![Banner](banner.png)](https://traverseresearch.nl)
1212

@@ -21,7 +21,7 @@ gpu-allocator = "0.27.0"
2121

2222
## Minimum Supported Rust Version
2323

24-
The MSRV for this crate and the `vulkan`, `d3d12` and `metal` features is Rust 1.70. Any other features such as the `visualizer` (with all the `egui` dependencies) may have a higher requirement and are not tested in our CI.
24+
The MSRV for this crate and the `vulkan`, `d3d12` and `metal` features is Rust 1.71. Any other features such as the `visualizer` (with all the `egui` dependencies) may have a higher requirement and are not tested in our CI.
2525

2626
## License
2727

examples/metal-buffer.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use gpu_allocator::metal::{AllocationCreateDesc, Allocator, AllocatorCreateDesc};
22
use log::info;
3-
use objc2::rc::Id;
43
use objc2_foundation::NSArray;
54
use objc2_metal::{
65
MTLCreateSystemDefaultDevice, MTLDevice as _, MTLHeap, MTLPixelFormat,
@@ -15,8 +14,7 @@ fn main() {
1514
#[link(name = "CoreGraphics", kind = "framework")]
1615
extern "C" {}
1716

18-
let device =
19-
unsafe { Id::from_raw(MTLCreateSystemDefaultDevice()) }.expect("No MTLDevice found");
17+
let device = MTLCreateSystemDefaultDevice().expect("No MTLDevice found");
2018

2119
// Setting up the allocator
2220
let mut allocator = Allocator::new(&AllocatorCreateDesc {

src/lib.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,7 @@
162162
//! # #[cfg(feature = "metal")]
163163
//! # fn main() {
164164
//! use gpu_allocator::metal::*;
165-
//! # use objc2::rc::Id;
166-
//! # let device = unsafe { objc2_metal::MTLCreateSystemDefaultDevice() };
167-
//! # let device = unsafe { Id::from_raw(device) }.expect("No MTLDevice found");
165+
//! # let device = objc2_metal::MTLCreateSystemDefaultDevice().expect("No MTLDevice found");
168166
//! let mut allocator = Allocator::new(&AllocatorCreateDesc {
169167
//! device: device.clone(),
170168
//! debug_settings: Default::default(),
@@ -181,9 +179,7 @@
181179
//! # fn main() {
182180
//! use gpu_allocator::metal::*;
183181
//! use gpu_allocator::MemoryLocation;
184-
//! # use objc2::rc::Id;
185-
//! # let device = unsafe { objc2_metal::MTLCreateSystemDefaultDevice() };
186-
//! # let device = unsafe { Id::from_raw(device) }.expect("No MTLDevice found");
182+
//! # let device = objc2_metal::MTLCreateSystemDefaultDevice().expect("No MTLDevice found");
187183
//! # let mut allocator = Allocator::new(&AllocatorCreateDesc {
188184
//! # device: device.clone(),
189185
//! # debug_settings: Default::default(),

src/metal/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ use crate::{
2020

2121
fn memory_location_to_metal(location: MemoryLocation) -> MTLResourceOptions {
2222
match location {
23-
MemoryLocation::GpuOnly => MTLResourceOptions::MTLResourceStorageModePrivate,
23+
MemoryLocation::GpuOnly => MTLResourceOptions::StorageModePrivate,
2424
MemoryLocation::CpuToGpu | MemoryLocation::GpuToCpu | MemoryLocation::Unknown => {
25-
MTLResourceOptions::MTLResourceStorageModeShared
25+
MTLResourceOptions::StorageModeShared
2626
}
2727
}
2828
}

0 commit comments

Comments
 (0)