Skip to content

Commit 6648295

Browse files
committed
Use objc2-metal
1 parent 18b758e commit 6648295

File tree

12 files changed

+1144
-1004
lines changed

12 files changed

+1144
-1004
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ By @atlv24 and @cwfitzgerald in [#5154](https://github.com/gfx-rs/wgpu/pull/5154
221221
#### Metal
222222

223223
- Metal 3.0 and 3.1 detection. By @atlv24 in [#5497](https://github.com/gfx-rs/wgpu/pull/5497)
224+
- Use autogenerated `objc2` bindings internally, which should resolve a lot of leaks. By @madsmtm in [#5641](https://github.com/gfx-rs/wgpu/pull/5641).
224225

225226
#### DX12
226227

Cargo.lock

Lines changed: 67 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,13 @@ termcolor = "1.4.1"
192192
#web-sys = { path = "../wasm-bindgen/crates/web-sys" }
193193
#js-sys = { path = "../wasm-bindgen/crates/js-sys" }
194194
#wasm-bindgen = { path = "../wasm-bindgen" }
195+
block2 = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
196+
objc2 = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
197+
objc2-encode = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
198+
objc-sys = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
199+
objc2-foundation = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
200+
objc2-quartz-core = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
201+
objc2-metal = { git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
195202

196203
[profile.release]
197204
lto = "thin"

wgpu-hal/Cargo.toml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ ignored = ["cfg_aliases"]
3838

3939
[features]
4040
default = ["link"]
41-
metal = ["naga/msl-out", "dep:block"]
41+
metal = ["naga/msl-out"]
4242
vulkan = [
4343
"naga/spv-out",
4444
"dep:ash",
@@ -76,7 +76,7 @@ windows_rs = ["dep:gpu-allocator"]
7676
dxc_shader_compiler = ["dep:hassle-rs"]
7777
renderdoc = ["dep:libloading", "dep:renderdoc-sys"]
7878
fragile-send-sync-non-atomic-wasm = ["wgt/fragile-send-sync-non-atomic-wasm"]
79-
link = ["metal/link"]
79+
link = []
8080
# Panic when running into an out-of-memory error (for debugging purposes).
8181
#
8282
# Only affects the d3d12 and vulkan backends.
@@ -156,13 +156,13 @@ d3d12 = { path = "../d3d12/", version = "0.20.0", optional = true, features = [
156156
"libloading",
157157
] }
158158

159-
[target.'cfg(any(target_os="macos", target_os="ios"))'.dependencies]
160159
# backend: Metal
161-
block = { version = "0.1", optional = true }
162-
163-
metal = { version = "0.28.0" }
164-
objc = "0.2.5"
165-
core-graphics-types = "0.1"
160+
[target.'cfg(any(target_os="macos", target_os="ios"))'.dependencies]
161+
objc2 = "0.5.1"
162+
objc2-foundation = { version = "0.2.0", features = ["all"] }
163+
objc2-quartz-core = { version = "0.2.0", features = ["all"] }
164+
objc2-metal = { version = "0.2.0", features = ["all"] }
165+
block2 = "0.5"
166166

167167
[target.'cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))'.dependencies]
168168
wasm-bindgen = "0.2.87"

wgpu-hal/src/gles/egl.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,10 +1261,11 @@ impl crate::Surface for Surface {
12611261
let window_ptr = handle.ns_view.as_ptr();
12621262
#[cfg(target_os = "macos")]
12631263
let window_ptr = {
1264-
use objc::{msg_send, runtime::Object, sel, sel_impl};
1264+
use objc2::msg_send;
1265+
use objc2::runtime::AnyObject;
12651266
// ns_view always have a layer and don't need to verify that it exists.
1266-
let layer: *mut Object =
1267-
msg_send![handle.ns_view.as_ptr() as *mut Object, layer];
1267+
let layer: *mut AnyObject =
1268+
msg_send![handle.ns_view.as_ptr() as *mut AnyObject, layer];
12681269
layer as *mut ffi::c_void
12691270
};
12701271
window_ptr

0 commit comments

Comments
 (0)