Repository navigation
Avoid Metal snorm16 vertex-fetch register spills - #4
Draft
matthargett wants to merge 2 commits into
Draft
matthargett wants to merge 2 commits into
matthargett wants to merge 2 commits into
Conversation
Extracted from the maintained mobile-rendering patch stack with focused regression coverage.
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.
Description
Replace Metal's
unpack_snorm2x16_to_floatintrinsic in Naga's Snorm16, Snorm16x2 and Snorm16x4 vertex-fetch helpers with explicit signed-short conversion, division by 32767, and clamping at -1.While profiling a moving-camera glTF scene on iPhone XS/A12, pipelines using packed snorm16 vertex attributes reported 16 bytes of compiler spilling per input, or 32 bytes with two inputs. Minimal controls with float32, snorm8, storage-buffer fetch, different MRT layouts and f16 arithmetic did not reproduce it. A device-reference-versus-struct-copy experiment also did not remove the reports. Replacing this particular unpack helper did.
Packed assets, attribute formats, strides, offsets, bounds checks and vertex/instance stepping remain unchanged. The general WGSL
unpack2x16snormbuiltin is intentionally untouched. This is a Metal code-generation correction, not a WebGPU semantic relaxation, runtime synchronization change, or memoryless-attachment change.Naga is part of the wgpu monorepo, so this one draft covers the wgpu/Naga contribution; there is no duplicate PR against the archived standalone Naga repository.
Validation
NAGA_SNAPSHOT=msl-vpt, covering the existing vertex-pulling/format fixtures. Four generated MSL snapshots change only their helper bodies.The iPhone 12 sustained run used 25% app-set brightness, USB power and a 180-second nominal-thermal start gate. It reached serious reported thermal state, so the result is not evidence of lower power, cool operation or indefinite 60 FPS. An earlier run stopped producing frames and has no completed benchmark receipt; it is excluded. Profiling-only keep-awake was added for the completed repeat, without changing rendering. The cause of that earlier interruption remains unproven.
Physical-device evidence uses the maintained backport on wgpu 30.0.1 (
40f4a34ebaf56f9a046231f54125ad046239d3f3); the draft is rebased onto current upstream trunka1d029a731855a6c8d49b717b0601ff3e2f05817. No patch-only sustained FPS or power benefit is claimed. The full rendering stack still falls below sustained 50 FPS on XS in the final two minutes of its five-minute test.The broader local
cargo xtask test --test-threads 4run is not green: 1,216 passed, five failed, six skipped. Three passthrough cases require unavailable DXC/Metal compiler tools. The other failures aresubgroup_operations(an expected-failure case unexpectedly succeeds) andwritten_timestamp_resolves_to_nonzero(zeros returned); both reproduce on verified unchanged upstream trunk. The targeted baseline selection also reports three related passes: one executed subgroup case and two unsupported-feature timestamp cases. No test expectations were weakened and no unrelated fixes are included.NAGA_SNAPSHOT=msl-vpt cargo test -p naga --test naga --features wgsl-in,msl-out snapshots::convert_snapshots_wgsl -- --nocaptureDraft for fork review before any upstream submission. Build-only Cargo workspace pinning and BabylonNative's scheduling/presentation experiments are intentionally excluded.
Implementation and device TODOs
AGENTS.md · Qualification and PR index. Fork branch instructions.