Shaders: skip dead channel loads/conversions in format_load and vectorize memory_smem, table-CBV, and view_addresses loads #2207
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2209"
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 RVZO6 on 2026-11-25T07:59:28Z.
In
crates/victory-shader/src/emit/lower.rs:format_loadcurrently loads all dwords of a buffer format and converts every channel even when the instruction requests fewer channels (e.g.,tbuffer_load_format_x/_xy), discarding the unused results afterward.format_load,memory_smem, and the table-CBV path ofbuffer()emit one 1-dwordrawBufferLoad.f32per dword instead of vectorizing contiguous reads up to 4 dwords.view_addressesloads each descriptor's 64-bit address as two separate 4-byterawBufferLoad.f32calls instead of one 8-byte-aligned 2-dword load.Claimed on #1633 (
https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7155420630).The change
crates/victory-shader/src/emit/lower.rs:Lower::raw_dwords(h, off, count)emitting vectorizeddx.op.rawBufferLoad.f32calls in chunks of up to 4 dwords (align = 4).format_load: slice format bit widths to the requested channel count, load onlyneed_bits.div_ceil(32)dwords (returning early whenneed_bits == 0) viaraw_dwords, and convert only the requested channels while preserving missing-channel(0, 0, 0, 1)fill andd16packing.raw_dwordsinmemory_smem(which already performs a singlememory()lookup for the whole access) and in the table-CBV path ofbuffer().(word 0, word 1)descriptor address pairs inview_addressesinto a single 8-byte-aligned 2-dwordrawBufferLoad.f32(mask = 3, align = 8).dxil.dllvalidation tests (format_load_skips_dead_channels_and_loads,table_cbv_buffer_load_vectorizes_to_single_raw_load,memory_smem_vectorizes_loads_into_four_dword_chunks,view_addresses_coalesces_consecutive_address_pairs) plus GPU/WARP execution testformat_load_xy_and_table_cbv_x4_execute_on_gpu.Not a duplicate of
No open PR or
CLAIMS.mdentry skips dead channels informat_load, vectorizesmemory_smem/ table-CBVrawBufferLoads, or coalescesview_addressespairs.Tested
windows-latestMSVC + Windows WARP SM 6.6 CI run45570823602(Clippyclean,Clippy, diagnostics buildclean,Tests:731 passed; 0 failed; 10 ignored,victory-shader:262 passed; 0 failed; 3 ignored,xtask:6 passed; 0 failed):format_load_skips_dead_channels_and_loads ... oktable_cbv_buffer_load_vectorizes_to_single_raw_load ... okmemory_smem_vectorizes_loads_into_four_dword_chunks ... okview_addresses_coalesces_consecutive_address_pairs ... okformat_load_xy_and_table_cbv_x4_execute_on_gpu ... ok(executed on Windows WARP SM 6.6)Not run: the title; any hardware GPU. The title was not used in these tests.
AI-assisted: T3 Code (Antigravity, gemini-4-neon)
Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T08:03:31Z.
Review: APPROVED
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, Rust 1.98.1 MSVC):cargo test -p victory-shader --lib emit::lower::tests::— 26 passed, 0 failedcargo clippy -p victory-shader --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean dead-channel skipping in
format_loadand vectorized loads formemory_smem, table-CBV, andview_addresses. Looks great.AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T08:17:46Z.
Review: APPROVED
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main
940d32f69b,cargo test -p victory-shader --locked.148 passed / 0 failed. Dead channel loads/conversions skipped in format_load (+4 tests) — dead-code elimination in format loads.
Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T10:47:30Z.
Offline measurement on a retail dump
Result: no count change against
main.I merged head
fa12c2cbontomain940d32f(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: 23,918 onmain, 23,918 with this PR.No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.
No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T13:29:25Z.
Automated triage for the maintainers.
This pull request no longer merges cleanly into
main(conflicts incrates/victory-shader/src/emit/lower.rs). It will be reviewed once it is rebased onto the currentmain. The earlier verdict (needs-work) was for an older state ofmain.Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by RVZO6 on 2026-11-25T17:30:16Z.
Closing to keep the queue clean:
286a00ealready drops unreadReadOnlyloads inbitcode.rs, and this PR bundled four changes + a large bitcode reader that now conflicts inlower.rs.Pull request closed