Shaders: truncate s_buffer_load terms to dword alignment independently #1939
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!1939
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@ashrafsdrop on GitHub · 2026-11-25 01:22 UTC · original
ashrafsdrop:shader/s-buffer-load-alignment-025→main· +172 −4 · 2 files · 1 commits · openResolves 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.2d6095ec48tof7a44b768b@upipibi on GitHub · 2026-11-25 01:44 UTC · original
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).
@Headache3318 on GitHub · 2026-11-25 01:49 UTC · original
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.
@Marvisak on GitHub · 2026-11-25 08:16 UTC · original · edited 2026-11-26 07:20 UTC
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
@ashrafsdrop on GitHub · 2026-11-25 10:54 UTC · original
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).@andrewpozdnakov7-jpg on GitHub · 2026-11-25 13:28 UTC · original
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.
@ashrafsdrop on GitHub · 2026-11-25 15:21 UTC · original
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.@catminou4 on GitHub · 2026-11-25 03:05 UTC · original · approved these changes
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.
@fuzeofficlal on GitHub · 2026-11-26 15:26 UTC · original · approved these changes
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.@ashrafsdrop on GitHub · 2026-11-26 15:37 UTC · original
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.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.