Repository navigation
Recompiler: reuse repeated s_buffer_load_dword* loads in direct DXIL - #2256
ramon-victor wants to merge 1 commit into
Conversation
|
Tested Independent Windows verification on clean
Both logged 20 native-wave64 skips, three per-lane f16/f32 refusals, unavailable driver-cache control and unavailable heap windows. The RTX 2080 SUPER also logged two skips for the missing D3D12 debug layer.
Wave64 follow-up (test-only overlay): In separate scratch checkouts at the same head, I changed only the existing
Not tested Full AMD workspace, Intel, retail smoke or shader samples, and performance. AI use Ran via Samaritan:
|
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
luckyteagirl
left a comment
There was a problem hiding this comment.
On 69b0bf6, this PR extends available-load reuse to S_BUFFER_LOAD_DWORD*, but reload::changes still misses VOPC SDWA's SD=1, SDST SGPR write. For example, two identical S_BUFFER_LOAD_DWORD instructions using descriptor s[4:7], separated by V_CMP_EQ_U32 SDWA writing s4, can reuse the first load's value for the second even though the descriptor base changed. The new buffer-load key makes this instruction family subject to the existing missed invalidation; the base emits two loads.
#2479 fixes the SDWA invalidation for the same analysis. Could this PR be stacked/rebased on that fix, or include it before buffer-load reuse is merged? Extending its CPU analysis fixture to a changed buffer descriptor would pin down this new instruction family. Source review only; I did not run the synthetic program.
|
Independent desktop NVIDIA verification of PR #2256 at head Environment
Targeted release tests & build (
|
| Command | Result |
|---|---|
cargo test --release -p xcl --lib s_buffer_load_reuses_and_tracks_four_sgpr_base -- --nocapture (3 consecutive runs) |
1 passed; 0 failed; 0 ignored; 1202 filtered out × 3 (0.00s × 3, 0 skipped) |
cargo test --release -p xcl --lib the_translator_emits_a_repeated_s_buffer_load_once -- --nocapture (3 consecutive runs) |
1 passed; 0 failed; 0 ignored; 1202 filtered out × 3 (0.01s × 3, 0 skipped) |
cargo test --release -p xcl --lib gpu_repeated_s_buffer_load_matches_fresh_load -- --nocapture (3 consecutive runs) |
1 passed; 0 failed; 0 ignored; 1202 filtered out × 3 (0.21s, 0.19s, 0.18s, 0 skipped; live RTX 4060 execution) |
cargo test --release -p xcl --lib gpu::dxil:: -- --test-threads=4 (3 consecutive runs) |
150 passed; 0 failed; 3 ignored; 1050 filtered out × 3 (3.27s, 3.18s, 3.29s, 0 skipped) |
cargo build --release -p xcl |
Clean build (1m 09s, exit 0, 0 new warnings) |
Paired quiet 60 s retail smoke (title: 29640639)
Exact parent & merge-base (426a5a745db4d5e4b037449ede0b70cb342f5192, same machine):
xcl-smoke v1
commit: 426a5a745db4d5e4b037449ede0b70cb342f5192
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1591 (PresentX 1591)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14477 MB
PR #2256 (69b0bf635f778ff79ccfca4025328ddee044e2bb):
xcl-smoke v1
commit: 69b0bf635f778ff79ccfca4025328ddee044e2bb
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1575 (PresentX 1575)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14460 MB
Runtime log observations (xcl.log)
9202log lines,0[ERROR]/ device-removal / panic lines (dxil_cache:460hits,0misses,0compilation failures;228background pipelines,0failures).- Final draw/memory telemetry in log:
19441 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample14460 MB committed by the process; video memory 6116 MB local, 4683 MB non-local.
Limits of coverage
- Repeated
s_buffer_load_dword*reuse, 4-SGPR descriptor-base invalidation tracking, single-load emission, and live RTX 4060 equivalence against fresh loads were directly verified via all 3 new tests (3/3each,0skipped) andgpu::dxil::(150/150× 3). - The 60 s retail smoke confirms zero runtime regression on
title: 29640639(single-run frame/commit delta vs. parent reflects normal startup variance, not this PR); direct-DXIL shader size or compile-time savings on cold retail shader caches were not separately profiled.
AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
Extends the direct DXIL scalar load reuse pass (
gpu::dxil::reload) to follows_buffer_load_dword*in addition tos_load_dword*, so repeated non-coherent constant-buffer loads reuse their earlier post-bounds-check values instead of re-emitting buffer bounds checks, window selection, anddx.op.rawBufferLoadcalls.Part of #1269.
What is in it
crates/xcl/src/gpu/dxil/reload.rs: extendKeywith abuffer: boolflag sos_load_dword*ands_buffer_load_dword*cannot alias; matchS_BUFFER_LOAD_DWORD..DWORDX16(excludingGLC/DLCcoherent loads, requiringsbase <= 121for the 4-SGPR descriptor, and tracking all foursbase..sbase+4descriptor registers inreads()as well as rejecting loads whoseSDATAoverlaps any descriptor or offset register). Add unit tests for 4-SGPR invalidation, self-overwrite/GLC exclusion, non-aliasing,rawBufferLoadcount reduction, and a wave32 GPU execution test checking repeated load reuse (including OOB zeroing) and fresh reload after a global store.crates/xcl/src/gpu/dxil/lower_mem.rs: checkself.reloadat the top ofLw::smembefore branching ons_buffer_load*so availables_buffer_load_dword*repeats read their saved SSA variables directly.On a seeded 600-program sample (
xcl shaders <archive> --direct --sample 600 --seed 3 --max-bytes 40000 --validate --threads 8, 573 programs within the cap), all 573/573 validate cleanly (0validator failures):42,232,344 B -> 42,202,120 B(-30,224 B,-0.07%)302.6 ms -> 292.3 msTested
621.24, wave32), AMD Ryzen 7 5700X, Windows 11 Pro26300,rustc 1.99.0(x86_64-pc-windows-msvc), DXC/DXIL1.8.2502.11(Windows SDK10.0.26100.0).cargo test -p xcl --lib gpu::dxil::reload::tests(debug):9 passed; 0 failed(includings_buffer_load_reuses_and_tracks_four_sgpr_base,the_translator_emits_a_repeated_s_buffer_load_once, andgpu_repeated_s_buffer_load_matches_fresh_loadon the RTX 3070)..\scripts\test.ps1(debug, full workspace):1246 passed; 0 failed; 46 ignored(25 GPU sub-checks skipped on this wave32 adapter: 21no wave64, 1no heap windows, 3 per-lane#1426refusals).cargo build --release -p xcl+ direct DXIL validation sweep on 573 sampled retail shader programs:573/573translated anddxil.dll-validated (0failures).Regression run
Not tested
XCL_SAMPLE_*env vars unset).AI use
reload.rsandlower_mem.rs, implementeds_buffer_load_dword*reuse and unit/GPU tests, ran the workspace test suite, retail shader validation sweep, and 60 s smoke regression run.