Shaders: truncate s_buffer_load offset terms independently #2438
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2438
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2438/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?
@makmatvey on GitHub · 2026-11-25 13:30 UTC · original
makmatvey:cursor/shaders-s-buffer-load-align-2ac3→main· +224 −4 · 2 files · 2 commits · closed without mergingWhat
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.
@oni-swr on GitHub · 2026-11-25 13:50 UTC · original
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.
@upipibi on GitHub · 2026-11-25 13:55 UTC · original · edited 2026-11-25 14:22 UTC
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.@kotekompotek on GitHub · 2026-11-25 14:26 UTC · original
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.@Marvisak on GitHub · 2026-11-25 15:59 UTC · original
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