shader: mesh programs read zero from SGPRs no hardware loads (#415) #420
No reviewers
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS!420
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-416"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@tiagonogueiraa-bit on GitHub · 2026-11-27 17:26 UTC · original
tiagonogueiraa-bit:shader-ngg-uninitialized-sgprs→main· +31 −0 · 3 files · 1 commits · closed without mergingRefs #419
Shape. 66 guessed mesh-style (NGG) vertex programs were refused as "a hardware SGPR input". Each reads an SGPR far above anything the hardware loads, before any write, on some path: s72, s77 or s79 in the ones I traced (a temporary instrument, not committed). Their layout ends at user data 15, the inferred heap. These are spill and temporary registers. For compute and pixel,
Io::initialized_sgprsalready makes such reads 0 ("a register holds what the last wave left"), but mesh programs had no count, so every such read was refused.Change.
Io::initialized_sgprsisSome(40)forStageIo::Ms. A mesh program has eight system SGPRs, then its user SGPRs from s8, and at most 32 of those: LLVM'sAMDGPU::getMaxNumUserSGPRsreturns 32 on GFX9 and later, andSPI_SHADER_PGM_RSRC2_GS's user SGPR count withUSER_SGPR_MSBholds no more. So nothing the hardware loads sits at s40 or above. Reads below s40 that no root parameter covers stay refused. The bound is a hardware limit, not a guess at this title's layout.By-output corpus sweep. 26,849 containers from my own runs (Series S, boot to the story load), native host options, main
b998bb6against this head:Conversion. All 66 gained translations convert with Apple's Metal Shader Converter 4.0 beta 3: 66 converted, 0 failed.
Test.
emit::graphics::tests::a_mesh_program_reads_zero_from_an_sgpr_no_hardware_loads. A mesh program moving s72 or s40 into its position translates. One moving s39 is still refused as "a hardware SGPR input". On main the s72 case is refused.Checks.
cargo test -p victory-shader -p victory-hle -p victory -p victory-gpu -p victory-metal -p xtask: 1054 passed, 0 failed, 11 ignored.-D warnings: clean.cargo xtask policy: ok.docs/native-host.mdhas a bullet next to the other mesh-program notes. @Olima34, for the board.@LakshanSivakumar on GitHub · 2026-11-28 00:37 UTC · original
Thanks for this. Main already has the same change:
00c44adcmakes mesh programs read s40 and up as zero, and it gains the same 66 programs. Merging this as well would add a second match arm for mesh programs that can never be reached, so I'm closing it as done. Thanks for the clear write-up and the test.@Olima34 on GitHub · 2026-11-28 00:44 UTC · original · requested changes
Thanks @tiagonogueiraa-bit, the rule is right, and the maintainer reached the same conclusion: main already has it. His
00c44adc("shader: a mesh program reads SGPRs past its user data as zero", now on main through the preview merge) addsStageIo::Ms(_) => Some(40)toraise_graphicsincrates/victory-shader/src/io.rs, with a docs note and a test inmask_tests.rs. GitHub still shows this PR as mergeable, but the merged code would have two identicalStageIo::Ms(_)arms. That's an unreachable pattern, so Windows clippy (-D warnings) would fail, and the docs would describe the rule twice.What's left that main doesn't have is your test's negative case: a read of s39 is still refused as "a hardware SGPR input". If you'd like to keep that, please merge current
maininto the branch, drop theio.rsarm and the docs bullet, and keepa_mesh_program_reads_zero_from_an_sgpr_no_hardware_loads(or fold its s39 assert into main's test). Otherwise the PR can be closed as already landed; that's the maintainer's call.Pull request closed