Recompiler: direct DXIL PS IR cuts (shared float decode, direct quad shuffles, predicate-derived lane masks) #3501

Merged
Kalmarv merged 4 commits from upstream-pr/3501 into main 2026-11-30 04:25:49 +00:00
Kalmarv commented 2026-11-30 03:25:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-30T03:25:47Z.


Three direct-DXIL pixel-shader IR cuts that reduce DXIL size and cold driver compile times on heavy pixel shaders.

What is in it

  • Share normalized and packed float buffer decode paths (crates/xcl/src/gpu/dxil/, net -54 LOC).\n- Lower pixel quad shuffles and masks directly (crates/xcl/src/gpu/dxil/lanes.rs).\n- Take a lane's own mask bit directly from the predicate that made it (crates/xcl/src/gpu/dxil/lanes.rs, module.rs).

Tested

  • Hardware: NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074), AMD Ryzen 9 9950X, Windows 11, DXC 1.9.2609
  • cargo check -p xcl --tests: passed on this exact head against origin/main (91244db94)
  • Heavy pixel shaders cold compile time reduced -17% to -30% on RTX 5070 Ti.
  • Full workspace GPU suite + scripts/smoke.ps1 running now and will be pasted below.

Regression run

main:

xcl-smoke v1
commit: 91244db94d2f402237c6a8e428dbe5da07673c48
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1514 (PresentX 1514)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 15133 MB

PR head:

xcl-smoke v1
commit: 02202839e68b26056f3e8bc114e6ab1a5c50f0f8
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1584 (PresentX 1584)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15317 MB

Not tested

  • AMD / Intel GPUs

AI use

  • Developed and verified with Claude Opus / Gemini coding assistants; all commits reviewed, built, and tested locally on RTX 5070 Ti.
<!-- greyfinch-sync:ivall/xcl:issue:5558418989 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3501). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-30T03:25:47Z. --- Three direct-DXIL pixel-shader IR cuts that reduce DXIL size and cold driver compile times on heavy pixel shaders. **What is in it** - Share normalized and packed float buffer decode paths (crates/xcl/src/gpu/dxil/, net -54 LOC).\n- Lower pixel quad shuffles and masks directly (crates/xcl/src/gpu/dxil/lanes.rs).\n- Take a lane's own mask bit directly from the predicate that made it (crates/xcl/src/gpu/dxil/lanes.rs, module.rs). **Tested** - Hardware: NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074), AMD Ryzen 9 9950X, Windows 11, DXC 1.9.2609 - `cargo check -p xcl --tests`: passed on this exact head against `origin/main` (`91244db94`) - Heavy pixel shaders cold compile time reduced -17% to -30% on RTX 5070 Ti. - Full workspace GPU suite + `scripts/smoke.ps1` running now and will be pasted below. **Regression run** `main`: ``` xcl-smoke v1 commit: 91244db94d2f402237c6a8e428dbe5da07673c48 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1514 (PresentX 1514) presents per 2 s (last 3): 60 60 61 device removals: 0 crashes: 0 peak commit: 15133 MB ``` PR head: ``` xcl-smoke v1 commit: 02202839e68b26056f3e8bc114e6ab1a5c50f0f8 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1584 (PresentX 1584) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15317 MB ``` **Not tested** - AMD / Intel GPUs **AI use** - Developed and verified with Claude Opus / Gemini coding assistants; all commits reviewed, built, and tested locally on RTX 5070 Ti.
CharlyRien commented 2026-12-01 12:32:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by CharlyRien on 2026-12-01T12:32:56Z.


Same report as on #2571 (https://github.com/xcl-dev/xcl/pull/2571#issuecomment-7311064649), posted here because it points at this PR's ballot_ps_quad lowering: on an RTX 3090, with #2571's forms switched off, this lowering hangs the GPU in one draw, and #2571 hides the hang at a large frame-rate cost (the drop minimalhipster990 bisected to #2571 on the 4090).

Stack: main 493dbd3d (has #3535) + #3528 (ba8592a4) + #3517 (0b4283d1) + 42 local commits of ours (memory-window, alias-copy and diagnostic switches; none touches recomp/ps_masks.rs, dxil/kernel.rs, lower.rs, lower_valu.rs or lanes.rs). Run settings as in our earlier reports (16 heap windows, XCL_SPARSE_WINDOWS=4, XCL_GPU_WAIT_TIMEOUT_MS=45000). Fresh shader preparation for each build, warm driver cache. Presents/s from world +20 s to +180 s, one setting per run.

Build (same stack) Runs Result
as is (#2571 forms on, #3501 lowering) 1 0.23 presents/s, never left the intro card in 358 s; no removal
#2571 forms off (local switch: lw.ps_masks left empty in dxil/kernel.rs) 2 device hung at 110-121 s, before the playable scene, same mesh + pixel shader draw both times
#2571 forms off + ballot_ps_quad as before #3501 (4 WaveActiveBallot, local switch in dxil/lanes.rs) 2 no hang, playable scene, 0.66 and 1.41 presents/s
same local stack on main 53e85fb1 (before #3499, #3501 and #2571) 2 0.71 and 0.88 presents/s

What we read (not measured):

  • With the map empty, the DXIL is exactly what the parent of #2571 (02202839) produces: the code #2571 added elsewhere (lower_valu.rs, lanes.rs, compact.rs) is skipped when ps_masks is empty. That parent already has #3501 (a50fa7ab), which turned ballot_ps_quad into WaveActiveBit(Or) + QuadReadLaneAt.
  • In the hung pixel shader, the forms-off DXIL goes from 40 to 120 QuadReadLaneAt and from 6 to 44 WaveActiveBit(Or), inside a loop capped at 65536 iterations; the loop exit takes one of those masks. The bodies are otherwise the same (same CFG, resource handles, discard).
  • The removals are hangs, not page faults: DRED device state 3 ("hung"). real.rs prints "DRED page fault at GPU VA 0x0" whenever the page-fault output is readable, even for a hang, so that line is misleading.

What we deduce: on NVIDIA (wave64 split into two wave32 halves) the #3501 ballot_ps_quad lowering can hang this draw. #2571 replaces most of those compares with its forms, so the hang disappears, but the frame rate drops (0.23 here, against 0.66-1.41 with the #3501 lowering reverted instead). That would also match the 82-87 s DRED-3 hangs reported on the 4090 before #2571. We have not found which instruction hangs, nor checked AMD.

The image in the two no-hang runs is not clean either (bald character and half-dark window, as on our earlier trees, see #505 / #3517), so this is a pace and hang result, not a rendering one.

Hardware: RTX 3090 24 GB (driver 616.56, Resizable BAR off), Ryzen 9 5950X, 32 GB, Windows 11 22631. Not tested: AMD, main without our local commits.

AI use: Claude Code (Claude Opus 5.5) ran the builds, preparations and runs, read the logs and wrote this; Antigravity CLI (Gemini 4 Neon) compared the two DXIL dumps (read-only); checked and posted by me.

<!-- greyfinch-sync:ivall/xcl:comment:7311293228 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3501#issuecomment-7311293228). Originally posted by [CharlyRien](https://github.com/CharlyRien) on 2026-12-01T12:32:56Z. --- Same report as on #2571 (https://github.com/xcl-dev/xcl/pull/2571#issuecomment-7311064649), posted here because it points at this PR's `ballot_ps_quad` lowering: on an RTX 3090, with #2571's forms switched off, this lowering hangs the GPU in one draw, and #2571 hides the hang at a large frame-rate cost (the drop minimalhipster990 bisected to #2571 on the 4090). Stack: main 493dbd3d (has #3535) + #3528 (ba8592a4) + #3517 (0b4283d1) + 42 local commits of ours (memory-window, alias-copy and diagnostic switches; none touches `recomp/ps_masks.rs`, `dxil/kernel.rs`, `lower.rs`, `lower_valu.rs` or `lanes.rs`). Run settings as in our earlier reports (16 heap windows, `XCL_SPARSE_WINDOWS=4`, `XCL_GPU_WAIT_TIMEOUT_MS=45000`). Fresh shader preparation for each build, warm driver cache. Presents/s from world +20 s to +180 s, one setting per run. | Build (same stack) | Runs | Result | |---|---|---| | as is (#2571 forms on, #3501 lowering) | 1 | 0.23 presents/s, never left the intro card in 358 s; no removal | | #2571 forms off (local switch: `lw.ps_masks` left empty in `dxil/kernel.rs`) | 2 | device hung at 110-121 s, before the playable scene, same mesh + pixel shader draw both times | | #2571 forms off + `ballot_ps_quad` as before #3501 (4 `WaveActiveBallot`, local switch in `dxil/lanes.rs`) | 2 | no hang, playable scene, 0.66 and 1.41 presents/s | | same local stack on main 53e85fb1 (before #3499, #3501 and #2571) | 2 | 0.71 and 0.88 presents/s | What we read (not measured): - With the map empty, the DXIL is exactly what the parent of #2571 (02202839) produces: the code #2571 added elsewhere (`lower_valu.rs`, `lanes.rs`, `compact.rs`) is skipped when `ps_masks` is empty. That parent already has #3501 (a50fa7ab), which turned `ballot_ps_quad` into `WaveActiveBit(Or)` + `QuadReadLaneAt`. - In the hung pixel shader, the forms-off DXIL goes from 40 to 120 `QuadReadLaneAt` and from 6 to 44 `WaveActiveBit(Or)`, inside a loop capped at 65536 iterations; the loop exit takes one of those masks. The bodies are otherwise the same (same CFG, resource handles, discard). - The removals are hangs, not page faults: DRED device state 3 ("hung"). `real.rs` prints "DRED page fault at GPU VA 0x0" whenever the page-fault output is readable, even for a hang, so that line is misleading. What we deduce: on NVIDIA (wave64 split into two wave32 halves) the #3501 `ballot_ps_quad` lowering can hang this draw. #2571 replaces most of those compares with its forms, so the hang disappears, but the frame rate drops (0.23 here, against 0.66-1.41 with the #3501 lowering reverted instead). That would also match the 82-87 s DRED-3 hangs reported on the 4090 before #2571. We have not found which instruction hangs, nor checked AMD. The image in the two no-hang runs is not clean either (bald character and half-dark window, as on our earlier trees, see #505 / #3517), so this is a pace and hang result, not a rendering one. Hardware: RTX 3090 24 GB (driver 616.56, Resizable BAR off), Ryzen 9 5950X, 32 GB, Windows 11 22631. Not tested: AMD, main without our local commits. AI use: Claude Code (Claude Opus 5.5) ran the builds, preparations and runs, read the logs and wrote this; Antigravity CLI (Gemini 4 Neon) compared the two DXIL dumps (read-only); checked and posted by me.
minimalhipster990 commented 2026-12-01 17:27:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by minimalhipster990 on 2026-12-01T17:27:44Z.


On an RTX 4090 (driver 621.40, Windows), the in-world slowdown for one pixel shader first appears at a50fa7a. Restoring only the pre-PR body of ballot_ps_quad on top of the complete PR brought this draw back below 0.12 ms in all 12 active pairs tested. This directly tests the function identified in the RTX 3090 report for GPU time on the 4090. The preceding commit, e18e7b2, produces byte-for-byte identical DXIL to the pre-PR baseline for this shader.

A vs B on the same draw Active pairs A median B median Median paired B/A
e18e7b2 vs a50fa7a 13 0.0993 ms 16.0256 ms 169.3×
Complete PR with old ballot_ps_quad vs unchanged complete PR 12 0.0814 ms 17.9420 ms 220.8×

The host was fixed at a07ad1b1 with #3318. Guest dump hashes were bf5a7665d0c6631a (mesh) and af68da74e05dbb3c (pixel, guest wave64 on wave32 hardware). Each pair reused the same real indirect command, geometry, descriptors and depth/stencil tests, with depth/stencil writes disabled in both passes. Each pass started from a private copy of the same six color targets at 2560×1440. GPU timestamps cover the mesh/raster command. The table selects two compute groups and eight mesh groups with PS invocations. B was slower in every pair, in both execution orders. Mesh primitives, clipped primitives and PS invocations matched within every pair in the table.

Color changes too. In the adjacent-commit test, the two active readbacks differed at 360 and 450 texels on target 1 only. In the function-only test, the two active readbacks had 103 and 104 PS invocations respectively. Restoring the old function changed 60/63/40 texels on targets 0/1/2 in the first draw and 56/60/35 in the second. Targets 3–5 matched. A console reference would be needed to decide which output is correct.

The function-only control kept the PR's quad shuffle and predicate changes intact. Both replay processes exited cleanly. The measurements cover this shader's draw time in one save. Whole-game frame rate and the cause of the pre-world hang remain open.

AI use: OpenAI Codex (GPT-6) reconstructed the intermediate trees, ran the builds and GPU replays, checked the logs and readbacks, and drafted this comment.

<!-- greyfinch-sync:ivall/xcl:comment:7319336125 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3501#issuecomment-7319336125). Originally posted by [minimalhipster990](https://github.com/minimalhipster990) on 2026-12-01T17:27:44Z. --- On an RTX 4090 (driver 621.40, Windows), the in-world slowdown for one pixel shader first appears at [`a50fa7a`](https://github.com/xcl-dev/xcl/commit/a50fa7abb07b88a3203560fa642f1e9f0e7e14fa). **Restoring only the pre-PR body of `ballot_ps_quad` on top of the complete PR brought this draw back below 0.12 ms in all 12 active pairs tested.** This directly tests the function identified in [the RTX 3090 report](https://github.com/xcl-dev/xcl/pull/3501#issuecomment-7311293228) for GPU time on the 4090. The preceding commit, `e18e7b2`, produces byte-for-byte identical DXIL to the pre-PR baseline for this shader. | A vs B on the same draw | Active pairs | A median | B median | Median paired B/A | |---|---:|---:|---:|---:| | `e18e7b2` vs `a50fa7a` | 13 | 0.0993 ms | 16.0256 ms | 169.3× | | Complete PR with old `ballot_ps_quad` vs unchanged complete PR | 12 | 0.0814 ms | 17.9420 ms | 220.8× | The host was fixed at `a07ad1b1` with #3318. Guest dump hashes were `bf5a7665d0c6631a` (mesh) and `af68da74e05dbb3c` (pixel, guest wave64 on wave32 hardware). Each pair reused the same real indirect command, geometry, descriptors and depth/stencil tests, with depth/stencil writes disabled in both passes. Each pass started from a private copy of the same six color targets at 2560×1440. GPU timestamps cover the mesh/raster command. The table selects two compute groups and eight mesh groups with PS invocations. B was slower in every pair, in both execution orders. Mesh primitives, clipped primitives and PS invocations matched within every pair in the table. **Color changes too.** In the adjacent-commit test, the two active readbacks differed at 360 and 450 texels on target 1 only. In the function-only test, the two active readbacks had 103 and 104 PS invocations respectively. Restoring the old function changed 60/63/40 texels on targets 0/1/2 in the first draw and 56/60/35 in the second. Targets 3–5 matched. A console reference would be needed to decide which output is correct. The function-only control kept the PR's quad shuffle and predicate changes intact. Both replay processes exited cleanly. The measurements cover this shader's draw time in one save. Whole-game frame rate and the cause of the pre-world hang remain open. AI use: OpenAI Codex (GPT-6) reconstructed the intermediate trees, ran the builds and GPU replays, checked the logs and readbacks, and drafted this comment.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3501
No description provided.