Skip to content

dxil: collapse forward s_cbranch_execz regions and make read-only loads branchless - #1834

Open
raylitebull wants to merge 2 commits into
xcl-dev:mainfrom
raylitebull:fix/dxil-block-collapse
Open

raylitebull wants to merge 2 commits into
xcl-dev:mainfrom
raylitebull:fix/dxil-block-collapse

Conversation

@raylitebull

@raylitebull raylitebull commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

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_EXECZ regions, cutting ActivateProbes (56c0cd3b82a00c6e) from 21,302 blocks to 396 (53.8x fewer) and amdxc64.dll compile 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_i32s branchless read-only loads in lower_mem.rs so load diamonds don't block region merging, plus collapse_execz_regions + backward scalar liveness in cfg.rs), while the remainder consists of CFG unit tests, the GS-entry geometry regression test in geometry_tests.rs, and the GPU differential test in core_tests.rs.

What is in it

  • crates/xcl/src/gpu/dxil/lower_mem.rs: add with_mem_load_i32s and safe_load_addr for read-only loads (mem_ld, mem_ld_n, ld_raw_guarded, ld_raw_u32_guarded, single-component FormatLoad, 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 forward S_CBRANCH_EXECZ regions (<= 2048 ops) in reverse RPO when all instructions pass a strict side-effect-free allowlist and abstract interpretation proves EXEC == 0, preserving the GS entry block boundary (gs_block) and only live-out modified scalar registers via SaveExecZ/RestoreIfExecZ (u128 backward scalar+SCC liveness); add 4 CFG unit tests plus geometry_execz_collapse_preserves_gs_entry_boundary and gpu_geometry_collapsed_execz_preserves_gs_entry.
  • crates/xcl/src/gpu/dxil/core_tests.rs: add GPU differential test collapsed_execz_kernel_matches_hlsl_on_gpu verifying bit-exact equivalence against HLSL across EXEC=0, partial EXEC, and full EXEC.

Tested

  • Toolchain: Windows 11 x64, rustc 1.99.1 (58cf8f9c3 2026-10-13), rebased cleanly onto 3da2abb (2a19e89).
  • 2a19e89 was rebased onto 3da2abb (resolving the core_tests.rs EOF append alongside #1922 via pure git during a local test hold); queued for GitHub Actions Build and test and fresh AMD / NVIDIA verification (gpu::dxil::cfg::tests, gpu::dxil::geometry_tests, gpu::dxil::core_tests).
  • Earlier head d899eb5 (onto 8e87fc7) passed cargo check --workspace --tests, gpu::dxil::cfg::tests (4/4), and CPU gpu::dxil::geometry_tests (2/2), and pre-GS head b1cae38 passed RX 9070 XT (976 pass, @eizispark) + RTX 3090 (@WebIdentity1).

Regression run

  • Exact-head 60 s scripts/smoke.ps1 pair and GPU tests on 2a19e89 vs 3da2abb have not been run locally yet. AMD and NVIDIA reviewers are invited to verify 2a19e89 vs 3da2abb (geometry_tests, core_tests, scripts/smoke.ps1) and post results in the comments.

Not tested

  • cargo check / cargo test (cfg, geometry_tests, core_tests) and scripts/smoke.ps1 on rebased head 2a19e89, wave32-only AMD adapters, and Linux/Wine/vkd3d-proton.

AI use

  • Antigravity assisted with implementation, rebase, CFG/liveness design, and test verification; the author reviewed the diff.

@HKEY-Funk-Machine

Copy link
Copy Markdown

@raylitebull the long XCL_DIRECT_DXIL=1 title run you asked for, on AMD RDNA4 (RX 9070). #1834 nearly halves cs 56c0cd3b82a00c6e's driver time in the title (151.5 s, against 282 s on c4d37be's parent 4178e88 with the same settings). cs 95cc13288a27a96e still doesn't build: about 6 min into its driver compile, process memory rose from ~47 GB to 104 GB in ~70 s, the next builds returned 0x8007000E, and XCL aborted on a failed 1.5 MB allocation (0xc0000409).

Tested

  • 4ed0c2d + D3D12.X: title texture reads outside the coherent window use the safe copy #751, plus two local-only changes: skip InitializeApiImplEx2 in xgameruntime/api.rs (hangs here), and a log line before and after each compute CreateComputePipelineState. Release.
  • AMD Radeon RX 9070 (RDNA4, native wave64), driver 32.0.32015.7029, Ryzen 9 7945HX3D, 32 GB RAM (page file grows to ~120 GB of system commit), Windows 11 Pro 26300, Rust 1.100.0, DXC 1.9.2602.17.
  • Retail title, XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_TRANSLATED_CACHE=0 XCL_PSO_DISK_CACHE=0 XCL_NETWORK=0, A pressed with XCL_PRESS_A_AT (every 2 s from 8 to 90 s), 30 min limit, xcl.exe copied to a new name so the AMD driver's cache was cold. Process memory sampled every 2 s.
4178e88 (#1748), same settings 4ed0c2d (#1834)
cs 56c0cd3b82a00c6e 3 594 476 B, built in 282.4 s 3 025 196 B, built in 151.5 s
cs 95cc13288a27a96e 3 324 912 B, 0x8007000E after 996 s 3 181 292 B, still in the driver when the process aborted after 7.4 min
peak private bytes 104.6 GB 104.1 GB
builds returning 0x8007000E 39 2 (in the second before the abort)
end stopped by me at ~19 min XCL abort, 0xc0000409, at 8.4 min (memory allocation of 1572864 bytes failed)
compute builds / driver time, sum 474 / 2 557 s 373 / 674 s
frames presented before the title waits 1 800 1 800
  • Memory over time: with both programs in the driver, the process stayed at 60–67 GB. After cs 56c0cd3b82a00c6e finished it fell to ~43 GB. Then, with cs 95cc13288a27a96e the only large build in the driver, it climbed 47 → 72 → 95 → 104 GB between 16:48:04 and 16:49:16. So on this driver, the late phase of that one compile seems to need ~55 GB or more on its own. I did not separate it from the title's other activity, though (no isolated build).
  • No crash or device removal before the out-of-memory abort.

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.

@thehollowedone

thehollowedone commented Nov 24, 2026 •

Copy link
Copy Markdown

Tested

On 4ed0c2d1, I ran the stock EXECZ-collapse fixture on the RTX 3080 Ti and then extended it with four asymmetric masks. These included upper-half-only activity, lower-half-only activity, an inner mask in the opposite half that leaves no active lanes, and full launch EXEC narrowed to the upper half.

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. cargo test --offline --locked -p xcl --lib collapsed_execz_kernel_matches_hlsl_on_gpu -- --nocapture --test-threads=1 passed 1/1 as shipped and 1/1 with the added masks. Zero skips. The extended fixture required this adapter and forced split wave64.

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 BUFFER_LOAD_FORMAT_X on the RTX 3080 Ti in split wave64, with two configured memory windows. The 16-bit signed normalized input started at byte 3 of a dword, so the load crossed a dword boundary. Both HLSL and direct DXIL passed with root-UAV switching and with descriptor-heap windows.

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.

cargo test --offline --locked -p xcl --lib scratch_formatted_load_preserves_split_wave_masks_and_windows -- --nocapture --test-threads=1 passed 1/1. The stock gpu_heap_windows_reject_out_of_uma_aliasing also passed with XCL_DIRECT_DXIL=1. Zero skips. These are synthetic readbacks on the same hardware and toolchain listed above.

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 branchy_program from geometry_tests.rs, immediately after the GS initializes EXEC, add 70 forward S_CBRANCH_EXECZ +1 branches, each skipping a single V_MOV_B32 v52, 1.0, and omit the original unconditional move to v52. Keep the existing ES S_SETPC_B64 handoff and the 25-primitive draw.

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, cargo test --offline --locked -p xcl --lib gpu::dxil::geometry_tests:: -- --nocapture --test-threads=1 passed 3/3 with that local control, including the extended fixture. The four CFG unit tests and the stock collapsed-EXECZ compute GPU test also passed. Zero skips. This retest used synthetic shaders and did not measure retail world load.

AI-assisted. Codex (GPT-6 family, exact variant unavailable) extended the fixture, ran the tests, and drafted this update.

Geometry fix retest on c1acabc

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, cargo test --offline --locked --release -p xcl --lib gpu::dxil::geometry_tests -- --nocapture --test-threads=1 passed all four tests with zero failures, ignored tests or runtime skips.

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 d899eb5

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.

cargo test --offline --locked --release -p xcl --lib gpu::dxil::geometry_tests -- --nocapture --test-threads=1 passed 4/4. The same test binary passed 4/4 with gpu::dxil::cfg::tests and 1/1 with collapsed_execz_kernel_matches_hlsl_on_gpu, with zero skips. This covers synthetic rendering through the test mesh shader. Retail world load and native wave64 were outside this check.

AI-assisted. Codex (GPT-6 family, exact variant unavailable) extended the fixture, ran the tests, and drafted this update.

@minimalhipster990

minimalhipster990 commented Nov 24, 2026 •

Copy link
Copy Markdown

XCL #1834 on a GeForce RTX 4090 — ActivateProbes

24 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

Results

Times 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.

Metric Base c4d37be PR 4ed0c2d Median change
Basic blocks in final DXIL 21,303 397 -98.1%
Conditional branches 13,390 211 -98.4%
PHI instructions 21,614 589 -97.3%
DXIL container bytes 3,978,772 3,408,880 -14.3%
Direct DXIL generation (ms) 620.61 (602.88–642.80) 560.22 (547.39–567.86) -9.7%
Peak private memory through DXIL generation (MiB) 241.4 (240.4–241.8) 201.9 (201.4–202.8) -16.3%
First driver PSO creation (s) 117.46 (115.56–119.37) 79.55 (78.28–81.24) -32.3%
Peak private memory through first PSO creation (MiB) 3,373.6 (3,347.7–3,399.6) 1,525.1 (1,524.3–1,525.3) -54.8%
Immediate repeat PSO creation (ms) 30.57 (27.70–33.43) 28.38 (27.86–28.92) -7.2%

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

  • BASE: six timed translations and 2/2 completed first PSO attempts. Median private memory immediately before the two calls was 99.0 MiB and 100.9 MiB respectively.

  • PR: six timed translations and 4/4 completed first PSO attempts. Median private memory immediately before the two calls was 98.5 MiB and 101.7 MiB respectively.

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

  • The input was the local retail record indirect_diffuse_lighting:CS_ScreenProbes_ActivateProbes_9083c094_Wrapped. Its inflated Xbox blob was 21,140 bytes, FNV-1a 56c0cd3b82a00c6e; the selected compute program contained 488,744 bytes of ISA with an 8×8×1 thread group. The runtime adapter query selected split wave64 on the RTX 4090.
  • All 12 timed outputs passed the SDK DXIL validator and matched the saved DXIL for their revision by length and FNV-1a. Driver processes loaded those exact artifacts. Both contain descriptor-heap handle creation. D3D12 OPTIONS11 confirmed 64-bit atomics on descriptor-heap resources.
  • Basic blocks include the unnamed entry block. The count of terminators in the disassembled main agrees with one entry plus the explicit labels (21,302 on base, 396 on the PR). This convention and the split-wave configuration matter when comparing counts and container sizes with the PR author's native-wave results.
  • The PR’s upstream differential kernel collapsed its 70 nested EXECZ sequences to one CFG block and ran both direct DXIL and an HLSL reference on this 4090. Empty, partial and full EXEC all matched for EXEC, SCC, s10 and the checked VGPRs in all 64 lanes. The local test wrapper failed missing prerequisites and logged each GPU readback, preserving the upstream assertions. This synthetic kernel used its upstream one-window configuration. The separate CFG test filter passed 4/4 tests.
  • The retail test covers direct translation, DXIL validation and driver pipeline creation. The GPU output comparison covers the differential kernel. No captured game-state dispatch or rendered-frame comparison was performed for ActivateProbes.

Reproduction

  • Base was the PR's immediate parent c4d37bec1bb4286eb373aea963404a23f13401fa, head 4ed0c2d1f1e18915607b92e01da3f8bba367feae. Both used locked release builds and the same measuring code. Commit comparison
  • GeForce RTX 4090, NVIDIA 621.24, Ryzen 7 5800X3D, Windows 11 build 26300.10075, Rust 1.99.1 MSVC, Windows SDK 10.0.26100.0, DXIL validator 1.9.2602.17. XCL used its per-instruction kernel::translate_compute entry point with XCL_DIRECT_DXIL=1, XCL_HEAP_WINDOWS=1, mem_windows=0x104 and sampler base zero. The direct translator emitted and signed DXIL. DXC compilation was used only for the synthetic HLSL reference.
  • Timed translation starts after blob parsing and device setup and ends on return of the DXIL container. Validation and disassembly were outside that interval. Driver timing covers CreateComputePipelineState only, using XCL's compute ABI root signature and the actual retail static sampler. Both revisions used fresh serial processes, unique executable paths, identical driver settings and no application-provided PSO blob. Within each round the revision order alternated. The plan allowed four driver rounds per arm, reduced to two if the first process took over 90 s. Each attempt had a 12-minute ceiling, a 24 GiB private-commit guard and a 5 GiB system commit reserve.
  • Windows' process peak commit counter (PROCESS_MEMORY_COUNTERS_EX.PeakPagefileUsage) was captured immediately after each timed stage. A fresh process for each stage isolates translation from driver memory. The driver peak is the process lifetime high-water mark through the first PSO call. It excludes GPU VRAM and kernel allocations outside the measuring process.
  • The request to disable the implicit driver shader cache returned 0x887A002D. First calls are fresh-process observations. Persistent driver caching could influence the timing; immediate repeats were recorded separately. A full title run and frame time were outside this benchmark.

The per-trial table and machine-readable results include every timed observation. The files trials.csv and results.json are retained locally.

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.py

OpenAI Codex prepared the harness, ran the benchmark and drafted this report.


XCL #1834 on RTX 4090 — smoke and world-entry tests

The 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

Measurement Base 689f2db PR b1cae38
Frames shown / PresentX calls 1,197 / 1,197 1,204 / 1,204
Presents per two seconds, final three intervals 61, 60, 60 60, 60, 60
Peak process commit (MiB) 15,522 15,538
Logged crashes / device removals 0 / 0 0 / 0
Exit 0x0 0x0

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 loading

The 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.

Measurement Base 689f2db PR b1cae38
First captured loading spinner after confirmation frame 3,080 at 123.710 s frame 3,020 at 124.707 s
Last saved frame, still on the loading screen frame 3,680 at 163.474 s frame 3,560 at 161.420 s
Last activity interval with presents 4 presents in interval ending at 172.065 s 2 presents in interval ending at 172.061 s
Process private commit at ~480 s, sampled 32.51 GiB 30.78 GiB
Peak process private commit, sampled 32.86 GiB 32.05 GiB
Minimum available system commit, sampled 0.92 GiB 1.65 GiB
DirectStorage requests / failed, summed across activity intervals 87,269 / 317 87,216 / 252
End of observation Monitor stopped the run at 484.7 s XCL ended the title at the 900 s limit, exit 0x0 (903.1 s wall clock)

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.

Compute shader record Base PR
56c0cd3b82a00c6e (ActivateProbes) 3,978,772-byte DXIL. Driver 130.207 s, completed at 445.055 s 3,408,880-byte DXIL. Driver 90.626 s, completed at 401.320 s
95cc13288a27a96e 3,324,912-byte DXIL. Started at 446.102 s. No completion recorded before the monitor stopped the run 3,181,292-byte DXIL. Driver 26.555 s, completed at 428.788 s

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 0x89240009. Neither run logged an unhandled exception or device removal. The PR’s final report counted 3,612 frames shown and 3,612 PresentX calls, all accounted for by the activity intervals through 172.061 s.

Reproduction and scope

  • Retail package 1.0.2.1, title label 7850d621. NVIDIA GeForce RTX 4090, driver 621.24, AMD Ryzen 7 5800X3D, 32 GB installed RAM, Windows 11 build 26300. Rust 1.99.1 MSVC, DXC/DXIL 1.9.2602.17.
  • Clean release builds from 689f2db477c3c062cf162649781640ef8a977c18 and its direct child b1cae384a163b97db59a80c57fd3182c2517a5d5, built with cargo build --release --locked -p xcl --bin xcl. The executable used for each smoke test and long run matched its build's SHA-256.
  • Base ran first, then PR, in each phase. Each run used a new XCL data root and DXIL cache, with direct DXIL and heap windows enabled, XCL networking off, and the RTX 4090 selected explicitly. The NVIDIA driver's internal cache state was uncontrolled. The measured world runs started without a save. Earlier menu-navigation trials were excluded.
  • Short runs used each checkout's own scripts/smoke.ps1 -Game <folder> -Seconds 60 -Xcl <release-exe>. Long runs used xcl run <folder>, XCL activity logging, frame readback every 60 frames and a 900-second in-game limit. Process private bytes and available system commit were sampled about once per second. The monitor stopped a run after three samples below 1 GiB available system commit, or any sample below 256 MiB. XCL's activity intervals are two seconds. Timings in the table use the game log's clock unless marked as a monitor measurement.
  • Gamepad playback used A every 2 s from 8 through 70 s, then Down at 74 and 85, A at 88 and 100, Down at 104, A at 116, Down at 119, A at 123 and every 6 s from 129 through 201. Frame sampling limits the precision of visual milestones.
  • AI use: OpenAI Codex (GPT-6 family) built and ran both revisions, inspected the logs and images, and prepared this report.

Original smoke output

Base

xcl-smoke v1
commit: 689f2db477c3c062cf162649781640ef8a977c18
gpu: NVIDIA GeForce RTX 4090
title: 7850d621
seconds: 60
exit: 0x0
frames shown: 1197 (PresentX 1197)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 15522 MB

PR

xcl-smoke v1
commit: b1cae384a163b97db59a80c57fd3182c2517a5d5
gpu: NVIDIA GeForce RTX 4090
title: 7850d621
seconds: 60
exit: 0x0
frames shown: 1204 (PresentX 1204)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15538 MB

@WebIdentity1

WebIdentity1 commented Nov 24, 2026 •

Copy link
Copy Markdown

Update: geometry-boundary repair verified on exact head c1acabc095db07352e86220edf6e57504b538b79.

Native Windows 10 19045, Ryzen 7 7800X3D, RTX 3090 driver 591.74, Rust 1.98.1 MSVC, DXC 1.8.2502.11, debug; XCL_ADAPTER=3090, XCL_SPLIT_WAVE64=1.

cargo test --locked -p xcl --lib -- gpu::dxil::geometry_tests gpu::dxil::core_tests::collapsed_execz_kernel_matches_hlsl_on_gpu --test-threads=1 --show-output
  • Exact head: 5 passed / 0 failed / 0 ignored, zero skips. This includes the new geometry boundary/record regressions, existing Direct/HLSL geometry records, and the nested-EXECZ compute GPU comparison. The compute fixture still asserts collapse to one block.
  • Negative control: the same head and tests with only cfg.rs restored from b1cae38: 3 passed / 2 failed / 0 ignored, zero skips. The new static check reports the GS entry merged into ES; the GPU record test produces zeros, including counts 0,0 instead of 72,5. The other three tests pass. This isolates the new boundary repair.
  • Both runs recompiled XCL and matched all 311 source-file SHA256 hashes before/after. Candidate source is unmodified c1acabc; no competing patch.

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 b1cae38 only. This answers the requested Ampere geometry check; exact-head retail smoke remains outstanding.

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 limits

RTX 3090 validation of exact rebased head b1cae384a163b97db59a80c57fd3182c2517a5d5 against main 689f2db477c3c062cf162649781640ef8a977c18. Native Windows 10 19045, driver 591.74, Rust 1.98.1 MSVC, XCL_ADAPTER=3090; synthetic fixtures only.

Tested

  • cargo build --locked --workspace: exit 0 on both revisions.
  • cargo test --locked --workspace --no-fail-fast -- --test-threads=4 --show-output: main 973 passed / 2 failed / 45 ignored, PR 978 passed / 1 failed / 45 ignored, across 20 targets, with 25 explicit SKIPPED lines each. gpu_clamp_and_omod_per_instruction failed on both. d32s8_targets_take_their_own_size_of_video_memory failed only on main; this PR does not change that path. No PR-only failure.
  • The exact-head collapsed_execz_kernel_matches_hlsl_on_gpu passed 1/0/0 with a test-only prerequisite guard that asserted and printed NVIDIA GeForce RTX 3090, split-wave64 support and DXC, preventing its normal silent early return.

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:

Repeats Main: CFG / DXIL / first pipeline+dispatch PR: CFG / DXIL / first pipeline+dispatch
203 813 blocks / 34,272 B / 180.724 ms 1 block / 12,732 B / 39.701 ms
204 817 blocks / 34,428 B / 181.376 ms 1 block / 12,784 B / 39.983 ms

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.

@eizispark

Copy link
Copy Markdown

Hardware test report — commit b1cae38

Verified b1cae384a163b97db59a80c57fd3182c2517a5d5 (rebased onto main 689f2db477c3c062cf162649781640ef8a977c18, clean merge): pass (0 new failures vs main 689f2db).

Tested

  • Hardware: AMD Radeon RX 9070 XT (RDNA4, native wave32 + wave64, driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 x64, rustc 1.100.0 (0ef1bc386 2026-11-09), debug tests + release smoke
  • cargo test --workspace --no-fail-fast -- --test-threads=4 --skip gpu::dxil::msaa_tests::gpu_direct_msaa_image_loads: 976 passed, 2 failed, 45 ignored (8 skipped), vs main 689f2db 972 passed, 2 failed, 45 ignored (8 skipped) on this adapter:
    • Skipped filter (--skip gpu::dxil::msaa_tests::gpu_direct_msaa_image_loads) and the 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_3) are pre-existing on main 689f2db (#1679) on RDNA4; 0 new failures
    • 8 skipped: 6 gpu::recomp::lower_dxil::tests f16/f32 direct-DXIL per-lane cases refused where #1426 semantics differ from the console's; shaders::tests::pso_measurement_compiles_an_exact_synthetic_record (Windows Developer Mode required, 0x887A002D); heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows
  • gpu::dxil::cfg::tests (4/4 passed: loop_entered_in_the_middle_is_split, live_out_scalar_reg_is_saved_and_restored, nested_execz_collapses_to_single_block, unsafe_execz_regions_are_not_collapsed), gpu::dxil::core_tests::collapsed_execz_kernel_matches_hlsl_on_gpu, and native RDNA4 wave64 GPU tests (gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, console_wave64_compute_through_the_pso_hook_dispatch_and_read_back) all passed

Regression run (scripts/smoke.ps1, 60 s, warm shader/driver cache)
main (689f2db477c3c062cf162649781640ef8a977c18):

xcl-smoke v1
commit: 689f2db477c3c062cf162649781640ef8a977c18
gpu: AMD Radeon RX 9070 XT
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1674 (PresentX 1674)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14862 MB

PR (b1cae384a163b97db59a80c57fd3182c2517a5d5):

xcl-smoke v1
commit: b1cae384a163b97db59a80c57fd3182c2517a5d5
gpu: AMD Radeon RX 9070 XT
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1677 (PresentX 1677)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14855 MB

Not tested

  • NVIDIA/Intel GPUs, XCL_SAMPLE_* pack benchmarks, gameplay past the menus

AI use

  • Verified and formatted with Antigravity (Google DeepMind, Gemini 4 Carbon).

@grahamster2

Copy link
Copy Markdown
Collaborator

Test report for 4ed0c2d on NVIDIA.

Tested

  • RTX 3080 10 GB (NVIDIA 610.88), Ryzen 5 7600X, 32 GB RAM, Windows 11 build 26200, rustc 1.94.0. Baseline: main 1d027e5 (one CI-only commit after your base c4d37be), built the same way.
  • cargo build --workspace then cargo test --workspace --no-fail-fast -- --test-threads=4: 963 passed, 0 failed, 43 ignored. main: 959 passed, 0 failed, 43 ignored. Same 22 SKIPPED lines on both (21 no wave64 / refused lower_dxil and lower tests, 1 no heap windows).
  • scripts/smoke.ps1, 60 s, same title:

main:

xcl-smoke v1
commit: 1d027e5c76c9a86a7ee2ca1cc677edf0be95d331
gpu: NVIDIA GeForce RTX 3080
title: 5d6132ca
seconds: 60
exit: 0x0
frames shown: 1590 (PresentX 1590)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15663 MB

PR:

xcl-smoke v1
commit: 4ed0c2d1f1e18915607b92e01da3f8bba367feae
gpu: NVIDIA GeForce RTX 3080
title: 5d6132ca
seconds: 60
exit: 0x0
frames shown: 1653 (PresentX 1653)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15816 MB
  • One 180 s world run each, XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_PSO_WAIT_MS=50, each build with its own empty driver-blob cache and the NVIDIA DXCache cleared first:
    • 56c0cd3b82a00c6e (ActivateProbes): direct DXIL 3,885 KB on main, 3,328 KB here (-14 %). 95cc13288a27a96e: 3,246 KB to 3,106 KB. Neither driver compile finished on either build: the title crashed 10-20 s after they started (the same 0xc0000005 null write inside the title on both, about 60 s after the world loads). So I have no NVIDIA compile time or compile RAM for those two.
    • The 20 compute programs of 260-614 KB that finished on both builds: DXIL 6,716 KB to 6,500 KB (-3.2 %), summed driver compile time 132.2 s to 119.8 s (-9.4 %). Two builds with the translator unchanged (D3D12.X: pack sub-64 KiB sampled textures into 4 KiB-aligned VRAM heaps #1835, D3D12.X: cache direct-DXIL mesh shaders, coalesce shader builds, make MS/GS lazy, and cache two-pass/graphics PSO blobs #1836) came out at -1.7 % and -0.9 % against the same main run, so most of the -9.4 % looks real, but it is one run per build.
    • Process commit at 120 s: 28.7 GB on main, 29.5 GB here. No compile-RAM spike on NVIDIA in either build. The world is still black on both, with about one present every 30 s.

Not tested

  • AMD; the ActivateProbes driver compile itself on NVIDIA (the title crashed before it finished); the DXIL validation sweep; repeat runs.

AI use

  • Claude Code with Claude Opus 5.5 ran the builds, tests and game runs and wrote this report.

@raylitebull

Copy link
Copy Markdown
Member Author

@thehollowedone Thank you for the sharp split-wave64 geometry retest on b1cae38 — that's a great catch on preserving the GS entry block boundary when crossing the EXECZ collapse threshold after S_SETPC_B64 handoff.

We'll preserve the GS entry boundary during block merging in cfg.rs and add that extended 70-branch branchy_program scenario to geometry_tests.rs as our next update to #1834.

@raylitebull

Copy link
Copy Markdown
Member Author

@thehollowedone Pushed c1acabc (fix/dxil-block-collapse, rebased onto 62265d3):

  • Preserves the GS entry block boundary (gs_block) during block merging in crates/xcl/src/gpu/dxil/cfg.rs.
  • Adds the 70-branch S_CBRANCH_EXECZ +1 after S_SETPC_B64 geometry scenario (geometry_execz_collapse_preserves_gs_entry_boundary + gpu_geometry_collapsed_execz_preserves_gs_entry) to crates/xcl/src/gpu/dxil/geometry_tests.rs.

If anyone on AMD or NVIDIA can verify gpu::dxil::geometry_tests and post a fresh 60 s scripts/smoke.ps1 pair on c1acabc vs 62265d3, that would be greatly appreciated.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@raylitebull
raylitebull force-pushed the fix/dxil-block-collapse branch from d899eb5 to 2a19e89 Compare November 25, 2026 01:53
@raylitebull

Copy link
Copy Markdown
Member Author

Rebased #1834 cleanly onto 3da2abb in commit 2a19e89, resolving the crates/xcl/src/gpu/dxil/core_tests.rs EOF append conflict cleanly alongside #1922.

Pushed 2a19e89 for GitHub Actions Build and test and fresh AMD / NVIDIA verification (gpu::dxil::cfg::tests, gpu::dxil::geometry_tests, gpu::dxil::core_tests, and scripts/smoke.ps1).

@gsucristo gsucristo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Window 0 readability assumption (crates/xcl/src/gpu/dxil/lower_mem.rs, with_mem_load_i32s): Inactive/OOB lanes clamp the heap window to MEM_HEAP_BASE + 0 (window 0, byte offset 0) and execute raw_load unconditionally. 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).
  2. Minor redundancy (crates/xcl/src/gpu/dxil/lower_mem.rs): In the multi-dword smem / buffer_load loops, let base_aligned = lw.safe_load_addr(base_aligned, cond); before the loop is redundant since at is already clamped with lw.safe_load_addr(at, cond) on every iteration.
  3. Verification: As noted in the PR description, this still needs fresh cargo test + scripts/smoke.ps1 regression runs on the rebased head 2a19e89 before merge.

(AI disclosure: review drafted with Antigravity — exact model name not provided to the agent — and checked by the reviewer before posting.)

@Royalflamejlh

Copy link
Copy Markdown
Contributor

My #2034 merged after 2a19e89 was pushed, and the two now conflict. With the conflict resolved collapse-first on main cbc296a, the compact form no longer triggers: the program your description measures (56c0cd3b82a00c6e) is 3,782,928 B of direct DXIL, where main has 484,508 B (4,329,420 B with neither). Planning the compact form before the collapse (14 added lines) keeps 484,508 B, but that program and its twin then skip your collapse; the other four of the six largest keep it.

Setup: Linux through Wine, no card, release. XCL_DIRECT_DXIL=1 xcl shaders <folder> --precompile --only cs --split 1, four memory windows in the switch form (no XCL_HEAP_WINDOWS), the six largest compute programs of a retail pack, 1 translation each. Most of the blocks below are those windows' switches; your collapse took that program's conditional branches from 10,025 to 208. To build, the merge needs one hunk in kernel.rs (both sides kept) and compact.rs taking CfgBlock::ops: 38 lines, with SaveExecZ and RestoreIfExecZ in a class's key and in emit as the block walk has them, and one line in compact_tests.rs.

tree 88,863-instruction program: DXIL, instructions, blocks 88,445 all six
main cbc296a 484,508 B, 65,577, 2,243 442,740 B 12,176,872 B
main, compact form off (XCL_DIRECT_COMPACT=0) 4,329,420 B, 605,779, 31,612 4,294,872 B 19,873,916 B
+ 2a19e89, collapse first 3,782,928 B, 536,261, 17,430 3,747,968 B 18,698,512 B
+ the compact form planned first 484,508 B, byte for byte main's 442,740 B 12,094,864 B

Read: collapse_execz_regions runs before compact::plan sees the blocks (on your earlier head d899eb5 it left that program as 195 blocks of 149 kinds), and the compact form is then not chosen. The lines that plan first:

// 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)? }
}

plan_with is compact::plan taking the two maps it reads from Lw as arguments. Here they are empty, so a program this check takes and the full plan then refuses would get neither form; none of the six did. On the other four programs the collapse still saves 1.1 % on three and 0.01 % on the fourth.

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.

@JJAutoCompare

Copy link
Copy Markdown

Tested

Independent Arc A770 run of open PR #1834 at 2a19e89ae60f1801b8f85577896f0bff5f45592e on STOR-WINLAB. The reused checkout was clean and detached at that SHA before and after testing.

Windows 11 Enterprise Evaluation x64 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust/Cargo 1.100.0 x86_64-pc-windows-msvc, DXC/DXIL 1.9.2609.5. Unoptimized tests with debug info and incremental compilation disabled. Used two Cargo jobs and prebuilt outside the Arc mutex (exit 0, 2m 43s).

cargo test --locked -p xcl --lib --no-run
$env:XCL_ADAPTER = 'A770'
$env:XCL_SPLIT_WAVE64 = '1'
$env:XCL_DXC_DIR = Join-Path $env:LOCALAPPDATA 'XclTooling/dxc-1.9.2609/bin/x64'
& 'L:/XclTooling/Invoke-ArcTest.ps1' -Test {
    & 'L:/XclTooling/pr1975-b62e6e3/target/debug/build/xcl/97fdf2b9ff8e1482/out/xcl-97fdf2b9ff8e1482.exe' --exact gpu::dxil::core_tests::collapsed_execz_kernel_matches_hlsl_on_gpu --nocapture --test-threads=1
}

1 passed, 0 failed, 0 ignored, 0 explicit skips, 1,093 filtered out, 0.36 s. The fixture and mutex wrapper each exited 0. The fixture asserted that 70 nested EXECZ regions collapsed to one CFG block. In split wave64, direct DXIL and HLSL/DXC matched all 396 checked 32-bit values across zero, partial, and full launch EXEC. The checks covered EXEC low/high, SCC, s10, v1 and v2. The final capture confirmed the Intel D3D12 driver loaded and HLSL compile workers started after the fixture's silent GPU guard. Two earlier runs passed with incomplete process evidence.

Not tested

Other fixtures, source mutations, separate memory and failure checks, native wave64 or standalone wave32, other adapters, retail titles and smoke runs, and the workspace suite.

AI use

T3 Code / Codex (gpt-6.2-sol) ran the checked-in fixture and wrote the test report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.