Skip to content

Commit 35a9525

Browse files
madsmtmErichDonGubler
authored andcommitted
Use objc2-metal with metal naming scheme
To keep the diff smaller and easier to review, this uses a temporary fork of `objc2-metal` and `objc2-quartz-core` whose methods use the naming scheme of the `metal` crate. One particular difficult part with this is that the `metal` crate has several methods where the order of the arguments are swapped relative to the corresponding Objective-C methods. This includes most perilously (since these have both an offset and an index argument, both of which are integers): - `set_bytes` - `set_vertex_bytes` - `set_fragment_bytes` - `set_buffer` - `set_vertex_buffer` - `set_fragment_buffer` - `set_threadgroup_memory_length` But also: - `set_vertex_texture` - `set_fragment_texture` - `set_sampler_state` - `set_vertex_sampler_state` - `set_fragment_sampler_state` Another noteworthy thing to mention is that `objc2-metal` does not (yet) provide a fallback for MTLCopyAllDevices, so we have to do that ourselves: madsmtm/objc2@3543940
1 parent ab07462 commit 35a9525

File tree

11 files changed

+863
-714
lines changed

11 files changed

+863
-714
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,9 @@ By @cwfitzgerald in [#6811](https://github.com/gfx-rs/wgpu/pull/6811), [#6815](h
558558
- Move incrementation of `Device::last_acceleration_structure_build_command_index` into queue submit. By @Vecvec in [#7462](https://github.com/gfx-rs/wgpu/pull/7462).
559559
- Implement indirect draw validation. By @teoxoy in [#7140](https://github.com/gfx-rs/wgpu/pull/7140)
560560

561+
#### Metal
562+
- Use autogenerated `objc2` bindings internally, which should resolve a lot of leaks and unsoundness. By @madsmtm in [#5641](https://github.com/gfx-rs/wgpu/pull/5641).
563+
561564
#### Vulkan
562565

563566
- Stop naga causing undefined behavior when a ray query misses. By @Vecvec in [#6752](https://github.com/gfx-rs/wgpu/pull/6752).

Cargo.lock

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

Cargo.toml

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,59 @@ which = "8"
194194
xshell = "0.2.2"
195195

196196
# Metal dependencies
197-
metal = "0.32"
198-
block = "0.1.6"
199-
core-graphics-types = "0.2"
200-
objc = "0.2.5"
197+
block2 = { version = "0.6", git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
198+
objc2 = { version = "0.6", git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
199+
objc2-core-foundation = { version = "0.3", default-features = false, features = [
200+
"std",
201+
"CFCGTypes",
202+
], git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
203+
objc2-foundation = { version = "0.3", default-features = false, features = [
204+
"std",
205+
"NSError",
206+
"NSProcessInfo",
207+
"NSRange",
208+
"NSString",
209+
], git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
210+
objc2-metal = { version = "0.3", default-features = false, features = [
211+
"std",
212+
"block2",
213+
"MTLAllocation",
214+
"MTLBlitCommandEncoder",
215+
"MTLBlitPass",
216+
"MTLBuffer",
217+
"MTLCaptureManager",
218+
"MTLCaptureScope",
219+
"MTLCommandBuffer",
220+
"MTLCommandEncoder",
221+
"MTLCommandQueue",
222+
"MTLComputeCommandEncoder",
223+
"MTLComputePass",
224+
"MTLComputePipeline",
225+
"MTLCounters",
226+
"MTLDepthStencil",
227+
"MTLDevice",
228+
"MTLDrawable",
229+
"MTLEvent",
230+
"MTLLibrary",
231+
"MTLPipeline",
232+
"MTLPixelFormat",
233+
"MTLRenderCommandEncoder",
234+
"MTLRenderPass",
235+
"MTLRenderPipeline",
236+
"MTLResource",
237+
"MTLSampler",
238+
"MTLStageInputOutputDescriptor",
239+
"MTLTexture",
240+
"MTLTypes",
241+
"MTLVertexDescriptor",
242+
], git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
243+
objc2-quartz-core = { version = "0.3", default-features = false, features = [
244+
"std",
245+
"objc2-core-foundation",
246+
"CALayer",
247+
"CAMetalLayer",
248+
"objc2-metal",
249+
], git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
201250
raw-window-metal = "1.0"
202251

203252
# Vulkan dependencies

0 commit comments

Comments
 (0)