tombox-xshader: map root Constants parameter values onto user SGPRs on Scarlett static path #170
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!170
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/170/head"
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?
@adriaespii on GitHub · 2026-11-22 17:37 UTC · original
adriaespii:contrib/scarlett-root-constant-sgpr→main· +282 −8 · 5 files · 1 commits · closed without mergingSummary
Fixes the blocker entry recorded in
docs/BLOCKERS.md: "RTS0 root-constant user SGPRs on the static Scarlett path (tombox-xshader, all titles)" (repro reported in #158).What
!self.dg().is_some() && !self.rootmem()), shaders reading user SGPRs corresponding to rootConstantsparameters were previously translated with zero-initialized SGPR declarations (uint s8 = 0u;), never loading the bound 32-bit root constant values.hlsl.rs, addedstatic_sgpr_init(&mut self) -> Stringto iterate root parameters starting fromself.user_base()(4 for CS, 16 for MS, 22 for GS, 8 for PS/VS). ForRootParamKind::Constants { num32, .. }, each live user SGPRs{at + i}is initialized fromtb_rc{p}_{i}, registeringpinself.rm_usedand the SGPR inself.regs.static_initinto the entry prologues of compute, graphics (VS, PS, GS), mesh (finish_mesh), and amplification (finish_amp) stages.root_constant_user_sgprs_read_bound_valuesintests/exec_mem/user_data.rsexecuting on WARP: readss8..s11with RTS0 having[Constants num32=4], binds root 32-bit constants, and verifies that pixel outputs receive the bound constants instead of zeros.docs/BLOCKERS.mdto mark this entry fixed.Verification
.github/scripts/pr_gate.py --base upstream/main --head HEAD(5 files checked, 0 problems).cargo test -p tombox-xshader --test exec(98 passed, 0 failed, 2 ignored).@omonkeyz on GitHub · 2026-11-22 17:48 UTC · original
Thanks for picking this up so quickly. The approach is right, and the Durango early return keeps Xbox One titles byte-identical. Two things are needed before it can land:
static_sgpr_initcomputes each parameter's first SGPR with its own loop (a table counts 1, a descriptor 2, constantsnum32). The rest of the translator usesroot_param_at()/user_base(). Please derive the offsets from those so the two can't drift apart. If that isn't practical, add a unit test that builds mixed root signatures and asserts your offsets equalroot_param_at()for every parameter. Cover table + root CBV + Constants num32=3 + root SRV + Constants num32=5, plus a case where Constants come first.No conflict with the opt-in user-data path from #158: that path only runs for shaders without a root signature, and yours only runs with one. Once it's updated I'll apply it with your authorship kept.
@adriaespii on GitHub · 2026-11-22 18:04 UTC · original
@omonkeyz Thanks for the clear feedback and guidance!
I've updated the implementation and tests to address both points:
Shared layout code & offset derivation:
oot_param_at\ without duplicating any offset counting logic.
Multi-parameter execution test:
egister=1\ and
egister=2).
Ready for re-review whenever you have a chance!
@omonkeyz on GitHub · 2026-11-22 18:26 UTC · original
Applied in
23505f0(merged inf0213ec) with your authorship kept, thanks. The offsets now come fromroot_param_at(), and the mixed-layout and multi-parameter WARP tests cover what the BLOCKERS entry says. It conflicted with #172 infinish_mesh, which #172 split into one-pass and two-pass branches. I resolved it by adding yourstatic_initafterud_init()in both branches.Pull request closed