Repository navigation
dxil: collapse forward s_cbranch_execz regions and make read-only loads branchless - #1834
raylitebull wants to merge 2 commits into
Conversation
|
@raylitebull the long Tested
Not tested
AI use: Claude Code (Claude Opus 5.5) built the tree, ran the title unattended with the memory sampling, read the logs and wrote this comment. |
|
Tested On The 70 nested regions collapsed to one block as expected. For all seven cases, direct DXIL and HLSL agreed on both output VGPRs across all 64 emulated lanes, restored EXEC, SCC and the live scalar register. The two VGPRs and the scalar register also matched a separate CPU calculation. Windows 11 build 26300, RTX 3080 Ti / 621.35, Ryzen 7 9800X3D, Rust 1.99.1 MSVC debug, DXC 1.8.2502.11. Not tested This covers synthetic branch collapse and scalar liveness. Retail driver compile time and the changed memory-load path were outside this check. AI-assisted. Codex (GPT-6 family, exact variant unavailable) extended and ran the fixture and drafted this report. Formatted-load retest on the same revision I ran Across all four dispatches, the 32 active lanes decoded the expected values from window 1 and got zero for a view outside the configured windows. The other 32 lanes kept both destination registers at their initial values. Window 0 held different data at the same low offsets. All 64 lanes per dispatch matched the CPU expectations.
Geometry retest on b1cae38 The stock geometry readback passed. A scratch extension exposed a split-wave64 regression when geometry crosses the EXECZ collapse threshold. In The PR reduced the CFG from 147 to 6 blocks. HLSL matched the CPU model. Direct DXIL returned zero vertices and triangles in the first group, where the model expected 72 vertices and 5 triangles. A local control that preserved the GS entry during block merging reduced the CFG from 147 to 7 blocks and restored exact record readback on both paths. On the same RTX 3080 Ti and toolchain, AI-assisted. Codex (GPT-6 family, exact variant unavailable) extended the fixture, ran the tests, and drafted this update. Geometry fix retest on Following up on the retest request. On an RTX 3080 Ti (621.35), Windows 11 build 26300, Rust 1.99.1 MSVC and DXC 1.8.2502.11, The new 70-branch fixture preserved the GS entry and matched the expected live geometry records on the GPU in split wave64, including 72 vertices and 5 triangles in the first group. Retail world loading and AMD remain unverified in this check. AI-assisted. Codex (GPT-6 family, exact variant unavailable) ran the tests and drafted this update. Rendered-output check on On the RTX 3080 Ti (621.35), Windows 11 build 26300, Rust 1.99.1 MSVC and DXC 1.8.2502.11, I extended only the test fixture. The 70-branch console shader was unchanged. The test mesh shader mapped the recorded primitive ID and vertex ordinal to six separate triangles, including one from the partial last group. Direct DXIL and HLSL matched all 1,024 RGBA pixels in split wave64, with 54 marked pixels and a verified interior pixel for each expected triangle. Both matched the same 702 live geometry record words against the CPU expectations.
AI-assisted. Codex (GPT-6 family, exact variant unavailable) extended the fixture, ran the tests, and drafted this update. |
4ed0c2d to
b1cae38
Compare
XCL #1834 on a GeForce RTX 4090 — ActivateProbes24 November 2026 · Direct DXIL · Four heap-backed memory windows The PR reduced the retail compute entry point from 21,303 to 397 basic blocks on this wave32 adapter running a split-wave64 program. Median first pipeline creation changed from 117.46 s to 79.55 s (-32.3%). PR #1834 · Shader optimization tracker #1269 ResultsTimes and memory figures are medians with the observed minimum and maximum in parentheses. Memory is process-private Windows commit. The driver peak includes the device, root signature, bytecode and driver allocations in the process.
For context, the RX 9070 title run on this same record reported 282.4 s and 151.5 s. That run used a different baseline, local changes and a live title. The RTX 4090 comparison here isolates the PR from its immediate parent. RX 9070 title measurements
The PR had the shorter first PSO time in 2/2 matched rounds. The immediate repeat is a separate warm measurement. Using only the 2 shared rounds, with order reversed in the second round, the first PSO medians are 117.46 s on base and 80.81 s on the PR (-31.2%). The table also includes the extra samples collected for the faster arm. Validation and scope
Reproduction
The per-trial table and machine-readable results include every timed observation. The files The retained harness can be rerun from the local benchmark directory with the pinned checkouts and local dump. Run the commands sequentially. python setup.py
python benchrun.py inspect
python benchrun.py translate
python collect.py
python checks.py
python analyze.py
python report.pyOpenAI Codex prepared the harness, ran the benchmark and drafted this report. XCL #1834 on RTX 4090 — smoke and world-entry testsThe PR compiled ActivateProbes 39.581 seconds faster in the running game (30.4%). Both builds reached the loading spinner after first-run setup. Neither produced a verified frame of the playable world during observation. The last two-second interval with any presents ended at 172.1 seconds on both builds. Compilation continued after that point. XCL PR #1834 · Shader tracker #1269 60-second smoke test
The PR produced seven more frames with 16 MiB higher peak commit. One run per build covered startup without menu input. This test does not measure gameplay FPS. World loadingThe same scripted gamepad input selected Confirm setup and start the game at 123 seconds on each fresh profile. I checked the presented images saved by XCL and the live game window. Both showed the loading indicator and later a black window reporting 0.0 FPS. The DirectStorage and driver logs continued after the visible transition.
What the driver completed. Durations below come from paired XCL driver-compile start/finish sequence numbers in the retail process. XCL recorded no supplied driver blob for either shader at the start of these calls.
The base reached the monitor's low-system-commit threshold with the second compile outstanding. That stop leaves its eventual compile time unknown. The PR completed both shaders and moved on to other pipelines. The last presents on both builds preceded these two driver calls, so the logs do not establish that either shader caused presentation to stop. Both builds also logged DirectStorage request errors including Reproduction and scope
Original smoke outputBasePR |
|
Update: geometry-boundary repair verified on exact head Native Windows 10 19045, Ryzen 7 7800X3D, RTX 3090 driver 591.74, Rust 1.98.1 MSVC, DXC 1.8.2502.11, debug;
Not tested on this head: retail smoke, the full workspace suite, AMD/native wave64, or new timing/memory measurements. The older timings below belong to AI use: Codex with GPT-6 Astra inspected the repair, prepared the negative control, ran the Windows checks and drafted this update. Earlier b1cae38 comparison and its limitsRTX 3090 validation of exact rebased head Tested
I also measured the same public, test-only nested-EXECZ kernel on both exact revisions, with two fresh shader sizes and reversed run order. Every GPU run passed and the checked outputs matched:
The timed interval includes pipeline creation and dispatch/readback; it is not a pure driver compile measurement. These two synthetic first-use observations are directional, not a retail workload or a stable latency distribution. Six 310-file source snapshots were SHA-256 checked before and after the remote runs. The author’s new head already includes the geometry merge and cache version 8, so I have no competing patch to propose. Not tested: retail smoke/gameplay, memory peak, AMD/Intel, and long world-loading behavior. The exact-head retail smoke gate is still pending; the common CLAMP failure prevents a clean full-suite claim on this machine. AI use: Codex desktop (GPT-6) prepared the synthetic test overlays, ran the Windows checks and drafted this report; all figures above come from the retained raw logs. |
Hardware test report — commit
|
|
Test report for 4ed0c2d on NVIDIA. Tested
main: PR:
Not tested
AI use
|
|
@thehollowedone Thank you for the sharp split-wave64 geometry retest on We'll preserve the GS entry boundary during block merging in |
b1cae38 to
c1acabc
Compare
|
@thehollowedone Pushed
If anyone on AMD or NVIDIA can verify |
c1acabc to
d899eb5
Compare
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
d899eb5 to
2a19e89
Compare
|
Rebased Pushed |
gsucristo
left a comment
There was a problem hiding this comment.
Reviewed the diff — strong CFG-reduction win (21,302 -> 396 blocks on ActivateProbes) that complements #2034 nicely on large shaders whose blocks aren't exact duplicates. The u128 backward scalar liveness + SaveExecZ/RestoreIfExecZ handling and GS-entry boundary pinning look well structured.
A few points from reading the diff:
- Window 0 readability assumption (
crates/xcl/src/gpu/dxil/lower_mem.rs,with_mem_load_i32s): Inactive/OOB lanes clamp the heap window toMEM_HEAP_BASE + 0(window 0, byte offset 0) and executeraw_loadunconditionally. Worth explicitly documenting/verifying the invariant that window 0 is always bound and readable at offset 0 (especially alongside PRs like #1992 that shift heap window slots). - Minor redundancy (
crates/xcl/src/gpu/dxil/lower_mem.rs): In the multi-dwordsmem/buffer_loadloops,let base_aligned = lw.safe_load_addr(base_aligned, cond);before the loop is redundant sinceatis already clamped withlw.safe_load_addr(at, cond)on every iteration. - Verification: As noted in the PR description, this still needs fresh
cargo test+scripts/smoke.ps1regression runs on the rebased head2a19e89before merge.
(AI disclosure: review drafted with Antigravity — exact model name not provided to the agent — and checked by the reviewer before posting.)
|
My #2034 merged after Setup: Linux through Wine, no card, release.
Read: // kernel.rs, translate_on_this_thread, in place of `None => Cfg::build_for(code, o.wave64, kernel)?,`
None => {
let flat = Cfg::build_with_threshold(code, o.wave64, kernel, usize::MAX)?;
let (none, none2) = (Default::default(), Default::default());
let take = (matches!(entry, Entry::Compute(_)) || kernel)
&& compact.unwrap_or_else(|| super::compact::large(&flat) && super::compact::plan_with(&flat, &none, &none2).is_some_and(|p| super::compact::wanted(&flat, &p)));
if take { flat } else { Cfg::build_for(code, o.wave64, kernel)? }
}
Not tested: anything on a card, the suite, your tests with these lines, and AMD, where you measured the driver's memory: which of the two forms its compiler takes better I cannot say. AI use: Claude Code (Claude Fable 5.2) made the merges, ran the translations and wrote this comment. Posted without review by a person: the account owner was away and reads replies later. |
Eliminates pathological basic-block and CFG blowup in the direct RDNA2 -> DXIL translator on large compute shaders by lowering read-only memory loads branchlessly and collapsing side-effect-free forward
S_CBRANCH_EXECZregions, cuttingActivateProbes(56c0cd3b82a00c6e) from 21,302 blocks to 396 (53.8x fewer) andamdxc64.dllcompile RAM from a +25.7 GB OOM spike to 2,737 MB (unblocking #1809 on AMD).Part of #1269 and #1673; unblocks #1809.
Why this exceeds ~800 lines (
+1219 / -31): the production change combines two closely coupled CFG-reduction passes (with_mem_load_i32sbranchless read-only loads inlower_mem.rsso load diamonds don't block region merging, pluscollapse_execz_regions+ backward scalar liveness incfg.rs), while the remainder consists of CFG unit tests, the GS-entry geometry regression test ingeometry_tests.rs, and the GPU differential test incore_tests.rs.What is in it
crates/xcl/src/gpu/dxil/lower_mem.rs: addwith_mem_load_i32sandsafe_load_addrfor read-only loads (mem_ld,mem_ld_n,ld_raw_guarded,ld_raw_u32_guarded, single-componentFormatLoad,smem), clamping out-of-range windows/inactive lanes to window 0 / byte offset 0 and selecting 0 on inactive lanes while keeping stores and atomics guarded.crates/xcl/src/gpu/dxil/cfg.rs,kernel.rs, &geometry_tests.rs: on CFGs with >= 128 blocks (EXECZ_COLLAPSE_MIN_BLOCKS), collapse acyclic forwardS_CBRANCH_EXECZregions (<= 2048 ops) in reverse RPO when all instructions pass a strict side-effect-free allowlist and abstract interpretation provesEXEC == 0, preserving the GS entry block boundary (gs_block) and only live-out modified scalar registers viaSaveExecZ/RestoreIfExecZ(u128backward scalar+SCC liveness); add 4 CFG unit tests plusgeometry_execz_collapse_preserves_gs_entry_boundaryandgpu_geometry_collapsed_execz_preserves_gs_entry.crates/xcl/src/gpu/dxil/core_tests.rs: add GPU differential testcollapsed_execz_kernel_matches_hlsl_on_gpuverifying bit-exact equivalence against HLSL acrossEXEC=0, partialEXEC, and fullEXEC.Tested
rustc 1.99.1 (58cf8f9c3 2026-10-13), rebased cleanly onto3da2abb(2a19e89).2a19e89was rebased onto3da2abb(resolving thecore_tests.rsEOF append alongside#1922via pure git during a local test hold); queued for GitHub ActionsBuild and testand fresh AMD / NVIDIA verification (gpu::dxil::cfg::tests,gpu::dxil::geometry_tests,gpu::dxil::core_tests).d899eb5(onto8e87fc7) passedcargo check --workspace --tests,gpu::dxil::cfg::tests(4/4), and CPUgpu::dxil::geometry_tests(2/2), and pre-GS headb1cae38passed RX 9070 XT (976pass,@eizispark) + RTX 3090 (@WebIdentity1).Regression run
scripts/smoke.ps1pair and GPU tests on2a19e89vs3da2abbhave not been run locally yet. AMD and NVIDIA reviewers are invited to verify2a19e89vs3da2abb(geometry_tests,core_tests,scripts/smoke.ps1) and post results in the comments.Not tested
cargo check/cargo test(cfg,geometry_tests,core_tests) andscripts/smoke.ps1on rebased head2a19e89, wave32-only AMD adapters, and Linux/Wine/vkd3d-proton.AI use