metal: use 256-byte uniform alignment on iOS simulator#636
Open
benface wants to merge 1 commit into
Open
Conversation
The simulator on Apple Silicon Macs (`aarch64-apple-ios-sim`,
`target_abi = "sim"`) runs the iOS arm64 binary but issues Metal
commands against the host Mac's GPU subsystem. That subsystem
validates with the 256-byte rule — not the 16-byte rule for Apple
GPUs on real iOS devices. The existing cfg matched the simulator
into the `target_arch = "aarch64"` branch with the iOS device
constant, and the first draw asserted:
-[MTLDebugRenderCommandEncoder validateCommonDrawErrors:]:6032:
failed assertion `Draw Errors Validation
Vertex Function(vertexShader): the offset into the buffer
uniforms that is bound at Buffer index 0 must be a multiple
of 256 but was set to 144.`
Add `target_abi = "sim"` to the cfg group that selects the 256-byte
constant so both the legacy x86_64 simulator and the modern arm64
simulator pick the same alignment as macOS. Real arm64 iOS devices
keep the 16-byte alignment they correctly used before.
45d4051 to
9114737
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.
Problem
The iOS simulator on Apple Silicon Macs (
aarch64-apple-ios-sim,target_abi = "sim") runs the iOS arm64 binary but issues Metal commands against the host Mac's GPU subsystem. That subsystem validates with the 256-byte uniform buffer offset rule — not the 16-byte rule for Apple GPUs on real iOS devices.The existing cfg matched the simulator into the
target_arch = "aarch64"branch with the iOS device's 16-byte constant. The first draw asserts:Fix
Add
target_abi = "sim"to the cfg group that selects the 256-byte constant. Both the legacy x86_64 simulator and the modern arm64 simulator now pick the same alignment as macOS. Real arm64 iOS devices keep the 16-byte alignment they correctly used before.Tested on
iPhone 17 simulator on iOS 27 beta (Apple Silicon Mac host) — uniform-alignment assert gone, draws complete.