Skip to content

Recompiler: direct DXIL's signature dependency sets are bit masks - #1770

Open
josh-wirick wants to merge 1 commit into
xcl-dev:mainfrom
josh-wirick:dxil/viewid-deps-bitset
Open

josh-wirick wants to merge 1 commit into
xcl-dev:mainfrom
josh-wirick:dxil/viewid-deps-bitset

Conversation

@josh-wirick

Copy link
Copy Markdown

The direct DXIL translator (#1426) recomputes a vertex or pixel shader's input → output dependency tables (PSV0, dx.viewIdState) from the code it emitted. compute_deps kept the input components of every value as a BTreeSet<u32>, cloned and merged at each operand of each instruction, in hash maps keyed by value. On a retail pack that was 39 % of the time its vertex and pixel shaders took to translate. This PR keeps the algorithm and makes the sets bit masks. The DXIL is byte for byte the same. Part of #1269.

What is in it

  • crates/xcl/src/gpu/dxil/graphics.rs, compute_deps:
    • the sets are bit masks (Comps: a u128 for components 0..128, words after that);
    • the two memo tables are indexed by instruction and by block instead of hashed;
    • the base of a pointer chain is found once per instruction (it was walked again at every instruction with two operands or more);
    • the instruction → block map, which nothing read, is gone.
      The traversal order and what is memoised are unchanged.
  • crates/xcl/src/gpu/dxil/graphics_tests.rs: a test of the set type on both sides of component 128, and a test that an input placed past row 32 reaches the dependency table. The second one passes on main too: it pins the behaviour the pack does not cover.

Tested

  • AMD Radeon RX 9070 (driver 32.0.32029.2010), Ryzen 7 9700X, 32 GB RAM, Windows 11 build 26300, Rust 1.100.0, DXC 1.9.2602.17. Tests in debug, measurements and regression runs in release.

  • cargo build --workspace, then cargo test --workspace -- --test-threads=4 on 6f8cb8b: 860 passed, 0 failed, 42 ignored (SKIPPED GPU tests: heap_window_out_of_memory_falls_back_to_the_switch_form, no heap windows).

  • Same output: xcl shaders <pack> --direct --sample 0 --max-bytes 0 --dump <dir> on main c160d86 and on this commit, all 26 698 programs of a retail pack (26 229 translated, the same 469 refused in both). diff -rq of the two folders: all 52 168 files identical, 25 615 of them DXIL containers.

  • Time, same command without --dump, 8 threads, two runs each (main → this PR):

    main c160d86 this PR
    compute_deps, summed over the threads 156 s / 154 s 37.5 s / 38.0 s
    vertex + pixel shaders (14 337 programs), summed 399 s / 392 s 284 s / 288 s
    all stages, summed 801 s / 794 s 685 s / 692 s
    the whole sweep, wall clock 103.6 s / 102.7 s 89.1 s / 89.9 s

    The first three rows come from timers added to both builds for the measurement; they are not part of this PR.

Regression run

Both runs with XCL_PRESS_A_AT=10,14,18,22,26,30,34,38,42,46,50,54,58 set before scripts/smoke.ps1, so that the title takes the same path in both (in a first pair without it, a real key press reached the title at 12 s in one run and at 36 s in the other, and the runs were not comparable). The game folder is given through a junction named retail-title.

main:

xcl-smoke v1
commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0
gpu: AMD Radeon RX 9070
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1290 (PresentX 1290)
presents per 2 s (last 3): 35 41 46
device removals: 0
crashes: 0
peak commit: 26128 MB

PR:

xcl-smoke v1
commit: 6f8cb8b321fb27b9bd0082486c6750b77f657448
gpu: AMD Radeon RX 9070
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1251 (PresentX 1252)
presents per 2 s (last 3): 5 32 39
device removals: 0
crashes: 0
peak commit: 26555 MB

Not tested

  • A title run with XCL_DIRECT_DXIL=all. The regression runs above use the default HLSL path, which does not send the title's shaders through compute_deps; for the changed code the evidence is the whole-pack comparison and the tests.
  • Other GPUs (NVIDIA, Intel, wave32-only). The change runs on the CPU and the containers are identical, but nothing was run there.
  • Mesh-stage entries of finish_graphics on game data: the pack's NGG programs go through the compute entry. The mesh unit tests (ms_*_parts_match_dxc) pass.
  • Signatures with rows past 32 on game data: none in the pack, only the new unit test.

Noticed while measuring, not changed here: Shader::infer_type_features takes about 39 s of the 800 s summed above (insts_use_type builds a Vec per instruction), and #1544 already touches that code.

AI use

  • Claude Code with Claude Fable 5.2: profiled the direct translator on the pack, wrote the change and its tests, ran the tests, the measurements and the regression runs, and wrote this description.

🤖 Generated with Claude Code

The direct translator recomputes a vertex or pixel shader's input -> output
dependency tables (PSV0, dx.viewIdState) from the code it emitted.
compute_deps kept the set of input components of every value as a
BTreeSet<u32>, cloned and merged at each operand of each instruction, in
hash maps keyed by value. On a retail pack that was 39 % of the time its
vertex and pixel shaders took to translate.

- the sets are bit masks (a u128 for components 0..128, words after that);
- the two memo tables are indexed by instruction and by block;
- the base of a pointer chain is found once per instruction, not walked
  again at every instruction with two operands or more;
- the instruction -> block map, which nothing read, is gone.

The traversal and what it memoises are unchanged, so the tables are too.

Measured on a retail pack's 26 698 programs (xcl shaders --direct
--sample 0 --max-bytes 0, 8 threads, Ryzen 7 9700X), two runs each:
- compute_deps: 156 / 154 s -> 37.5 / 38.0 s summed over the threads;
- vertex and pixel shaders (14 337 programs): 399 / 392 s -> 284 / 288 s;
- the whole sweep: 103.6 / 102.7 s -> 89.1 / 89.9 s.
The per-phase times come from timers added for the measurement, not part
of this commit. With --dump, all 52 168 files of the two builds are
identical (25 615 DXIL containers).

Part of xcl-dev#1269.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@josh-wirick
josh-wirick marked this pull request as ready for review November 24, 2026 20:31
@SzczepanGrela

Copy link
Copy Markdown

Code review and Linux/RADV GPU test report on PR head 6f8cb8b (clean merge onto main 4178e88, zero compiler warnings).

Review

  • Checked Comps (0..128 in u128 + Vec<u64> overflow, insert/extend/iter boundary math at 127/128/191/192), root_of memoization against root(), and dense Vec<Option<Comps>> indexing in compute_deps. Traversal order and memoization semantics match main.

Tested

  • CachyOS Linux (kernel 7.3.0-5-cachyos), AMD Radeon RX 9070 (RDNA4, RADV GFX1201, Mesa 26.2.5-arch3.1), GE-Proton11-12 (Wine Staging 11.0, vkd3d-proton v3.1-1-g8293130eb), DXC 1.9.2602.17. Cross-built x86_64-pc-windows-gnu, release profile (--lib).
  • gpu::dxil::graphics::tests:: (--test-threads=1): 26 passed, 0 failed (0.12 s), including component_sets_insert_merge_and_list_in_order, dependencies_on_input_rows_past_32_reach_the_table, all VS/PS/MS DXC-match tests, and GPU draw tests (emitted_vs_ps_draw_a_triangle, emitted_ms_ps_draw_a_triangle, emitted_ms_primitive_attribute_reaches_the_pixel_shader, emitted_ps_samples_a_texture_with_implicit_lod).
  • gpu::dxil:: --skip ops_tests (--test-threads=1): 62 passed, 0 failed, 1 ignored (0.30 s).
  • gpu::recomp::tests::gpu_ with XCL_DIRECT_DXIL=all (--test-threads=4, skipping the 3 Wine vtable-swap tests gpu_sparse_vram/gpu_uma/gpu_unified_memory_arena and 3 pre-existing RADV failures gpu_f64_roots/gpu_f64_math_random/gpu_nonfused_mad_and_mac_prevent_fma_contraction): 81 passed, 0 failed, 1 ignored (0.61 s).
  • Same with XCL_DIRECT_DXIL=all XCL_SPLIT_WAVE64=1 (--test-threads=4): 81 passed, 0 failed, 1 ignored (0.63 s).

Not tested

  • Retail shader pack sweep and scripts/smoke.ps1 (no retail title files locally).
  • gpu::dxil::ops_tests::integer_ops_match_cpu and uaddc_and_usubb_match_cpu abort with exit code 3 under Wine/vkd3d-proton (unrelated compute op tests, does not exercise graphics.rs::compute_deps).

AI use

  • Diff review, test execution, and summary drafted with Antigravity (Gemini 4 Neon) and verified by me before posting.

@FIJI1299

Copy link
Copy Markdown

Test report on NVIDIA GeForce RTX 5070 (12 GB)

  • PR / Commit: Recompiler: direct DXIL's signature dependency sets are bit masks #1770 (6f8cb8b)
  • Hardware: AMD Ryzen 5 9600X, NVIDIA GeForce RTX 5070 (12 GB VRAM, driver 621.35), 32 GB DDR5 6000MT/s
  • Environment: Windows 11 (build 26300), rustc 1.100.0 (0ef1bc386 2026-11-09), Windows SDK 10.0.26100.0 (debug build)
  • Command: .\scripts\test.ps1 (cargo test --workspace -- --test-threads=4)
  • Results:
    • xcl --lib: 811 passed; 0 failed; 22 ignored (14.16s)
    • Integration tests: 8 passed; 0 failed; 12 ignored (1 + 1 + 6)
    • Total workspace: 819 passed; 0 failed; 34 ignored
  • GPU tests skipped on this adapter: 2 (no wave64), 1 (no heap windows)
  • Not tested: Retail title (smoke.ps1) with XCL_DIRECT_DXIL=all, shader pack sweep (xcl shaders --direct), release build, AMD GPUs.
  • AI use: Google Gemini assisted with running the commands and drafting this report from my real local test run.

@ivall ivall added the goal:world-load Bears on the retail title getting past world loading label Nov 24, 2026
@LocranKing

Copy link
Copy Markdown

Independent Windows 11 + 8 GB Ampere (RTX 3060 Ti, wave32) --release verification of exact head 6f8cb8b321fb27b9bd0082486c6750b77f657448 paired against its exact merge-base c160d86ef2efe3a07e4dfb473e4fa72eafb413c0: full suite green, --direct validation identical across --split 0 and --split 1, and clean 60 s retail smoke.

Tested

  • Hardware / toolchain: Windows 11 Build 26200, AMD Ryzen 5 5500, 31.8 GB RAM, NVIDIA GeForce RTX 3060 Ti (8024 MiB VRAM, Ampere, wave32 only), driver 32.0.16.2101 (621.01), rustc 1.100.0 (0ef1bc386 2026-11-09) (x86_64-pc-windows-msvc), DXC 1.9.2602.17 (21d28f72) / dxil.dll 1.9.2602.17, --release.
  • cargo build --release -p xcl: exit 0.
  • Full workspace suite (cargo test --workspace --release --no-fail-fast -- --test-threads=4 --nocapture): 860 passed, 0 failed, 42 ignored (+2 over exact merge-base c160d86's 858/0/42):
    • gpu::dxil::graphics::tests::component_sets_insert_merge_and_list_in_order — ok
    • gpu::dxil::graphics::tests::dependencies_on_input_rows_past_32_reach_the_table — ok
    • Expected host SKIPPED lines: 2 wave64 (gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware), 2 D3D12 debug layer (test_title_draws_with_a_root_signature_under_the_debug_layer, uploads_start_from_each_subresources_state), 1 heap windows (heap_window_out_of_memory_falls_back_to_the_switch_form).
  • Direct DXIL validation sweep (xcl shaders <retail-pack> --direct --sample 200 --seed 1269 --validate, 175 programs, 25 over 16384 B skipped):
    • --split 0: 171 / 175 (97.7%) validated (CS 9/9, MS 69/69, PS 71/71, VS 22/22, GS 0/4 unsupported ES+GS), 0 validator errors, 0 panics, 0 timeouts (p50 20.58 ms, p95 76.71 ms, max 125.53 ms, 1.8 s wall; vs 2.2 s wall on c160d86).
    • --split 1: 171 / 175 (97.7%) validated, 0 validator errors, 0 panics, 0 timeouts (p50 23.02 ms, p95 80.53 ms, max 151.58 ms, 1.0 s wall; vs 1.3 s wall on c160d86).

Regression run (scripts/smoke.ps1 -Seconds 60, --release)

Exact merge-base (c160d86):

xcl-smoke v1
commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1538 (PresentX 1538)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16245 MB

PR #1770 (6f8cb8b):

xcl-smoke v1
commit: 6f8cb8b321fb27b9bd0082486c6750b77f657448
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1570 (PresentX 1570)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15215 MB

Not tested: AMD/Intel GPUs, wave64 hardware, D3D12 debug layer, or extended world-loading past 60 s.

AI use: Antigravity (Gemini 4 Neon) built and ran the --release test suite, --direct sweeps, and paired 60 s smoke run locally and drafted this report from the captured outputs.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

@guinpereira

Copy link
Copy Markdown

Independent Windows/NVIDIA test report on exact PR head 6f8cb8b321fb27b9bd0082486c6750b77f657448.

Tested

  • RTX 5060 Ti (16052 MiB VRAM, driver 32.0.16.1714), Ryzen 7 5700X, 32 GB RAM, Windows 11 Pro build 26200, Rust 1.99.1 MSVC, DXC / dxil 1.8.2502.11 (SDK 10.0.26100.0).
  • XCL_ADAPTER="rtx 5060 ti" .\scripts\test.ps1 (cargo build --workspace, then cargo test --workspace -- --test-threads=4), debug: 860 passed, 0 failed, 42 ignored, exit 0.
  • GPU skips, included among passing functions and not counted as coverage: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no wave64); heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows). All XCL_SAMPLE_* inputs were unset; their optional data bodies did not run.
  • Release builds succeeded for PR head, exact parent c160d86ef2efe3a07e4dfb473e4fa72eafb413c0, and smoke baseline main 689f2db477c3c062cf162649781640ef8a977c18. Source checkouts were clean.
  • Exact-parent / PR shader comparison: xcl shaders <same local pack> --direct --sample 2000 --seed 1269 --validate --split 1 --threads 1. In each of six runs: 301 programs above 16384 bytes skipped; remaining 1699 programs: 1664 translated and validated, 35 unsupported, 0 validator errors, 0 panics, 0 timeouts. Unsupported: 33 ES+GS and 2 static-sampler image_get_lod.
  • First pair also used --dump: all 1697 unique result files (DXIL / refusal text, repeated inputs deduplicated by output name) matched SHA-256 byte for byte; no missing or extra files.

Timing limitation
Two subsequent pairs omitted dumps and alternated order. Parent: 53.961 / 57.969 s; PR: 56.254 / 35.438 s. Background desktop CPU activity and the wide variation prevent a reliable speedup claim. These are sampled CLI translation-plus-validation times, not cold driver PSO times or FPS.

Regression run
Same local title/data root, warmed cache, release, 60 s, XCL_ADAPTER="rtx 5060 ti", XCL_PRESS_A_AT=10,14,18,22,26,30,34,38,42,46,50,54,58; main then PR, with no task-owned build or other measurement running. Script output copied verbatim:

main:

xcl-smoke v1
commit: 689f2db477c3c062cf162649781640ef8a977c18
gpu: NVIDIA GeForce RTX 5060 Ti
title: GTA6.Xbox.v1.0.2.1-MyDump
seconds: 60
exit: 0x0
frames shown: 1613 (PresentX 1614)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14923 MB

PR:

xcl-smoke v1
commit: 6f8cb8b321fb27b9bd0082486c6750b77f657448
gpu: NVIDIA GeForce RTX 5060 Ti
title: GTA6.Xbox.v1.0.2.1-MyDump
seconds: 60
exit: 0x0
frames shown: 1622 (PresentX 1622)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14921 MB

Not tested

  • Full-pack identity/timing, cold driver PSO creation, AMD/Intel, native wave64, split=0, gameplay/world load, or full-title XCL_DIRECT_DXIL=all.
  • Default smoke uses the HLSL path and does not exercise compute_deps. Its main/PR builds also differ by upstream changes; only the exact-parent shader comparison isolates this PR. No FPS improvement claimed.

AI use

  • Codex (GPT-6; exact model variant unknown) ran the local builds, tests, sweeps and smoke checks, and drafted this test report from captured outputs. Published at the user's request. No project source changes.

IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 25, 2026
# Conflicts:
#	crates/xcl/src/gpu/dxil/graphics.rs
#	crates/xcl/src/gpu/dxil/graphics_tests.rs
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 6f8cb8b

No open or merged PR replaces the BTreeSets in compute_deps. #2642 removes BTree allocations in the direct DXIL CFG code, which is not this function.
The PR is built on the old compute_deps. Main has since rewritten it to iterate to a fixed point across loops (#1966, #2035: the Known/close passes), so Comps has to be ported to that version.
No problems found in the diff itself.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

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

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants