Shaders: truncate s_buffer_load offset terms independently #2436
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2438"
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?
Imported from Marvisak/VIctory. Originally posted by makmatvey on 2026-11-25T13:30:42Z.
What
s_buffer_load_dword*on RDNA adds the immediate offset andsoffsetafter clearing each term's two LSBs (RDNA ISA guide §8, Scalar Memory Operations). Onmainthe terms were summed first, sosoffset = 3withoffset:3loaded dword 1 ((3+3)>>2) instead of dword 0.Tracked as VIC-BT-025 in #1249. Related open head #1939 (
triage: needs work) — this is a focused slice with the citation and distinguishingsoffset=3, offset:3case from that triage.Change
In
crates/victory-shader/src/emit/lower.rs, mask only the instruction operands (imm & !3,soffset & !3) before adding. Descriptorbase/ dynamicextrastay unmasked.Tests
cargo test -p victory-shader --locked --lib s_buffer_load_with_unaligned_soffset_and_offset_lowers— pass (Linux)s_buffer_load_truncates_offset_terms_independently(Windows GPU / WARP):soffset=3,offset:3→ dword 0;soffset=7,offset:7→ dword 2cargo clippy -p victory-shader --locked -- -D warnings— cleanNo game data used.
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T14:01:10Z.
Review: APPROVED
Verified against
origin/main(940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:s_buffer_loadoffset terms independently (& !3per term before adding) matches hardware semantics and passes live GPU readback tests.cargo test -p victory-shader s_buffer_load: 2/2 passed on RTX 5090, 2/2 passed on WARP (s_buffer_load_with_unaligned_soffset_and_offset_lowersands_buffer_load_truncates_offset_terms_independently).cargo clippy -p victory-shader --all-targets -- -D warnings: 0 warnings.cargo xtask policy: 183 files ok.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-25T13:50:06Z.
Verification — head
938a3ccea710112a31be4ca05357d793076f4b55Environment: Windows 11 Pro 10.0.26200, rustc/cargo 1.98.1, DXC/dxil 1.8.2502.11 (Windows Kits 10.0.26100.0 x64).
origin/main=940d32f69b22265690a0b5a15d6ded572ba33baf; the PR is one commit set on top of it (merge-base = main), so the exact head was tested with no merge needed.cargo test -p victory-shader --lib: 249 passed, 0 failed, 3 ignored (ignored are pre-existing benchmarks/defect markers). New testsemit::lower::tests::s_buffer_load_with_unaligned_soffset_and_offset_lowersandemit::valu_tests::s_buffer_load_truncates_offset_terms_independentlyboth ran and passed (not skipped).cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: ok.emit::valu_testsetc.) iterate over a hardware adapter and WARP and ignoreVICTORY_D3D12_WARP, so this run was not WARP-only; they passed on both.Read the full diff first: no process, network or filesystem code beyond what the PR describes; no game data, dumps, shader names or retail hashes involved.
Verified by Claude Code (Claude Sonnet 5.5), an AI assistant; this is a test report, not a code review or approval.
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T13:55:29Z.
Duplicate check: #1939 (ashrafsdrop, opened 01:22Z, mergeable) makes the same change to
s_buffer_loadinemit/lower.rs.Both mask the immediate offset and
soffsetwith!3separately before summing, then add the descriptorbaseunmasked. The lowering lines are the same apart from variable names (imm/totalhere,imm_offset/total_offsetthere). Neither one masksbase. The two PRs differ only in their tests. Both add GPU tests invalu_tests.rs, and this one also adds a unit test inlower.rs(s_buffer_load_with_unaligned_soffset_and_offset_lowers). (Edited: I first wrote that the tests differ only invalu_tests.rs.)AI-assisted (Claude Code). Read from the two diffs against
main940d32f; nothing run.Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T14:11:03Z.
Review: APPROVED
Tested locally: merged into main
940d32f69b,cargo test -p victory-shader --lockedon macOS arm64 — 145 passed, 0 failed, 2 ignored (Windows-gated hardware execution tests not run here). Approving — s_buffer_load offset terms truncated independently.Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T14:26:49Z.
Verified the semantics against RDNA ISA §8: the two LSBs of
soffsetand of the immediate offset are ignored independently before summing —soffset=3, offset:3yields0, not(3+3)>>2 = 1. The old code folded the immediate intobaseunmasked and never maskedsoffsetat all.extrastaying unmasked is right — it is a dynamic component, not an instruction operand. The lower-test pins the lowering, thevalu_testscase verifies the actual dword read on hardware.Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:59:19Z.
Automated triage for the maintainers.
Proposed close: duplicate of #1939. The lowering change in
crates/victory-shader/src/emit/lower.rs(thes_buffer_load_dword*path: mask the immediate offset andsoffsetwith!3separately, leavebaseandextraunmasked, use the masked total on the constant path) matches #1939 line for line. #1939 was opened earlier and has since been updated (2d6095e) with the RDNA ISA citation and the distinguishingsoffset = 3, offset:3GPU test invalu_tests.rs, which is essentially the same test as the one here. The extra unit test inlower.rsonly checks that the shader lowers, not the address. CI (check) passes. If something here is missing from #1939, please suggest it there.This PR will be closed in 48 hours unless the author pushes a change or a maintainer removes the label.
Generated by Claude Code
Pull request closed