Recompiler: a static sampler whose S# word is written with s_brev_b32 falls back to sampler-heap entry 0 #2284
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#2284
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@Prime1997 on GitHub · 2026-11-25 12:24 UTC · original
What happens
The console compiler places a root signature's static samplers as S# words built from constants in the code, and
constant_samplers(crates/xcl/src/gpu/recomp/mod.rs) turns an S# whose four words were all set that way into a static sampler of the pipeline. It followss_mov_b32,s_movk_i32ands_mov_b64. A word with only high bits set is written bit-reversed instead, for examples_brev_b32is not followed, so this S# is not recognised and the image instruction is emitted with the fallback for an S# from memory:Word 3 of a constant S# is 0 here, so the instruction samples with sampler-heap entry 0, a sampler the title created for something else. Both translators are affected: the direct one calls the same function (
dxil/kernel.rs).How often
In a seeded sample of 1244 programs of a retail title (
xcl shaders … --direct --sample 1500 --seed 7 --dump, then counted withconstant_samplersover the decoded programs):s_brev_b32.The rest load their S# from memory (
s_load_dwordx4) or set it in an earlier block. The example above is the gather at guest 0x270 of a542b07e605c8fd7.Minimal program (fails on
main568e7db:static_samplersis empty and the HLSL containsSamplerDescriptorHeap)Fix (branch, PR to follow once its GPU test and the regression runs are done): one more arm in
constant_samplersthat takess_brev_b32of a constant as the constant it is.github.com/Prime1997/xcl-compat-fixes@253bc79d0bChecked for duplicates:
mainat1a0bbe3has noS_BREV_B32inconstant_samplers; no open PR or issue I could find covers it (the open PRs that mentions_brev, #620, #1597, #1672 and #2091, are about the instruction itself or about mask trees, going by their titles).Not tested: what the wrong sampler does to the picture in the title (which sampler sits in entry 0 depends on the run); the GPU test of the fix has not been run yet.
Setup:
main568e7db, RTX 3060 Ti 8 GB (driver 617.14), Windows 11 26200, DXC 1.9.2609.5.AI use: Claude Code (Claude Fable 5.2) found this, wrote the fix, the test and this report, and posted it at Prime's request; the runs were on Prime's machine.