tombox-xshader: opt-in user-data CBV fallback for shaders without RTS0 #158
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!158
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/158/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?
@AntonioEspana on GitHub · 2026-11-22 16:46 UTC · original
AntonioEspana:user-data-cbv→main· +255 −6 · 8 files · 1 commits · closed without mergingFirst step of the fallback discussed in the issue: user SGPRs only, fed from a bind-time CBV. No runtime descriptor resolution yet.
What it does
hlsl::translate_user_data(ex)andhlsl::translate_linked_user_data(ex, feeds_ps).translate/translate_linkedare unchanged and produce byte-identical HLSL.ex.root_sig.is_none()) and is not a Durango layout. With a root signature, the opt-in call returns exactly the static path (asserted in the test).src/user_data_abi.rs): one CBV per stage atb0, space4000005(TB_USER_DATA_REGISTER/TB_USER_DATA_SPACE), 32 dwords (256 bytes). Dword N is the initial value of sN, for s0..s31.src/hlsl/user_data.rs): when the fallback is active, the shader declarescbuffer TbUserData { uint4 tb_ud[8]; }. Every declared sN with N < 32 is initialised fromtb_udright after the register declarations, before the stage's system-value assignments. System SGPRs (CS group id, MSs3, ASs2..s4, GSs3) therefore still win. This covers VS/PS/GS, CS, MS and AS.Translated::user_data_base: Option<usize>:Some(base)when the shader needs the CBV, where base is the stage's first root-parameter SGPR (the sameuser_base()the static path uses).Noneotherwise.user_data_abi::pack(root_sig, base, args): for d3d12_xs at draw time. It lays out root arguments with the static path's mapping (table = 1 dword, root descriptor = 2, constants = num32, consecutive frombase). It refuses on a count or kind mismatch and on anything past s31, instead of truncating.Not in this PR
Module name
You suggested
hlsl/rootmem.rs, but that file already exists (the root-memory CS path). So the new code is inhlsl/user_data.rs. The ABI constants are inuser_data_abi.rs, next tocentroid_abi.rs/gds_abi.rs.global.rsandglobal_abi.rsare untouched.Observation (not changed here)
On the static Scarlett path (non-Durango, non-root-memory), user SGPRs mapped to a root
Constantsparameter are declared but never initialised. A PS with RTS0[Constants num32=4]that reads s8 getsuint s8 = 0u;. That is why the WARP test compares against the static layout (packwith the static mapping) rather than the static path's output. Is that expected on Scarlett, or a gap worth an issue?Tests
src/user_data_abi.rsunit tests: packing order, refusals, byte layout.tests/exec_mem/user_data.rs(WARP):user_data_sgprs_read_the_bound_buffer: a PS without RTS0 reads s0, s8, s17, s31. The test binds a root CBV atb0, space4000005and checks the render target.user_data_follows_the_static_root_layout:TbUserData.[Table, Constants×3]root layout at the reported base (8) and checks that s8..s11 receive the table pointer and the three constants on WARP.Ran locally on Windows (WARP):
cargo test -p tombox-xshader: all passed, 0 failed (5 new: 3 unit, 2 WARP). The ignored tests are the fixture/hardware ones.I don't have a console or dumps. All checks are synthetic.
@omonkeyz on GitHub · 2026-11-22 17:10 UTC · original
Applied in
e4505ea(merged in43d17b0) with your authorship kept, thanks. I left out the runs/ output file, since generated run logs don't go in the repo. Your report that root-constant user SGPRs are left uninitialised on the static Scarlett path is now recorded in docs/BLOCKERS.md with your repro.Pull request closed