Repository navigation
Conversation
Dukestar69
left a comment
There was a problem hiding this comment.
LGTM — verified on RTX 5090 and VICTORY_WARP=1 (Windows / D3D12) against origin/main (63bcca4).
- Truncating base (
lo), immediateoffset, andsoffsetindependently with& !3before summing accurately matches RDNA2 SMEM dword-aligned address formation. cargo test -p victory-shader --lib emit::memory_tests:: -- --skip heap_direct_texture_reads_mark_their_heap_index --test-threads=1: 5 passed, 0 failed on RTX 5090 and 5 passed, 0 failed onVICTORY_WARP=1.cargo clippy -p victory-shader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal
left a comment
There was a problem hiding this comment.
Looks good to me — masking lo, the sign-extended 21-bit offset, and soffset independently with !3 before add64 matches RDNA2 SMEM effective-address calculation ((SBASE & ~3) + (sext(OFFSET) & ~3) + (zext(SOFFSET) & ~3)), including negative immediates and 32-bit carry propagation.
Verified locally on Windows 11 with head 0f68e4d6 cleanly merged onto main (63bcca43):
crates/victory-shader/src/emit/lower.rsis520,892bytes (3,396bytes below the524,288limit), and the newly added lines inlower.rs:4495-4501matchrustfmt --edition 2024.cargo run -p xtask -- policy(191 files ok) andcargo clippy --locked -p victory-shader --all-targets -- -D warnings(both default and--all-features) pass.cargo test --locked -p victory-shader --lib emit::memory_tests(withWindows Kits\10\bin\10.0.26100.0\x64\dxil.dllpresent):VICTORY_WARP=0(--skip heap_direct_texture_reads_mark_their_heap_index):5 passed; 0 failed(1.56s, includingscalar_loads_truncate_address_terms_to_dwords_independently).VICTORY_WARP=1(fullemit::memory_tests):6 passed; 0 failed(0.30s).
Minor non-blocking formatting nit: rustfmt --edition 2024 --check reports two line-wrap diffs on added lines at crates/victory-shader/src/emit/memory_tests.rs:1020 and 1061. (Also note the sibling PC-relative CODE path in Lower::smem still combines unmasked imm + soffset separately.)
|
WARP verification of head New test present at head (in
So the test catches a real bug on main and is fixed by the PR. victory-shader lib: head 299 passed / 4 failed (the unrelated four below); control 299 passed / 7 failed (the same four plus this PR's test and #3351's two, which I carried in the same control checkout). Note the PR does not cover negative immediates or wide loads (it says so itself); I did not extend it. Setup (Windows 11, no physical GPU): Suites ( Synthetic tests only; no game files, dumps, shader names or hashes. Test report only, no code changes. Claimed on #1633. AI use: Claude Code (Claude Sonnet 5.5). |
What
s_load_dword*from title memory (Lower::memory_smem) added the 64-bit base address, the signed 21-bit immediate offset, and the unsigned SGPRsoffsetbefore passing the byte address toself.memory. On RDNA2 hardware, scalar memory loads truncate each address component to a dword boundary independently before adding them:(base & ~3) + (soffset & ~3) + (imm & ~3) + 4*i.Because the unaligned low bits of each term were added together instead of dropped first, combinations such as
base = TITLE + 1withimm = 3orsoffset = 2withimm = 6read the next dword (+4/+8) instead of+0/+4. Each term (lo,offset, andsoffsetwhen present) is now masked with!3beforeadd64.For dword-aligned inputs the result is unchanged.
How
In
crates/victory-shader/src/emit/lower.rs(Lower::memory_smem), masklo,offset, andsoffset(when notNULL) with!3before summing them inadd64. For negative 21-bit immediates,(offset as u32) & !3preserves the sign-extended rounding down to a multiple of 4 (e.g.-1 & !3 = -4), keepingoffset < 0foradd64.lower.rsgrows by 329 bytes (520,563 to 520,892).Evidence
87d7bf7c43reports raw compute kernel measurements on AMD Radeon RX 6800 (gfx1030, driver 32.0.21045.29003, wave32 = wave64, 155 runs): each ofbase,soffset, andimmis truncated to a multiple of 4 before addition (base & 3 = 1withimm = 3 -> data@0;soffset = 8withimm = -4 -> @4;soffset = 0xbwithimm = -1 -> @4; same rule fors_load*withpointer & 3 = 1or3). Only the stated rule and measured cases are used; no code is taken.devin/ci-smem-load-align-negative): run 45883071279 — 302 passed, 1 failed (scalar_loads_truncate_address_terms_to_dwords_independently: returned[0xA110_0001, 0xA110_0002]instead of[0xA110_0000, 0xA110_0001]).devin/ci-smem-load-align): run 45883064141 — 303 passed, 0 failed; both Clippy runs clean;policy::tests::repository_passes_policy ... ok.96d6ddb(control) and0f68e4d(fix) on AMD Radeon(TM) Graphics, NVIDIA GeForce RTX 2060 Max-Q, and WARP: fails with[0xA110_0001, 0xA110_0002]without the fix and passes on all three with the fix.Other pull requests
triage: merge candidate) and Shaders: fix RPO resource tracking, SMEM alignment, raw VCC branch, and readlane/writelane semantics (#1249) #1336 cover independent dword truncation fors_buffer_load*(Lower::smem) and do not touchLower::memory_smem.memory_smem.memory_tests.rs.Not checked
s_load_dwordx2/x4/...loads, ands_store*are not covered by the new test.s_load_dword*terms (no game corpus).Synthetic tests only; no game files.
— Devin & Neon