Repository navigation
Conversation
Contributor
Author
|
The Android check failed before it checked out the code: Docker Hub refused to pull the |
`draw` passed `indexBufferOffset`, `baseVertex` and `baseInstance` as
untyped literals, so Rust sent them as 32-bit integers, where Metal
takes `NSUInteger` and `NSInteger`. On arm64 the last two go on the
stack, which Apple's ABI packs by each argument's own size, so Metal
read `baseVertex` from both and `baseInstance` from whatever came
next. With `MTL_DEBUG_LAYER=1`, a debug build of the `triangle`
example failed validation on its first draw:
instance_id type is not big enough to draw this many instances
(8657156772)
Verified on macOS with `MTL_DEBUG_LAYER=1`: the same build of the
example now draws without a validation error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
benface
force-pushed
the
metal-draw-argument-types
branch
from
October 18, 2026 17:49
2e02ac6 to
7e982d0
Compare
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.
Why
drawpassesindexBufferOffset,baseVertexandbaseInstancetodrawIndexedPrimitives:as untyped0literals, so Rust sends them as 32-bit integers. Metal takesNSUIntegerandNSInteger, which are 64-bit. On arm64 the last two go on the stack, which Apple's ABI packs by each argument's own size, so Metal readsbaseVertexfrom both of them andbaseInstancefrom whatever comes next.With Metal's validation layer on, a debug build of the
triangleexample fails on its first draw:A release build can pass, depending on what happens to be on the stack.
Change
The three literals are typed:
0u64,0i64and0u64.Verification
trianglenow draws with validation on and raises no error.cargo checkpasses foraarch64-apple-darwin,aarch64-apple-iosandaarch64-apple-tvos.🤖 Generated with Claude Code