Skip to content

Recompiler: direct DXIL's view-id tables follow a load's stores - #2269

Closed
b3IKK wants to merge 1 commit into
xcl-dev:mainfrom
b3IKK:dxil/view-id-store-deps
Closed

b3IKK wants to merge 1 commit into
xcl-dev:mainfrom
b3IKK:dxil/view-id-store-deps

Conversation

@b3IKK

@b3IKK b3IKK commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Fixes #1892 — its first point was #1966 (merged), this is the second.

compute_deps builds the input-to-output tables of dx.viewIdState and PSV0 for the direct DXIL translator's vertex, pixel and mesh programs. A load of a global or groupshared root got the dependencies of the values its stores wrote, but not of how those stores were reached:

  • the branch that guarded a store. if (C != 0) g[i] = X; then out = g[0]; — C decides whether the load sees X or what was there before, yet the tables did not list C.
  • the index a store was made through. g[I & 1] = X; out = g[0]; — I decides which slot the load reads, and the tables did not list it.

A driver reads these tables to decide which inputs a stage uses, so an input that only steers a store could be treated as unused. Atomics were recorded the same way (their written values, without the pointer they operate on).

A store into a root now carries its value, its pointer and its block; a load of that root takes the dependencies of all three — value_deps of the value and the pointer, and block_deps of the block, which is what brings in the branch conditions.

What is in it

  • crates/xcl/src/gpu/dxil/graphics.rs: root_stores holds Stored { v, p, block } (atomics included, with the resource as the pointer); the Load arm takes all three sets.
  • crates/xcl/src/gpu/dxil/kernel.rs: TRANSLATOR_VERSION 9 → 10, since the tables of programs with stores change (other open direct-DXIL PRs bump the same line).
  • crates/xcl/src/gpu/dxil/graphics_tests.rs: a_load_depends_on_the_branch_and_the_index_of_the_stores_into_it builds the two cases above and asks compute_deps directly. Without the change it fails with the output depends on C (the branch that guards the stores); its inputs: {4, 8} — I and X, not C.

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): 1244 passed, 0 failed, 46 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: 26 passed, 0 failed, including the loop case of Recompiler: direct DXIL's signature dependencies are complete across loops #1966 and every ..._parts_match_dxc comparison, so the extra dependencies do not change any table DXC produces for those programs
  • the new test without the change: 0 passed, 1 failed (message above)

Regression run

main (426a5a7, clean tree, no local changes):

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

PR (a98c6bd, clean tree, no local changes):

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

Not tested

  • a translated console shader whose tables differ with this change: the test builds the stores and the load by hand, and the DXC comparisons above are programs that do not exercise it
  • what a driver does with a table that used to be short. I only show that it was short.
  • the compile time of compute_deps on large programs, which now walks every store of a root for every load of it
  • AMD GPUs and native wave64 hardware
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

`compute_deps` (the input-to-output tables of `dx.viewIdState` and PSV0) gave
a load the values its stores wrote, but not how the stores were reached
(xcl-dev#1892, its second point): the branch condition guarding a store, and the
index a store was made through, are inputs the loaded value depends on. A
shader that writes a slot an input selected, or under a branch an input
decided, then reads it, had those inputs missing from the tables - which is
what a driver reads to decide which inputs a stage uses.

A store into a root is now recorded with its value, its pointer and its
block, and a load of that root takes the dependencies of all three (atomics
included, whose pointer is the resource they operate on).

The direct translator's version goes to 10, since the tables of programs with
global or groupshared stores change.

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

itsSio commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Tested

Independent verification on clean a98c6bd2ae5676480d49ae10b8c76bf9c6cdbb5c, Windows 11 Pro build 26200, x64 MSVC, unoptimized dev/test profiles with debug info off. cargo build --workspace --locked passed on both PCs.

cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --nocapture:

GPU / driver CPU, RAM, toolchain Passed / failed / ignored Runtime SKIPPED Exit
RTX 5080 / 32.0.16.1088 Ryzen 7 9800X3D, 32 GiB; Rust 1.97.0, DXC/DXIL 1.9.2609.5 1244 / 0 / 46 25 0
RTX 2080 SUPER / 32.0.16.1088 Ryzen 5 5600X, 16 GiB; Rust 1.99.1, DXC/DXIL 1.8.2502.11 1243 / 1 / 46 27 101

cargo test -p xcl --lib --locked gpu::dxil::graphics -- --test-threads=1 --nocapture: 26 passed / 0 failed / 0 ignored, zero runtime skips, on both RTX cards and the Radeon RDNA2 iGPU (32.0.21043.5001, same Ryzen 7 system and toolchain). This includes the new synthetic check that the branch condition, index and stored value are all recorded as dependencies. That specific test checks computed dependency data, not GPU output.

The RTX 2080 SUPER workspace run failed only at hle::xgameruntime::gamesave::tests::atomic_writes_preserve_xcltmp_blobs_and_skip_leftover_temps (E_FAIL, expected S_OK). The same named test failed in an earlier verification. On this head, cargo test -p xcl --lib --locked hle::xgameruntime::gamesave::tests::atomic_writes_preserve_xcltmp_blobs_and_skip_leftover_temps -- --exact --test-threads=1 --nocapture passed in isolation on both PCs (1 / 0 / 0, no skips). The original workspace result remains failing; this does not establish the cause.

Not tested

The exact parent, a translated console shader whose dependency tables change, a full Radeon workspace, Intel, retail smoke and performance.

AI use

Ran via Samaritan:

  • OpenCode with OpenAI GPT-6.2 Sol (openai/gpt-6.2-sol): scoped and ran the two-PC checks, verified the logs, and wrote this report. No subagents contributed.

@b3IKK

b3IKK commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Thank you — that is the first independent run on this, and the Radeon RDNA2 iGPU result on the graphics tests is more than I could check here.

On the RTX 2080 SUPER failure: hle::xgameruntime::gamesave::tests::atomic_writes_preserve_xcltmp_blobs_and_skip_leftover_temps is unrelated to this change (it lives in gamesave, and this PR touches gpu/dxil/graphics.rs and kernel.rs only). It looks like the same class as #1487: a test that passes alone and fails under parallel scheduling, and you saw the same name on another head. I will look at whether the test needs the same kind of lock the xasync tests take rather than leave it as a known flake.

The 26/26 on all three GPUs, including the new branch/index/value check, is exactly the evidence this needed. AI use: OpenCode, Claude Fable 5.2.

@thehollowedone

Copy link
Copy Markdown

Independent direct-DXIL comparison of #2269 at a98c6bd and #2035 at 5473448. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, Rust 1.99.1 MSVC, DXC 1.8.2502.11.

Commands: cargo test --offline --locked -p xcl --lib -j 4 gpu::dxil::graphics::tests -- --skip local_d79_read_address_does_not_taint_unrelated_output --test-threads=1 --nocapture and the same test command filtered to local_d79_read_address_does_not_taint_unrelated_output without the skip. Synthetic inputs only.

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

@b3IKK

b3IKK commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favour of #2035, which is the same fix (#1892's second point) opened earlier and does it correctly.

The independent comparison by @thehollowedone is right that this head over-counts: my root_stores treated any InstInfo::Other whose first operand roots at a global as a write, so a GEP - an address computation, not a write - was recorded as a store of its index operands, and a later load of the root picked up dependencies from it. That is the extra {0, 4} against #2035's {4} in their fixture. The fix is to tell atomic writes apart from other value operations in module.rs, which #2035 does; I had worked around the same problem with the first-operand heuristic instead.

No test here fails for it (my own test only asks that the branch and index are present), which is why the precision case had to come from outside. #2035 also has three focused regressions for store address, store condition and atomic address/control, so nothing here is lost.

AI use: OpenCode, Claude Fable 5.2 read the comparison, traced the over-count to the heuristic and wrote this.

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.

Direct DXIL: compute_deps() poisons memo tables on cyclic phis/loops and omits store pointer/control dependencies in dx.viewIdState / PSV0

3 participants