Shaders: vectorize wide s_buffer_load and global_load rawBufferLoad calls #1393
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!1393
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1393"
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?
@wbkepler on GitHub · 2026-11-24 17:41 UTC · original
wbkepler:shader/dxil-vector-raw-buffer-loads→main· +584 −50 · 3 files · 1 commits · openSummary
Rebased cleanly onto
upstream/main(ffe310e):Adds
Lower::raw_buffer_loadincrates/victory-shader/src/emit/lower.rsto coalesce contiguous dword raw-buffer loads into vectorizeddx.op.rawBufferLoad.f32calls of up to 4 dwords (mask0x1/0x3/0x7/0xF,align4) withextractvaluechannel extraction:s_buffer_load_dwordx2/4/8/16->1/1/2/4loads).global_load_dwordx2/3/4->1load, preserving sub-dword andCODEpaths) andformat_load.Verification
cargo clippy -p victory-shader --all-targets— passedcargo test -p victory-shader— passed (including 3 new tests withdxil.dllvalidation and live hardware GPU + WARP execution covering partial-OOB zero semantics)cargo xtask policy— passed@marquezinii on GitHub · 2026-11-24 18:33 UTC · original
Ran on an RTX 5070 (desktop, driver 621.40, the only adapter), Windows 11 26300, Rust 1.98.1 at
7a780a0.cargo test -p victory-shader --lib -- --test-threads=1 --nocapturegives 123 passed, 0 failed, 1 ignored.vectorizes_wide_raw_buffer_loads,s_buffer_load_wide_srv_reads_exact_dwords_and_oob_zerosandglobal_load_wide_srv_reads_exact_dwordsall pass on the hardware adapter and WARP.The case I'd watch most in this change is the one the second test covers: a vector
rawBufferLoadthat straddles the end of the view. The console checks bounds per dword, so the in-range dwords must keep their values and only the ones past the end read 0. With one load per dword that is automatic; withmask0x3/0x7/0xF it relies on how the host driver bounds a multi-component raw load. On this NVIDIA driver and on WARP the result is per dword, as the test expects. A run on AMD hardware would cover the other vendor.@sinan-cmyk on GitHub · 2026-11-24 19:50 UTC · original
Offline measurement on a retail dump, and the shader tests on Ada
Result: no count change against
main.Offline. I merged head
7a780a0ontomainffe310e(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 21,724 onmain, 21,724 with this PR.No program changes its failure reason either. That is the expected result for a fix whose instructions sit behind the earlier failures on
main. The count shows that the change rejects nothing. It does not show whether the output is right.Tests: with the same merge,
cargo test --locked -p victory-shader --libpassed 123, failed 0. The bitcode benchmark is ignored, as onmain, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, withVICTORY_WARPunset.No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
@aycow on GitHub · 2026-11-24 22:17 UTC · original
I tested the analogous per-lane raw table-constant path introduced in
683ad7aon exact main70564ae. The local experiment combines only aligned same-row dwordx2/x3/x4 reads, emitting one raw load with masks 3, 7 or 15. Dynamic and crossing cases retain scalar lowering. Baseline and candidate each passed 240 synthetic dispatches per adapter on AMD and WARP with full validation, including partial bounds, nonzero FirstElement and raw bit patterns. A 2 MiB synthetic read had medians of 52.58 → 50.68 µs on AMD and 397.70 → 261.35 µs on WARP. The AMD maximum rose slightly, so the AMD performance evidence is limited.Is the table-constant branch already in your current-main plan? I can share the exact fixture and hunk to avoid parallel implementations.
AI-assisted using Codex.
@Marvisak on GitHub · 2026-11-25 01:25 UTC · original
Automated triage for the maintainers.
Needs rebase. This pull request conflicts with
main(conflicting:crates/victory-shader/src/emit/lower.rs,crates/victory-shader/src/emit/valu_tests.rs). It will be reviewed once it is rebased onto the currentmain.Generated by Claude Code
@ryotdev on GitHub · 2026-11-25 02:33 UTC · original
I found a 32-bit byte-offset wrap case in the table SRV path. On Windows WARP, the same hand-written
s_buffer_load_dwordx2fixture passed on the scalar parentffe310eand failed on7a780a0. The difference also survives DXIL validation and pipeline creation.To reproduce, extend
s_buffer_load_wide_srv_reads_exact_dwords_and_oob_zeroswith a 24-dword SRV, a nonzero first dword,dyn_off = 0xfffffff8u32, and the existing immediate offset of 4. The first address is0xfffffffc. The scalar parent explicitly adds four again in i32 for the second word and reads byte zero. The vector load returned zero for both words on WARP. With my synthetic buffer the readbacks were[0, 0x7fa12345]on the parent and[0, 0]on this head.The fixture's current expectation uses a host
usize. To check parity with the scalar parent at this boundary, compute each expected byte address asdyn_off.wrapping_add(4).wrapping_add(4 * k as u32)before dividing by four. An ordinary read crossing the end of a small view exercises a different case.I also checked a conservative version that groups only known, dword-aligned offsets with a proven non-wrapping last dword and keeps scalar reads for dynamic offsets. The fixed, dynamic, partial-view and wrapping cases passed on WARP for widths 2/4/8/16. This establishes the difference from the previous translator. A console result at this boundary would settle which behavior the emulation should implement. AI-assisted.
@Moon0755 on GitHub · 2026-11-26 20:52 UTC · original
On the hardware question above: RDNA2 (
gfx1036, measured natively in wave32 and wave64 inzDiazG/Leonida,docs/design.md@68e8b30ab) does not wrapsOFF + IMMin 32 bits fors_buffer_load*— e.g.sOFF = 0xfffffffc, IMM = 8andsOFF = 0xfffffff0, IMM = 0x20both return0pastNUM_RECORDS = 0x100.So
[0, 0]is the hardware-matching result here, andmain's scalari32wrap ([0, 0x7fa12345]) was the bug. We opened #3373 to fix the scalar path inLower::smemso both paths agree on returning0on 32-bit overflow.— Neon
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.