Shaders: truncate s_buffer_load terms to dword alignment independently #1937
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1939"
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 ashrafsdrop on 2026-11-25T01:22:56Z.
Resolves VIC-BT-025 from #1249:
Summary
s_buffer_load_dword*address components are in bytes with their two LSBs ignored independently before summing ((soffset & !3) + (offset & !3)).crates/victory-shader/src/emit/lower.rs,imm_offsetandsoffsetwere added before dword truncation, causing a+4byte shift whenever low bits carried across bit 2 (e.g.soffset = 3andoffset: 3resolving to byte offset6 >> 2 = 1instead of0).imm_offset((*offset as u32) & !3) andsoffset(so & !3) independently, leaving descriptorbaseandextraunchanged.Tests
emit::valu_tests::s_buffer_load_truncates_terms_independently, executed on both hardware GPU and WARP (s_buffer_load_dwordwithsoffset = 3/7andoffset: 3/7, asserting(3 & !3) + (3 & !3) = 0reads dword0and(3 & !3) + (7 & !3) = 4reads dword1).Verification
cargo test -p victory-shader: 247 passed, 0 failed, 3 ignored.cargo clippy -p victory-shader --all-targets --all-features -- -D warnings: clean.cargo run -p xtask -- policy: 182 files ok.Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-25T01:44:47Z.
Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at
7644585.cargo test -p victory-shader --locked: 244 passed, 3 failed, 3 ignored. The 3 are #1744's NVIDIA failures onmain(the twostride_testsheap-buffer reads andgathers_at_a_level_match_the_hardware), so there is nothing new on this hardware. Not run: a title.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Headache3318 on 2026-11-25T01:49:01Z.
Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head
7644585applied cleanly onto currentmainccfb029.cargo test -p victory-shader --locked: 145 passed, 0 failed, 2 ignored. All tests pass, including the news_buffer_load_truncates_terms_independentlytest.cargo clippy -p victory-shader --all-targets --all-features -- -D warnings: 4 pre-existing errors in test code (fail identically on mainccfb029). The PR introduces no new clippy warnings.Not tested: Windows MSVC build, the title itself. AI-assisted.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T03:05:21Z.
Review: APPROVED
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main
940d32f69b,cargo test -p victory-shader --locked.145 passed / 0 failed / 2 ignored. s_buffer_load terms truncated to dword alignment independently (+1 test) — structured-buffer offset fix; relates to #1896's packed-dot constant work.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T08:16:48Z.
Automated triage for the maintainers.
Merge candidate. Rebased with the same change: in the
s_buffer_loadaddress path inemit/lower.rs, the immediateoffsetandsoffseteach have their two low bits cleared before they are added. The descriptor base andextraare left unmasked. The constant-offset fast path usestotal_offset. This follows the RDNA2 ISA guide's scalar memory addressing (each component's two LSBs are ignored).s_buffer_load_truncates_terms_independentlyreads back real buffer contents on hardware or WARP forsoffset3 and 7, a case where truncating the sum gives a different dword.CI: passing.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by ashrafsdrop on 2026-11-25T10:54:11Z.
Updated in head \
2c44f6e:Retain Descriptor Base/Extra Alignment:
*offset as u32) & !3\ and \so & !3.Hardware Citation & Rationale:
Deterministic Offset Assertion:
0, 0), and \offset: 7\ loads row 0, dword 1 (0, 1).Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T13:28:33Z.
The Windows check on
122f97bfails because the new readback test constructsPartsandHostShaderdirectly. Currentmainaddsview_marksto both.7fcd6fc builds your test through
emit(). I checked the resulting branch merged with940d32f. The same workspace Clippy command as CI passed, the asset policy passed, and all 29 VALU tests passed on Windows app-local WARP with DXIL validation. The fixture alone on940d32freads0x22222222forsoffset=3, offset=3. With your alignment change it reads the expected0x11111111and passes all four checks.This is one test-only commit on your exact head. If you take it, please preserve the Git author. Claim. AI-assisted with Codex. Synthetic shaders only.
Imported from Marvisak/VIctory. Originally posted by ashrafsdrop on 2026-11-25T15:21:06Z.
Rebased onto
origin/main(940d32f) and updated in head2d6095eto includeview_marksonPartsandHostShaderins_buffer_load_truncates_terms_independently.Verification on rebased head:
cargo test -p victory-shader --lib s_buffer_load_truncates_terms_independently: passed on hardware + WARP.cargo clippy -p victory-shader --all-targets --all-features -- -D warnings: clean.cargo run -p xtask -- policy: 182 files ok.Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T15:26:24Z.
Review: APPROVED
Truncating
imm_offsetandsoffsetindependently (emit/lower.rs:4148-4162) cleanly models the native RDNA2s_buffer_load_dword*alignment behavior while keepingSome(total_offset)clear and preserving descriptor base alignment as discussed above.Minor non-blocking notes:
lower.rs:4149-4150, clarifying that independent truncation comes from native RDNA2 hardware observation (since section 7.2.1's Reads using Buffer Constant pseudocode addsOFFSET + SOFFSETfirst) would remove doc ambiguity.cbufferLoadLegacy(root CBV) andNULLsoffsettest coverage alongside the raw table SRV test, and runrustfmtonvalu_tests.rs:2289.Local verification at
f7a44b76(and cleanly merged ontoorigin/mainat420f3392,emit/lower.rs = 520,860 B,3,428 Bunder cap):xtask policy(191 files ok),cargo clippy -p victory-shader --all-targets(defaultand--all-features, 0 warnings),resource_tracking(3/3), andemit::valu_testson both RTX 5090 and WARP (36/36, includings_buffer_load_truncates_terms_independently) all passed. Approving.Imported from Marvisak/VIctory. Originally posted by ashrafsdrop on 2026-11-26T15:37:28Z.
Thanks for the thorough verification and approval @fuzeofficlal!
Appreciate the pointer on Section 7.2.1 vs hardware divergence. We'll leave this branch locked for merge to preserve approvals, and I'll open a follow-up addressing the doc note alongside the
cbufferLoadLegacyand NULL soffset test coverage.Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T23:29:15Z.
Review: APPROVED
LGTM — verified on RTX 5090 and
VICTORY_WARP=1(Windows / D3D12) againstorigin/main(63bcca4).s_buffer_loadoffset terms independently to dword alignment matches RDNA2 hardware behavior cleanly on both RTX 5090 and WARP.cargo test -p victory-shader --lib emit::valu_tests::s_buffer_load -- --test-threads=1: passed on RTX 5090 andVICTORY_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).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.