tombox-xshader: bind literal static samplers through the FSSM table #329
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!329
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/329/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?
@GDAgent on GitHub · 2026-11-23 20:16 UTC · original
GDAgent:feat/xshader-fssm-static-samplers→main· +1426 −10 · 11 files · 4 commits · closed without mergingStacked on #289 (head
714efcc); only943e546andb02b817belong to this PR. Please reviewgit diff 714efcc..until #289 lands; I will rebase ontomainthen.Library / area:
tombox-xshader(newhlsl/static_sampler.rs, a strict literal check next to the S# decoder inhlsl/durango.rs, one call site inhlsl.rs).Exports changed: None.
Builds on #289 (FSSM root-binding table reader). Complements #183; see "Relation to #183".
Problem
Console shaders that use a static sampler do not load a sampler descriptor. The compiler builds the four S# words in SGPRs from literals (
s_movk_i32/s_mov_b32) right beforeimage_sample. Without a root signature carrying the sampler state, the translator refuses these withmimg ...: sN not a sampler descriptor (None). With #289's table fallback this is the largest first refusal on a very popular AAA title that ships without RTS0 (7,582 of 25,889 unique shaders). 7,551 of those use static samplers listed in their FSSM table.What the table says
The table's parameter list has one kind-4 entry per static sampler in the root signature (
index, shader register). The resource list names the static samplers the shader actually uses (source 4, class sampler,index, register). It carries no sampler state: no filter, address mode or border colour. The state exists only in the literal words in the ISA. The register space is not in the table either, but the shader's PSV0 sampler bindings give it (the AAA title's static samplers are in space 1).Change
s_mov_b32/s_movk_i32/s_brev_b32/s_not_b32literals and SGPR copies (s_mov_b32,s_mov_b64). Paths must agree at joins, and loops iterate to a fixpoint.*_co_*,v_div_scale,v_mad_u64_u32),v_readlane_b32/v_readfirstlane_b32, VOPC/VOP3 compare sdst, and the sdst pair of any SOP1/SOP2/SOPK op the decoder does not name.s_setpc,s_swappc,s_rfe,s_movrels(d),s_cbranch_joinands_callforget everything.register(sN, spaceK), space from PSV0). If it lists several, translation is refused with the four words and the candidate registers named, because the table cannot tell them apart.w3 >> 30) when border addressing is used. Any known field that differs refuses. Two remaining candidates with different state refuse as well.Relation to #183
#183 resolves literal samplers against the root signature's static samplers by decoded state, for straight-line RDNA2 shaders, using a backward scan (
sgpr_const_in). This PR differs in three ways:Both can land. Order at the call site: Durango path, then #183's RDNA2 straight-line resolver (if merged), then this table-based resolver. If #183 lands first, its strict check and this
literal_mismatchshould become one function; I'm happy to rebase onto it.Evidence
The Matrix Awakens (RTS0 + table, no static samplers in any table): must be byte-identical. Translate-only comparison of the HLSL hash of every unique shader against the base
714efcc: 35,442 shaders compared, 35,382 identical HLSL, 60 failing in both with the same message, 0 differences.A very popular AAA title (no RTS0), translate-only,
--fssm-root 1, 25,889 unique shaders, base714efccagainst this branch:sN not a sampler descriptor, 849 now translate (exactly one used static sampler) and 5,066 are refused with the new explicit message, because their table lists 2-12 (up to 14) used static samplers and no root signature exists offline to say which one a literal selects (4 is the most common). 628 keep the old message (no static sampler in their table).Tests
hlsl/static_sampler.rs(7 unit tests): literals through a straight line,s_movk+ copies, a branch where both paths agree, a word set on one path only, clobbers (VOP3B carry-out into a sampler word,v_readlane,s_buffer_load_dwordx4,s_swappc,s_movreld, an unnamed SOP1 into the words) vs non-clobbers (carry-out and unnamed SOP1 into other SGPRs,s_cmpk), and loop back edges.tests/fssm_bind.rs(+6):register(s5, space1)without a root signature (DXC compiles), also with the literal set before a branch;cargo test --locked -p tombox-xshader --no-fail-fast(debug, native Windows 11): 370 passed, 0 failed, 18 ignored. That includes lib 128/0/3,fssm_bind11/11 andtests/exec.rs128/0/2.714efcc): 0 problems.Not verified in a title
No title was run. The no-root-signature case is checked offline (translation + DXC) only. The root-signature case is checked only with synthetic root signatures: the AAA title's root signatures and their static-sampler states have not been seen, so the claim that the table's static-sampler registers match the title's PSO root signature is untested. Static sampler register spaces come from PSV0. The table itself has none. Native Windows 11; not run under Proton.
Merge notes
This branch and #183 both edit the sampler call site in
hlsl.rsand add tests totests/synthetic.rs, so whichever lands second needs a small rebase. No conflict with #278 or #302.@omonkeyz on GitHub · 2026-11-25 13:49 UTC · original
Applied on main in
2b3a132(cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.Pull request closed