Skip to content

Recompiler: direct DXIL's signature dependencies are complete across loops - #1966

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
b3IKK:dxil/view-id-deps-loop-fixpoint
Nov 25, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
b3IKK:dxil/view-id-deps-loop-fixpoint

Conversation

@b3IKK

@b3IKK b3IKK commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Part of #1892 (its first point; the second is not in this PR, see Not tested).

compute_deps in gpu/dxil/graphics.rs works out which input components each output component depends on, for dx.viewIdState and the PSV0 tables of the direct DXIL translator's vertex, pixel and mesh programs. A loop makes a value depend on itself, and the function broke that recursion by answering an empty set for a value whose own set was still being worked out, then kept whatever it derived from that answer.

With acc = phi [X, entry], [next, loop] and next = acc + 1: asking for acc first reaches next while acc is open, next is remembered as depending on nothing, and an output written from next loses input X. Which outputs are affected depends only on the order the stores are met in.

The sets now record which pass worked them out and whether that is still going on. A pass that had to answer for an open value or block is followed by another, each value starting from what the last pass knew of it, until no set grows. Code without a loop cuts nothing and is done after one pass, as before.

What is in it

  • crates/xcl/src/gpu/dxil/graphics.rs: compute_deps keeps Known { set, pass, open } per value and per block, and repeats its walk over the output stores while a pass both cut a cycle and grew a set.
  • crates/xcl/src/gpu/dxil/kernel.rs: TRANSLATOR_VERSION 7 → 8, since the tables of programs with loops change. Other open direct-DXIL PRs bump the same line (my Recompiler: v_pack_b32_f16 applies the abs and neg half modifiers #1720 among them), so whichever merges second needs the next number.
  • crates/xcl/src/gpu/dxil/graphics_tests.rs: a_loop_value_first_reached_through_its_phi_keeps_the_phis_inputs builds the loop above with outputs A = acc and B = next and asks compute_deps directly. On main it fails with output B depends on input X through the loop; its inputs: {}.

#1770 rewrites the same function's sets as bit masks and keeps the single pass, so the two conflict; this change is small enough to redo on top of it if that one goes first.

Tested

  • hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1)
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 991 passed, 0 failed, 45 ignored (SKIPPED: the wave64 / direct-DXIL per-lane tests that need 64-lane hardware or a semantics mode this adapter refuses, no heap windows, and cannot disable the driver cache (Windows Developer Mode is required))
  • cargo test -p xcl --lib -- gpu::dxil::graphics: 25 passed, 0 failed, also with XCL_DIRECT_DXIL=all. That includes vs_control_dependence_matches_dxc, whose loop and branches still give the same PSV0 bytes as DXC, so the extra passes add nothing DXC does not have there.
  • the new test on main 20cf130 before the change: 0 passed, 1 failed (the message above)

Regression run

main (8e87fc7, clean tree, no local changes):

xcl-smoke v1
commit: 8e87fc7b62a87ea589ccb9ea6182f514016cf7db
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1561 (PresentX 1561)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19330 MB

PR (25298fb, clean tree, no local changes):

xcl-smoke v1
commit: 25298fb70155f9b7c724560b7af4455bc9a4a450
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1647 (PresentX 1647)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17773 MB

(These two runs use the default settings, where vertex and pixel programs go through HLSL and DXC, so they do not run the changed code. One more run of the PR's build with XCL_DIRECT_DXIL=all set: 1629 frames, 60 60 60, 0 crashes, 0 device removals, and no "rejected" line in the log. I did not count how many of the programs it translated have loops.)

Not tested

  • Direct DXIL: compute_deps() poisons memo tables on cyclic phis/loops and omits store pointer/control dependencies in dx.viewIdState / PSV0 #1892's second point (a load does not get the pointer or the control dependence of the stores it reads): not changed here, and I have not checked whether it is real.
  • A translated console shader whose tables differ with this change. The test builds the loop by hand; I did not look for a retail vertex or pixel program that hits the order it needs.
  • What a driver does with an incomplete table. I only show that the table was incomplete.
  • Compile time of compute_deps on large programs with loops, which now takes at least two passes.
  • AMD GPUs and native wave64 hardware
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

…loops

compute_deps (the input-to-output tables of dx.viewIdState and PSV0)
breaks the recursion a loop makes by answering an empty set for a value
whose own set is still being worked out, and then keeps what it derived
from that answer. With acc = phi [X, entry], [next, loop] and
next = acc + 1, asking for acc first reaches next while acc is open:
next is remembered as depending on nothing, and an output written from
next loses input X (xcl-dev#1892, its first point).

The sets now say which pass worked them out and whether that is still
going on. A pass that had to answer for an open value or block (a cut)
is followed by another, each value starting from what the last pass
knew of it, until no set grows. Code without a loop cuts nothing and is
done after one pass, as before.

The direct translator's version goes to 8, since the tables of programs
with loops change.

Assisted-by: OpenCode (Claude Fable 5.2)
@futurepro62

futurepro62 commented Nov 25, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head 25298fb (on its base 8e87fc7).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, DXC + dxil.dll 1.9.2602.17 (Windows SDK 10.0.26100), debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 980 passed, 0 failed, 43 ignored. SKIPPED (no wave64): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, a_per_lane_2d_or_3d_group_runs_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.
  • The new tests ran and passed: a_loop_value_first_reached_through_its_phi_keeps_the_phis_inputs.
  • Same head on the AMD Radeon integrated GPU (iGPU) of the Ryzen 7 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 990 passed, 0 failed, 45 ignored. SKIPPED: f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f16_programs_on_the_gpu (f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), f32_programs_on_the_gpu (f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's))), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • --skip leaves out tests that fail on main 80f4819 too, not because of this PR. On NVIDIA: heap_window_out_of_memory_falls_back_to_the_switch_form (Tests: heap_window_out_of_memory_falls_back_to_the_switch_form fails under XCL_REQUIRE_GPU=mesh (opt-in skip counted as missing coverage) #1651), the four gpu::recomp::lower_dxil::tests::*_programs_on_the_gpu tests and const_and_null_mask_operands_agree_with_hlsl_on_the_gpu (follow-up on #1651) fail because runner::skip_test turns their skips into failures under XCL_REQUIRE_GPU=mesh, and gpu::dxil::fuzz_tests seeds 70, 545, 1019 and 1507 fail CreateComputePipelineState with E_OUTOFMEMORY on this card (drivers 616.64 and 621.40). On AMD: fuzz_validate_and_gpu_1 fails on seed 540 (res[833] 0x7 vs CPU 0x6). The AMD run does not set XCL_REQUIRE_GPU.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@GustavoEllwanger

Copy link
Copy Markdown
Contributor

Tested exact head 25298fb70155f9b7c724560b7af4455bc9a4a450 on AMD RDNA3 (RX 7600).

Tested

  • cargo build --workspace: passed.
  • XCL_HEAP_WINDOWS=1 cargo test -p xcl --test gpu_compute_e2e heap_window_out_of_memory_falls_back_to_the_switch_form -- --nocapture: 1 passed, 0 failed (RX 7600).
  • cargo test --workspace --no-fail-fast -- --test-threads=4 --skip fuzz_validate_and_gpu_1: 990 passed, 0 failed, 45 ignored, 1 filtered out, 0 wave64/mesh capability skips.
    • gpu::dxil::graphics::tests::a_loop_value_first_reached_through_its_phi_keeps_the_phis_inputs: passed.
    • 8 SKIPPED lines reported in the default run (not counted as coverage): 6 per-lane #1426 refusals (f16_programs_on_the_gpu / f32_programs_on_the_gpu), 1 pso_measurement_compiles_an_exact_synthetic_record (Windows Developer Mode not enabled, 0x887A002D), 1 heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows, separately verified above with XCL_HEAP_WINDOWS=1).
  • fuzz_validate_and_gpu_1 was skipped on RX 7600 due to the pre-existing amdxc64 seed 722 failure documented in 210f773. With XCL_ADAPTER=warp, fuzz_validate_and_gpu_1 validated all 500/500 modules (500..1000, GPU-compared 0).
  • XCL_SAMPLE_* variables were unset.
  • Machine: Windows 11 Home build 26200; AMD Ryzen 5 5600T; AMD Radeon RX 7600 (8133 MiB VRAM, RDNA3, Adrenalin 26.11.2 / driver 32.0.32029.2010); Rust 1.100.0 MSVC x64; DXC/DXIL 1.8.2502.11 (Windows SDK 10.0.26100.0); debug profile.

Not tested

  • Retail-title smoke or world-load run, release builds, or XCL_SAMPLE_* game-data tests.

AI use
Antigravity (Gemini 4 Neon) ran the commands and drafted this report; only the measured results above are posted.

anoyarou pushed a commit to anoyarou/xcl that referenced this pull request Nov 25, 2026
…loops (xcl-dev#1966)

compute_deps (the input-to-output tables of dx.viewIdState and PSV0)
breaks the recursion a loop makes by answering an empty set for a value
whose own set is still being worked out, and then keeps what it derived
from that answer. With acc = phi [X, entry], [next, loop] and
next = acc + 1, asking for acc first reaches next while acc is open:
next is remembered as depending on nothing, and an output written from
next loses input X (xcl-dev#1892, its first point).

The sets now say which pass worked them out and whether that is still
going on. A pass that had to answer for an open value or block (a cut)
is followed by another, each value starting from what the last pass
knew of it, until no set grows. Code without a loop cuts nothing and is
done after one pass, as before.

The direct translator's version goes to 8, since the tables of programs
with loops change.

Assisted-by: OpenCode (Claude Fable 5.2)
@raylitebull

Copy link
Copy Markdown
Member

Both AMD and NVIDIA passes look solid on 25298fb.

Remaining before merge: please rebase onto main (resolving the kernel.rs TRANSLATOR_VERSION bump after #1950 and #1947, which now auto-hashes gpu/dxil sources via XCL_DIRECT_DXIL_SOURCE_ID) so Build and test (Windows, no GPU) can run cleanly.

@raylitebull
raylitebull merged commit 3da2abb into xcl-dev:main Nov 25, 2026
2 checks passed
luckyteagirl added a commit to luckyteagirl/xcl that referenced this pull request Nov 25, 2026
Track each memory write's pointer, value, and control block when computing
input-to-output dependencies for dx.viewIdState and PSV0. Preserve the
fixed-point traversal merged in xcl-dev#1966. The direct-DXIL source hash from
xcl-dev#1947 accounts for the changed output without a manual version bump.

Refs xcl-dev#1892
@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

luckyteagirl added a commit to luckyteagirl/xcl that referenced this pull request Nov 25, 2026
Track each memory write's pointer, value, and control block when computing
input-to-output dependencies for dx.viewIdState and PSV0. Preserve the
fixed-point traversal merged in xcl-dev#1966. The direct-DXIL source hash from
xcl-dev#1947 accounts for the changed output without a manual version bump.

Refs xcl-dev#1892
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.

5 participants