Repository navigation
feat(metal): implement dispatch_workgroups_indirect on native Metal backend - #2642
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements
ComputePass::dispatch_workgroups_indirecton Rune's native Apple Metal backend instead of panicking withunsupported!("indirect dispatches").Addresses #2545
Design
crates/rune-gpu/src/indirect.rs): ValidatesBufferUsages::INDIRECT, 4-byte offset alignment, and overflow-checkedoffset..offset + 12bounds against the logical buffer size (DispatchIndirectArgs) before issuing the unsafe Metal call. Invalid calls report awgpu::Error::Validationthrough the thread's active error scope (or panic when uncaptured).crates/rune-gpu/src/metal/compute.rs): TracksMetalBuffer::usage, flushes dirty bind groups / storage buffer swaps / sizes / immediates, forwards todispatchThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerThreadgroup:with the bound pipeline'sworkgroupsize, and retains the currentBufferRawinself.keepuntil the unretained command buffer retires.draw_indirect/draw_indexed_indirect) remain out of scope.Verification
cargo test -p rune-gpu --lib(60 passed, including 5 newindirect::testscoveringDispatchIndirectArgslayout, alignment,BufferUsages::INDIRECT, bounds, andu64overflow).CARGO_FEATURE_PURE=1 cargo check -p rune-gpu --target aarch64-apple-darwin --tests(0 warnings/errors).CARGO_FEATURE_PURE=1 cargo clippy -p rune-gpu --target aarch64-apple-darwin --tests --no-deps(0 new warnings).cargo check -p rune-gpu --no-default-features --target wasm32-unknown-unknown(clean).crates/rune-gpu/src/metal/compute_tests.rs(indirect_dispatch_matches_wgpus_bit_for_bit,indirect_dispatch_validation_captures_errors) compile-checked foraarch64-apple-darwinbut not executed on Apple Metal hardware locally.