tombox-xshader: typed buffer integer formats assumed float4 (TECHNICAL_DEBT) #105
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#105
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?
@Trwthh on GitHub · 2026-11-22 09:16 UTC · original
Component:
crates/tombox-xshader/src/hlsl.rsWhat happens: At line 4919-4920, typed buffer (TBUFFER/MUBUF) access assumes the view format is float4:
The translator infers some integer types via
tbuf_ty(line 318-319) for atomics, but loads from integer-format typed buffers may misinterpret data as float, and stores may write incorrect bit patterns when the actual view format is R32_UINT, R32G32_SINT, etc.Impact: Console games that read structured integer data through typed buffer views (common for index buffers, instance data, and compute dispatch arguments) may get garbled values. This affects both MUBUF typed loads and TBUFFER loads where the format specifies an integer type.
ISA reference: RDNA2 ISA manual, section 9.1 (Buffer Resources),
nfmtfield determines the data format interpretation.Suggested fix: The shader already tracks
tbuf_tyfor atomic inference. Extending this to propagate the inferred integer type to typed buffer load/store emissions (usingasuint()/asint()casts) would cover the common cases.@NemesisDawn on GitHub · 2026-11-23 03:10 UTC · original
I'm interested in helping address this with AI-assisted Rust development and independent RTX 5080 testing. Is this issue available to work on, and is the proposed integer-format handling still the preferred approach?
@omonkeyz on GitHub · 2026-11-23 03:22 UTC · original
Yes, it's still open and available. The gap is still there on current main: typed buffer loads and stores declare float4 unless the slot is used by an atomic (
tbuf_uint, hlsl.rs around the TECHNICAL_DEBT note near line 5613).What a PR needs to be accepted:
tests/exec_mem) for each integer nfmt you handle (UINT, SINT, USCALED or SSCALED if you cover them), checked bit-exact on WARP, plus a case showing the float path is unchanged. A hardware run on your RTX 5080 on top is welcome.cargo test -p tombox-xshaderpasses, and the PR names the ISA section it follows.It changes translator output, so it'll get a review from the graphics lead before merge.
@NemesisDawn on GitHub · 2026-11-23 03:59 UTC · original
I've traced the typed-buffer handling through
hlsl.rs,mtbuf.rs,shader_xlat.rs, and the D3D12 descriptor tracking code.The MTBUF path already decodes the numeric format from the instruction. However, for typed MUBUF loads/stores,
infer_tbuf_types()relies on register-use evidence and defaults tofloat4when the type is unknown.I also found that
bindtracerecords SRV/UAV descriptor information, but shader translation occurs separately during pipeline creation, so the actual bound view format isn't currently passed to the translator.Before implementing a fix, would you prefer a narrower change to the translator's type handling, or is the intended solution to specialize shader translation using the runtime view format?
I'd like to avoid introducing another heuristic or breaking existing floating-point buffers. I can add synthetic regression tests covering UINT, SINT, and FLOAT once the intended approach is clear.
@omonkeyz on GitHub · 2026-11-23 04:32 UTC · original
Thanks for tracing it. The graphics lead's answer is to specialize on the runtime view format, scoped tightly:
infer_tbuf_types()has no evidence for. Every other shader keeps a single variant.The PR then gets a graphics-lead review. Your plan to avoid a new heuristic and leave float buffers unchanged fits this.