Skip to content

Commit f4287f9

Browse files
committed
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 0931958 commit f4287f9

File tree

11 files changed

+884
-720
lines changed

11 files changed

+884
-720
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,9 @@ By @cwfitzgerald in [#6811](https://github.com/gfx-rs/wgpu/pull/6811), [#6815](h
397397
- 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).
398398
- Implement indirect draw validation. By @teoxoy in [#7140](https://github.com/gfx-rs/wgpu/pull/7140)
399399

400+
#### Metal
401+
- 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).
402+
400403
#### Vulkan
401404

402405
- 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
@@ -158,10 +158,59 @@ walkdir = "2.3.0"
158158
winit = { version = "0.29", features = ["android-native-activity"] }
159159

160160
# Metal dependencies
161-
metal = "0.32.0"
162-
block = "0.1.6"
163-
core-graphics-types = "0.2"
164-
objc = "0.2.5"
161+
block2 = { version = "0.6", git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
162+
objc2 = { version = "0.6", git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
163+
objc2-core-foundation = { version = "0.3", default-features = false, features = [
164+
"std",
165+
"CFCGTypes",
166+
], git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
167+
objc2-foundation = { version = "0.3", default-features = false, features = [
168+
"std",
169+
"NSError",
170+
"NSProcessInfo",
171+
"NSRange",
172+
"NSString",
173+
], git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
174+
objc2-metal = { version = "0.3", default-features = false, features = [
175+
"std",
176+
"block2",
177+
"MTLAllocation",
178+
"MTLBlitCommandEncoder",
179+
"MTLBlitPass",
180+
"MTLBuffer",
181+
"MTLCaptureManager",
182+
"MTLCaptureScope",
183+
"MTLCommandBuffer",
184+
"MTLCommandEncoder",
185+
"MTLCommandQueue",
186+
"MTLComputeCommandEncoder",
187+
"MTLComputePass",
188+
"MTLComputePipeline",
189+
"MTLCounters",
190+
"MTLDepthStencil",
191+
"MTLDevice",
192+
"MTLDrawable",
193+
"MTLEvent",
194+
"MTLLibrary",
195+
"MTLPipeline",
196+
"MTLPixelFormat",
197+
"MTLRenderCommandEncoder",
198+
"MTLRenderPass",
199+
"MTLRenderPipeline",
200+
"MTLResource",
201+
"MTLSampler",
202+
"MTLStageInputOutputDescriptor",
203+
"MTLTexture",
204+
"MTLTypes",
205+
"MTLVertexDescriptor",
206+
], git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
207+
objc2-quartz-core = { version = "0.3", default-features = false, features = [
208+
"std",
209+
"objc2-core-foundation",
210+
"CALayer",
211+
"CAMetalLayer",
212+
"objc2-metal",
213+
], git = "https://github.com/madsmtm/objc2", branch = "metal-wgpu" }
165214
raw-window-metal = "1.0"
166215

167216
# Vulkan dependencies

0 commit comments

Comments
 (0)