Recompiler: enable scalar reload CSE for direct DXIL vertex and pixel shaders #2446
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2446
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2446"
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?
@emusynths on GitHub · 2026-11-25 19:18 UTC · original
emusynths:dxil-gfx-scalar-reloads→main· +109 −3 · 3 files · 1 commits · openEnable scalar reload CSE (
reload::analyze) for direct-DXIL vertex and pixel shaders (Entry::Vertex,Entry::Pixel). Previouslyfollow_loadswas restricted toEntry::Kernel | Entry::Compute(_)because two-phaseEntry::Geometryenters its GS blocks via edges outside the CFG; vertex and pixel shaders use the exact same single-entryCfg::buildas compute, so repeateds_load_dword*descriptor reloads can safely reuse their first values and avoid redundant memory-window switches.Part of #2088.
What is in it
crates/xcl/src/gpu/dxil/kernel.rs: includeEntry::Vertex(_) | Entry::Pixel(_)infollow_loadssoreload::analyze(&cfg)runs for direct-DXIL VS and PS.crates/xcl/src/gpu/dxil/reload.rs: addgraphics_stages_emit_a_repeated_load_onceverifying DXIL validation, repeateds_load_dwordx4elimination, and store-invalidation across 4 memory windows for bothtranslate_vertexandtranslate_pixel.Tested
Hardware: NVIDIA GeForce RTX 5090 32 GB (driver 621.01, wave32-only), AMD Ryzen 9 5950X, 64 GB RAM, Windows 11 26300,
rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2609.5, debug tests / release benchmarks and smoke runs.Clean head
3a71471c80. cargo build --workspace succeeded. cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output reported 1361 passed, 4 failed, 46 ignored and 25 SKIPPED notices (1 heap windows unavailable, 21 no wave64, 3 unsupported per-lane translation). The four NVIDIA compute fuzz failures match #1905.Both gpu_graphics_scalar_reloads_match_hlsl and graphics_stages_emit_a_repeated_load_once passed on the RTX 5090.
Cold RTX 5090 pixel-shader
CreateGraphicsPipelineStatebenchmark (XCL_DIRECT_DXIL=all,XCL_TRANSLATED_CACHE=0,--windows 4 --repeat 3,ShaderCacheControl(IMPLICIT_DRIVER_MANAGED | IMPLICIT_D3D_CACHE_FOR_DRIVER, DISABLE), distinct exe basenames per build, measured with #2438's--measure-psoon2898511vs926428e):c7f0a851a539391c1f0e250e6f22b0593552327805b442b77221675a6826d87634253cc8188405fdRegression run
60 seconds per build, XCL_NETWORK=0, XCL_PRESS_AT=18:A,30:A,44:A,52:A and XCL_FRAME_DUMP=300.
XCL_DIRECT_DXIL=all on both builds.
main
PR head
Not tested
AMD, Intel, native wave64 and shader execution-time benchmarks on this revision.
AI use
--measure-psobenchmarks, and smoke runs, and drafted this PR description.@emirduran707 on GitHub · 2026-11-25 19:41 UTC · original
Independent AMD RDNA4 (native wave64) test report on exact head
926428e48c2e4944f714ac96a5efc6c61f13705b(clean detached checkout, no local changes).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1362 passed, 2 failed, 46 ignored; 8 SKIPPED (6 inlower_dxil::tests::{f16,f32}_programs_on_the_gpurefused by per-lane form;heap_window_out_of_memory_falls_back_to_the_switch_form;pso_measurement_compiles_an_exact_synthetic_record). Allgpu::dxil::reload::testsand native wave64 GPU tests ran and passed.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1seed 722 andfuzz_validate_and_gpu_3seed 1599) are pre-existing on unmodifiedmainon this GPU.Regression run (60 s retail-title smoke,
XCL_NETWORK=0, release)(Matched
main68a284abaseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)Not tested
AI use
@emusynths on GitHub · 2026-11-25 19:59 UTC · original
Additional in-title check covering the
XCL_DIRECT_DXIL=allpath on exact head926428e48c2e4944f714ac96a5efc6c61f13705b(RTX 5090 32 GB, driver 621.01, Ryzen 9 5950X, 64 GB RAM, Windows 11 26300, release build,XCL_DIRECT_DXIL=all):AI use: Antigravity (Gemini 4 Neon) ran the smoke check and posted this comment.
@DavidM1911 on GitHub · 2026-11-25 20:29 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: 1038 passed, 1 failed in one parallel run; the failing test passes on a single-threaded rerun (1039/0). Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.Thanks!
@emusynths on GitHub · 2026-11-25 21:40 UTC · original
@bmjask, please take another look at
3a71471. The new graphics execution test checks that a reused scalar load produces the expected vertex positions and pixel colors on the RTX 5090, and matches the HLSL output. The original load-elimination test also passed. The description includes the full-suite results and the post-push offline smoke pair.@DarkPanda69 on GitHub · 2026-11-25 19:31 UTC · original · edited 2026-11-25 22:01 UTC
Update for head
3a71471: paired rerun onmaine1d84b7with the same command and cards. On both cards the only result changes againstmainaregraphics_stages_emit_a_repeated_load_onceand the new draw testgpu_graphics_scalar_reloads_match_hlsl, both ok, with no new skips. The draw test takeswave64 = !runner::graphics_wave32(), which is false on both cards: the RX 9070 XT also runs 32-lane waves. So it ran the wave32 VS / PS form on both, not native wave64. RX 9070 XT: 700 passed, 2 failed (the #2115 fuzz seeds), 6 SKIPPED. RTX 3060: 702 passed, 0 failed, 24 SKIPPED.AMD native wave64 run (listed as untested), plus an RTX 3060, paired against
mainwith the direct translator on for the whole GPU suite.Head
926428eapplied onmain23865ea, debug, Windows 11 Pro 26200,XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4, onmainand on this PR for each card:mainPer-test comparison: on both cards the only difference is the new
graphics_stages_emit_a_repeated_load_once(ok). No existing test changes result or skip state. The 2 RX 9070 XT failures are the AMD fuzz seeds tracked in #2115, the same onmain.Not tested: a title with
XCL_DIRECT_DXIL=all, GPU time of the translated pixel shaders.AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@thehollowedone on GitHub · 2026-11-26 01:31 UTC · original
Independent RTX 3080 Ti check of #2446 head
3a71471. Windows 11 build 26300, Ryzen 7 9800X3D, NVIDIA driver 621.35, Rust 1.99.1 MSVC, DXC 1.8.2502.11; debug tests, synthetic inputs only.Tested
cargo test --offline --locked -p xcl --lib gpu_graphics_scalar_reloads_match_hlsl -- --nocapture --test-threads=1passed 1/0/0 without a skip. Its GPU draw readback matched the HLSL path and the expected pixel positions and colors.graphics_stages_emit_a_repeated_load_oncealso passed 1/0/0; it validates the emitted VS/PS DXIL and checks repeated loads and store invalidation across four windows.cargo build --offline --locked --workspacepassed.cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4reported 1,365 passed, 0 failed, 46 ignored, with 25SKIPPEDnotices.b49be18; there was no conflict. On that integration, the same workspace build passed, the GPU draw test passed 1/0/0 without a skip, and the full suite reported 1,437 passed, 0 failed, 47 ignored, with 25SKIPPEDnotices. TheInvalid bitcode signaturelog line belongs to a passing malformed-container test.Not tested
AI use
@DavidM1911 on GitHub · 2026-11-26 01:50 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
@oni-swr on GitHub · 2026-11-26 07:01 UTC · original
Independent native Windows RX 7800 XT verification at
3a71471c80b842d8e6f2bffd74556947fc11921bagainst its exact parent,2898511af1c038a2ef809719e9b6f89e5675c422.Environment: RX 7800 XT (driver 32.0.31035.1003), Ryzen 7 5700X3D, Windows 11 Pro 26200.9974, Rust 1.100.0 MSVC, DXC 1.8.2502.11. The head passed
cargo build --workspace --locked -j 4.cargo test --locked -j 4 --workspace --no-fail-fast -- --test-threads=4 --show-output:Both runs reproduced the same seed-722 failure in
fuzz_validate_and_gpu_1(#2115). The skips also matched: six unsupported per-lane cases and one unavailable heap-window case.The synthetic
gpu_graphics_scalar_reloads_match_hlslfixture ran without a skip and matched HLSL and expected positions and colors with the wave32 form. The syntheticgraphics_stages_emit_a_repeated_load_oncetest also ran and passed, covering repeated-load elimination and store invalidation in both stages. No retail smoke run.AI use: Codex (gpt-6.2-sol) ran and compared the tests and drafted this report.
@bmjask on GitHub · 2026-11-25 20:56 UTC · original · reviewed
No concrete source-level defect found. Enabling reload analysis for VS/PS retains the existing safety exclusions and CFG availability handling; title smoke/AMD/RTX evidence is encouraging. Nonblocking gap: tests count rawBufferLoad elimination but do not execute a Direct-DXIL VS/PS fixture whose output depends on reused scalar data. Add graphics execution parity coverage and provide current CI confirmation.
@luckyteagirl on GitHub · 2026-11-26 07:40 UTC · original · reviewed
This enables
reload::analyzefor VS/PS (kernel.rs:206,334) while the current base'sreload::changesstill missesVOPCSDWASD=1writes toSDSTand some cache barriers. Open #2479 has a failing-first fixture for those invalidations. For a graphics program that loads throughs[4:5], overwritess4with such an SDWA compare, then repeats the load, this PR can reuse the value from the old address instead of emitting the second load. The existing VS/PS tests cover repeated loads and an ordinary store, not this address-register write.Could #2446 depend on #2479's invalidation fix before merge and include a VS or PS variant of its fixture? This is a source-derived cross-PR dependency at exact #2446 head
3a71471c80b842d8e6f2bffd74556947fc11921b; #2479's live head isd423c902918bcac16c8e8fe6192e85e2003c16b0. I have not run a graphics GPU reproduction. AI-assisted review with Codex.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.