xshader: the SMEM immediate is signed, with RX 6800 vectors #206
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!206
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/206/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?
@QuentinDanblon on GitHub · 2026-11-23 01:16 UTC · original
QuentinDanblon:pr/hw-smem→main· +24 −4 · 4 files · 1 commits · closed without mergingLibrary / area: tombox-xshader (SMEM decode,
s_buffer_load)Exports changed (exports.txt rows): none
Source of the behaviour: LLVM AMDGPU (
isInt<21>SMEM offset on GFX9+), and results an AMD Radeon RX 6800 (gfx1030) returned, published in the comments of the Leonida project's GPU test programs (GPL-3.0). Facts only, no code copied; encodings fromllvm-mc -mcpu=gfx1013. The first Leonida line ofTHIRD_PARTY/CREDITSis extended to these cases in this PR.Part of the split of #152: third group of translator fixes. Based on
2eda8b0, on top of your SMEM bounds work (smem_bounds.rs), 4 files, +24 / -4.The version in #152 also truncated soffset and the immediate to a multiple of 4. Main does that now, so this PR keeps only what is still missing: the 21-bit SMEM immediate is signed. It was decoded unsigned, so
s_buffer_loadwith a negative immediate and a SOFFSET register (soffset 0x10, imm -8) computed0x10 + 0x1ffff8, was out of bounds and returned 0. The RX 6800 reads byte 8.rdna2.rs: the immediate is sign extended.hlsl.rs, both dynamic paths (structured buffer and cbuffer): the truncated immediate is added to the truncated soffset as before. For a negative immediate the carry test is inverted, so a sum below the start of the buffer sets the samet..cflag as a sum past 4 GiB and takes your out-of-bounds path. Nothing else insmem_bounds.rschanges.Not measured, so said plainly: what the hardware returns when soffset plus a negative immediate lands below the start of the buffer. This PR returns 0 for every dword of such a load, like any other out-of-bounds dword. The Leonida vectors only cover sums that stay inside the buffer.
Tests: 7 cases added to
scalar_smem_loads(tests/exec.rs). On2eda8b0without the fix, the three cases with a negative immediate fail (soffset 8, imm -4;soffset 0xb, imm -1;soffset 0x10, imm -8with dwordx2); the four alignment cases already pass and are kept as regression vectors.Results
WARP,
--release, this branch on2eda8b0:cargo test -p tombox-xshader, all targets: 0 failed. exec 113 passed (2 ignored), lib 97 (your sixsmem_boundstests included), mesh 24, opcodes 24, synthetic 24, linkage 3, mixed_table 3, gcn_dims 3, isa_sweep 2.exec_mem::smem_nr::smem_bounds_emissionandsmem_bounds_follow_num_records_on_warppass unchanged.Hardware: not run, the GPU of my machine is busy for now. The #152 version of this change passed on an RTX 5090, but that was before
smem_bounds.rs, so it does not count for this code. I will post a hardware run of this branch when the card is free.No comment lines added (PR gate: 4 files checked, 0 problems). Not run against a title.
cargo test -p tombox-xshaderpasses on WARPmissingwith a note🤖 Generated with Claude Code
@omonkeyz on GitHub · 2026-11-23 01:57 UTC · original
Applied in
3f728a6(merged inad24144) with your authorship kept, thanks. The trailing comment on the OFFSET decode line was dropped inf9c3ec5(the project keeps code comment-free).Pull request closed