Skip to content

Recompiler: direct PS compares skip the per-quad mask where no helper bit is read - #2571

Merged
Prime1997 merged 1 commit into
xcl-dev:mainfrom
Kalmarv:direct-ps-local-masks
Nov 30, 2026
Merged

Prime1997 merged 1 commit into
xcl-dev:mainfrom
Kalmarv:direct-ps-local-masks

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Since #2083 every pixel-shader compare on the direct DXIL route rebuilds its quad's four bits: quad reads of its VGPR operands and four WaveActiveBallot passes. That is right for masks whose helper-lane bits are read, but it is used for every compare. On the 610 pixel shaders of title ea3b5e4d, it makes the DXIL 1.42× larger than before #2083 (median 1.36×). @MarcosMDev measured +28 % to +81 % driver time on an RTX 4060 in #2083, and found that a mask only v_cndmask reads needs no ballot.

This PR picks the cheapest form each compare's mask allows, from a forward dataflow analysis (recomp/ps_masks.rs):

  • own bit: a mask that is never read whole (x64_masks) takes the lane's own bit, as @MarcosMDev's variant in Direct DXIL: include pixel shader helper lanes in ballots and VOPC masks #2083 did;
  • WaveActiveBallot(c) | own bit (the HLSL path's ballot_px_local): a mask that is read whole, but where nothing reads another lane's helper bit. In this form every lane's copy has the live lanes' bits and its own bit right. So EXEC predication, v_cndmask and carry-ins stay exact in helper lanes, and so do the values they compute for later derivatives. The analysis refuses the form where something reads another lane's bit:
    • a non-bitwise SALU (s_cmp, s_wqm, s_bcnt …), SCC or VCCZ of the mask, or a scalar operand;
    • DPP, ds_swizzle / bpermute or permlane while EXEC carries the mask (they read the source lane's bit of the reader's EXEC);
    • v_readfirstlane under it (waterfall loops);
    • SGPRs, SCC or a widened EXEC that a branch on such an EXEC makes differ between lanes after it.
      A register known to be a subset of the entry EXEC (the live-pixel mask a kill updates) has no helper bits, so it is exact whatever it was computed from;
  • cond ? EXEC : 0: a compare of scalar / constant operands;
  • every other compare keeps Direct DXIL: include pixel shader helper lanes in ballots and VOPC masks #2083's form, and ORs in its own bit, which the quad's other lanes may not have seen in their copy of EXEC.

None of the new forms has a quad op, so #134's AMD constraint holds: the kept compares still quad-read their operands, never the predicate.

On the 610 PS (110,821 compares) the forms split as:

form compares
own bit 43.0 %
ballot | own bit 30.7 %
cond ? EXEC : 0 3.6 %
kept (#2083's form) 22.7 %

The main reasons a compare is kept (shares of the whole-read masks, first reason only):

  • s_cbranch_vccz on the mask: 20 %;
  • s_andn2_wrexec / s_mov exec changes inside a branch on it: 7 %;
  • v_readfirstlane: 4 %;
  • SCC of a non-EXEC mask: 4 %.

Part of #156. Follows #2083.

What is in it

  • crates/xcl/src/gpu/recomp/ps_masks.rs: the analysis (forms), with unit tests.
  • crates/xcl/src/gpu/dxil/lower_valu.rs, lanes.rs: Lw::vopc takes the chosen form; Lw::ballot_ps_local; kept compares OR in their own bit. kernel.rs computes the forms for pixel shaders (not the split form), compact.rs keys blocks on them, and TRANSLATOR_VERSION 10.
  • lanes.rs test: Direct DXIL: include pixel shader helper lanes in ballots and VOPC masks #2083's standalone v_cmp read only by v_cndmask now expects no quad reads.
  • TRANSLATOR_VERSION 10 is also taken by my wave64-split PR; whichever lands second rebases to 11.

Tested

  • RTX 5070 Ti (NVIDIA 610.74), Ryzen 9 9950X, Windows 11 26200, rustc 1.99.0, DXC 1.9.2609, release.
  • DXIL, xcl shaders --direct --windows 4 --split 0 --validate on the 610 PS of title ea3b5e4d (DXC 1.9.2609): 0 errors, all validated on both sides.
  • DXIL instructions (dxc -dumpbin, function bodies) on 22 of them (the median and the largest growth under Direct DXIL: include pixel shader helper lanes in ballots and VOPC masks #2083, 20 random): 1,120,934 on main → 824,591 (×0.736); per program median ×0.79, best ×0.39. DXIL bytes on the same 22: 7.65 MB → 5.76 MB.
  • Driver compile time, RTX 5070 Ti: cold CreateGraphicsPipelineState (driver shader cache off with ShaderCacheControl) of each of the 22 PS with a pass-through VS, main and this PR alternating, two repeats (local harness, not in this PR):
    • repeat 1: 174.3 s on main → 128.6 s (−26 %); repeat 2: 164.5 s → 135.4 s (−18 %);
    • driver blob 9.87 MB → 7.94 MB (−20 %);
    • per program the ratio is 0.28 to 1.30 (other builds ran on the machine); 16 of the 22 are faster over both repeats.
  • The title's own pipelines, through the runtime path (XCL_DIRECT_DXIL=all; VS and PS take the non-split direct form there): the 509 PS behind its cold graphics pipelines are 104.4 MiB of DXIL on main and 72.1 MiB here (−31 %), 16.62 M → 11.12 M instructions; VS unchanged; 0 failures.
  • GPU tests (RTX 5070 Ti), lib tests built from this head plus a local xcl shaders reporting patch (CLI only, not in this PR): ps_ballot_tests 4 passed (with Direct DXIL: include pixel shader helper lanes in ballots and VOPC masks #2083's gpu_direct_ps_masks_hold_helper_lanes_on_triangle_edges: ddx, ddy and a waterfall loop on triangle edges); XCL_DIRECT_DXIL=all, gpu_ps_: 8 passed; XCL_DIRECT_DXIL=all, gpu_wave64_ps: 2 passed; 0 failed, 0 skipped.
  • cargo test --release --workspace --no-fail-fast -- --test-threads=4 on the RTX 5070 Ti (XCL_DXC_DIR = DXC 1.9.2609): 1426 passed, 0 failed, 46 ignored. SKIPPED (15 tests): the wave64 cases (no wave64 on this GPU) of lower_dxil / lower / kernel tests, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware; the f16 / f32-conversion per-lane cases (refused forms); heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • The same with no GPU (XCL_ADAPTER=nomatch): 1426 passed, 0 failed, 46 ignored. Two earlier runs of the lib binary ended in an access violation inside tls::tests, which this PR does not touch; those tests pass alone (15 of 15 runs).
  • RTX 2060 (NVIDIA 595.91) under Wine (wine-staging 11.21) + vkd3d-proton 30b0eb9, windows-gnu release lib tests, this head and main e1d84b7, XCL_DIRECT_DXIL=all:
    • ps_ballot_tests 4/0/0, gpu_ps_ 8/0/0, gpu_wave64_ps 2/0/0 on both, no SKIPPED;
    • gpu::: 700 passed, 3 failed, 22 ignored here, 697/3/22 on main (the 3 more are the new ps_masks tests). The same 3 fail on both (f64 / f16 rounding on that stack) and the same 13 tests print SKIPPED on both.

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: f4ee8ac5f934d431b5b112df1f7293027f0ed9ff
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1654 (PresentX 1654)
presents per 2 s (last 3): 60 60 59
device removals: 0
crashes: 0
peak commit: 15302 MB

Not tested

AI use

  • Claude Code, Claude Opus 5.5: wrote the analysis, the lowering and the tests, ran the measurements and wrote this description.

🤖 Generated with Claude Code

@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, 26 ignored.

Thanks!

— Devin

@luckyteagirl

Copy link
Copy Markdown
Contributor

RX 6800M focused test report for #2571: the helper-lane pixel test starts, then the Windows test process exits with 0xc0000005 (STATUS_ACCESS_VIOLATION) before reporting a pass or failure. I reproduced this on the exact PR head and on an earlier XCL head, so I cannot attribute the crash to this PR.

Setup: Windows 11 Home build 26200, Ryzen 9 5980HX, AMD Radeon RX 6800M (driver 30.0.13002.13003), Rust 1.99.0 MSVC, DXC/dxil 1.9.2609.5. XCL_ADAPTER=6800M, XCL_REQUIRE_GPU=wave64, XCL_DIRECT_DXIL=1, with XCL_DXC_DIR set to the pinned DXC folder. Clean detached PR head ad0ded91d9fac08d27631c8c09b2b83c9c923adf, isolated Cargo target.

Tested: cargo test --locked -p xcl --lib -j 1 gpu_direct_ps_masks_hold_helper_lanes_on_triangle_edges -- --test-threads=1 --show-output, under a monitor that stops on low free system commit or physical memory. Compilation completed and the harness printed running 1 test, the exact fixture name, and the DXC version. It then exited 0xc0000005 before ok, FAILED, or summary counts. The guard did not stop this run. A no-build direct rerun of the same test binary with --exact --test-threads=1 --nocapture reproduced the same exit. There was no SKIPPED line in either run; neither produced a test result.

Earlier-head control: The same exact test in a previously built clean #2514 binary (57853e017054d715cd46cd3c07cb70e58eddddc8) also exited 0xc0000005 at the same point, with no test result. That head has the same lanes.rs as current main, but other compiler files differ, so this is not an exact-main baseline.

Not tested: exact current main, a title smoke pair, or the full suite. The first cold build attempt stopped at the memory guard before any test ran; it is not counted as a test result. No game files were used.

AI use: Codex (GPT-6) and a Codex Luna subagent ran the guarded test and direct controls, verified commit and binary provenance, and wrote this report.

@luckyteagirl

Copy link
Copy Markdown
Contributor

Follow-up to my RX 6800M report above: Windows Application Error (Event ID 1000) records all three focused-test process crashes in amdxc64.dll version 30.0.13002.13003, with exception 0xc0000005 at the same fault offset 0x00000000006b097b. Two events name the exact #2571 test binary under work-pr2571/target; the third names the earlier-head control binary under work-pr2444/target. Their recorded times were 16:43:25, 16:44:57, and 16:45:55 local on 2026-11-25.

This localizes the observed access violation to the AMD shader-compiler module on this machine. The earlier-head control faulted at the same offset, so it still does not establish a regression from #2571. I have no call stack or shader compiler dump and did not rerun the test for this follow-up.

AI use: Codex (GPT-6) read the local Windows Application Error records and prepared this supplemental report.

@Kalmarv
Kalmarv marked this pull request as ready for review November 26, 2026 04:04
rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
…read (port upstream xcl-dev#2571)

LATER shared analysis: new backend-independent recomp/ps_masks.rs
forward analysis lands whole with its CPU unit tests (3 pass on
Linux). The DXIL consumption (ballot_ps_local, vopc forms,
TRANSLATOR_VERSION) stays out for the future SPIR-V path.
@Prime1997 Prime1997 mentioned this pull request Nov 26, 2026
@rgroenewoudt

Copy link
Copy Markdown

Test report on AMD RDNA4 for ad0ded9

Tested

  • AMD Radeon RX 9070 (driver 32.0.32029.2010), Ryzen 9 5950X, 32 GB, Windows 11 Pro 26300, rustc 1.100.0, DXC 1.9.2602.17 (Windows Kits 10.0.26100.0), debug.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on ad0ded91: 1424 passed, 2 failed, 46 ignored.
  • gpu_direct_ps_masks_hold_helper_lanes_on_triangle_edges and gpu_ps_masks_hold_helper_lanes_on_triangle_edges pass on this GPU, with no crash in amdxc64.dll.
  • With XCL_DIRECT_DXIL=all, cargo test -p xcl --lib <filter> on this head and on its base e1d84b7d:
filter this head base
ps_ballot_tests 4 passed 4 passed
gpu_ps_ 8 passed 8 passed
gpu_wave64_ps 2 passed 2 passed
ps_masks 6 passed 3 passed

0 failed and no SKIPPED in any of them.

Not tested

  • A smoke run on a title and the driver compile time on AMD.
  • RDNA2/RDNA3; the RX 6800M crash in the earlier report is not checked here.
  • This head is not rebased onto current main.

AI use

  • Claude Code, Claude Opus 5.5: ran the tests and wrote this report.

@Decodere

Copy link
Copy Markdown
Contributor

Independent desktop NVIDIA (Wave32-only Ada) verification of PR #2571 at head ad0ded91d9fac08d27631c8c09b2b83c9c923adf (1 commit; exact parent & merge-base: e1d84b7d9153f86a97d2ec5d209d196046fc0bea, pre-#2555 ancestor of main).

Environment

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12, Wave32-only Ada), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6C / 12T), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200 (Developer Mode off)
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, DXC 1.9.2609.5, --release

Targeted release tests & build (ad0ded91)

Command Result
cargo test --release -p xcl --lib masks_read_lane_by_lane_or_restored_before_derivatives_take_the_cheap_forms -- --nocapture 1 passed; 0 failed; 0 ignored; 1326 filtered out (0.00s)
cargo test --release -p xcl --lib masks_read_across_lanes_keep_the_quad_form -- --nocapture 1 passed; 0 failed; 0 ignored; 1326 filtered out (0.00s)
cargo test --release -p xcl --lib a_kill_mask_of_live_lanes_stays_exact -- --nocapture 1 passed; 0 failed; 0 ignored; 1326 filtered out (0.00s)
cargo test --release -p xcl --lib gpu::recomp::ps_masks:: (3 consecutive runs) 3 passed; 0 failed; 0 ignored; 1324 filtered out × 3 (0.00s, 0.00s, 0.00s)
cargo test --release -p xcl --lib gpu::dxil:: 183 passed; 0 failed; 3 ignored; 1141 filtered out (3.41s; dispatch_chain_native_wave64_builds_whole self-skipped on Wave32-only RTX 4060)
cargo test --release -p xcl --lib gpu::recomp:: 395 passed; 0 failed; 19 ignored; 913 filtered out (5.09s; Wave64-only and #1426-refused subcases self-skipped as expected)
cargo build --release -p xcl --bin xcl Clean build (1m 09s, exit 0)

Paired quiet 60 s retail smoke (title: 29640639)

Exact parent & merge-base (e1d84b7d9153f86a97d2ec5d209d196046fc0bea, cached baseline on the same machine):

xcl-smoke v1
commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1531 (PresentX 1531)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13982 MB

PR #2571 (ad0ded91d9fac08d27631c8c09b2b83c9c923adf):

xcl-smoke v1
commit: ad0ded91d9fac08d27631c8c09b2b83c9c923adf
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1605 (PresentX 1605)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13990 MB

Runtime log observations (xcl.log)

  • 9220 log lines, 0 [ERROR] / device-removal / panic lines.
  • Final draw/memory telemetry in log: 19618 draws with translated pipelines (0 skipped, 0 with PC pipelines), 1024 dispatches (0 skipped); last memory sample 13990 MB committed by the process; video memory 6116 MB local, 4651 MB non-local.

Limits of coverage

  • Pixel-shader mask classification (ps_masks::, 3×) and full gpu::dxil:: / gpu::recomp:: suites passed on RTX 4060 (with expected Wave64-only skips on Wave32-only Ada and existing #[ignore] dump/fuzz/benchmark tests left ignored).
  • No separate cold retail PS corpus DXIL-size or driver compile-time benchmark (retail_ps_gallery / retail_shader_cost) or visual pixel-diff inspection was performed; the 60 s warm-cache retail smoke confirms clean runtime execution and zero regression on title: 29640639 (frame-count delta vs. cached parent smoke reflects normal single-run startup variance, not this PR).

AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).

@JJAutoCompare

Copy link
Copy Markdown

Tested: Clean ad0ded91d9fac08d27631c8c09b2b83c9c923adf, Windows 11 build 26200.9974, Ryzen 7 3800X, Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC, DXC/DXIL 1.9.2602.17, debug. cargo test --locked -p xcl --lib -j 2 --no-run, then exact test names with --test-threads=1 --nocapture. Eight CPU assertions and six Arc GPU fixtures passed, with zero failures, ignores or skips. The CPU fixtures checked lane-local compare and cross-lane helper reconstruction. HLSL and Direct DXIL triangle edge variants reported zero bad pixels out of 1,024 per draw. The helper ballot, mask and readfirstlane loops and the four EXP VM survival cases also passed.

Not tested: Base comparison, native wave64, full suite, retail smoke and performance.

AI use: T3 Code / Codex (gpt-6.2-sol) ran and reran the fixtures and wrote this report.

@CharlyRien

Copy link
Copy Markdown
Contributor

A possible wave32 gap in ps_masks::forms(). I found it by reading the code; it is not measured in-game. Could you check it with a wave32 test on your side?

Read (head ad0ded9, and the same code rebased onto main 7a649b0):

  • crates/xcl/src/gpu/recomp/ps_masks.rs:284: forms() takes its liveness from x64_masks::whole_live_out(insts, false). That function always calls whole_live_out_for_width(.., wave64 = true) (x64_masks.rs:543-545).
  • dxil/kernel.rs:758-759 calls forms() for every pixel program that is not split. That includes console wave32 pixel shaders on any card.
  • In wave64, a V_CMP writes an SGPR pair. In wave32 it writes one SGPR. With the wave64 liveness, a compare into s20 is treated as killing s21 as well.
  • Example (PS, wave32): v_cmp → s21, then v_cmp → s20, then s_bcnt1 s21. In the wave64 view, the first compare is dead at its site, so it gets Form::Own. But in wave32, s21 is still live and is read whole by s_bcnt1, which then counts only the lane's own bit.
  • This looks like the same shape as HLSL pixel masks: adjacent Wave32 carry destinations lose s21 on WQM triangle edges #2584, which Recompiler: Wave32 pixel mask writes kill one SGPR, not a pair #2781 fixed for the HLSL path ("Wave32 pixel mask writes kill one SGPR, not a pair"), but not for this direct-path analysis.
  • The tests in ps_masks.rs (forms_of, l.457) all build wave64 programs.

Deduced: in wave32 pixel shaders translated by the direct path, a compare whose destination is still read whole could get the per-lane form, giving wrong counts or ballots on helper-lane / triangle-edge pixels. I have not identified any affected program in a run.

Suggested: pass the wave width to forms() and use the width-aware liveness (whole_live_out_for_width, currently private), plus one wave32 test with the sequence above.

Context: we read this while rebasing a test tree onto main 7a649b0 (RTX 3090 24 GB, driver 616.56, Windows 11 22631). Nothing was built or run for this note.

AI use: found by an independent code review run with Claude Code (Claude Opus 5.5), checked and posted by me.

@Kalmarv
Kalmarv force-pushed the direct-ps-local-masks branch from ad0ded9 to c1686b6 Compare November 30, 2026 03:09
@github-actions github-actions Bot added area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 gpu:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test) labels Nov 30, 2026
@Kalmarv
Kalmarv force-pushed the direct-ps-local-masks branch from c1686b6 to d24df30 Compare November 30, 2026 04:29
@Prime1997 Prime1997 added the test-only A maintainer reviewed the diff: tests only, no smoke run needed for this revision (CONTRIBUTING.md) label Nov 30, 2026
… bit is read

Since xcl-dev#2083 every pixel-shader compare on the direct route rebuilds its quad's four bits
from quad reads of its operands and four WaveActiveBallot passes. On 610 retail PS that
makes the DXIL 1.42x larger than before xcl-dev#2083; the driver time grew with it (+28 % to
+81 % on an RTX 4060, measured in xcl-dev#2083).

recomp/ps_masks.rs picks the cheapest form a compare's mask allows: the lane's own bit
when the mask is never read whole, WaveActiveBallot | own bit (HLSL ballot_px_local) when
it is read whole but nothing reads another lane's helper bit, cond ? EXEC : 0 for scalar
operands. In the ballot | own form every lane's copy of the mask has the live lanes' bits
and its own right, so EXEC predication, v_cndmask and carry-ins stay exact in helper lanes
and so do the values derivatives read later. A forward taint analysis refuses it where a
helper bit of another lane is read: a non-bitwise SALU, SCC / VCCZ, a scalar operand,
DPP / ds_swizzle / bpermute / permlane / readfirstlane while EXEC carries it, or values a
branch on such an EXEC lets differ between lanes. A subset of the entry EXEC (a kill's
live-pixel mask) has no helper bits and stays exact. Kept compares OR in their own bit.

610 PS: 43 % own bit, 31 % ballot | own, 4 % cond ? EXEC : 0, 23 % kept; DXIL x0.784
(x1.109 of before xcl-dev#2083), all validate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Kalmarv
Kalmarv force-pushed the direct-ps-local-masks branch from d24df30 to f4ee8ac Compare November 30, 2026 04:43
@Prime1997
Prime1997 merged commit 1183cd4 into xcl-dev:main Nov 30, 2026
4 of 5 checks passed
@minimalhipster990

minimalhipster990 commented Nov 30, 2026 •

Copy link
Copy Markdown

Correction, December 1. The RTX 4090 world replay reproduces the drop from 0.716 to 0.186 fps across an interval containing #3503, #3501, #2123 and #2571. I previously attributed that whole drop to #2571 alone. The comparison does not establish that.

With #3318 applied throughout, the fast tree was da19f00c + #3318 (local merge daab7202). Merging f4ee8ac into that tree also brought its ancestors. The resulting tree (a07ad1b1) differs from the fast one in 14 files. The exact pre-#2571 control is f3bb6649 + #3318 (7ee8201f). Its seven-file diff to the slow tree is byte-identical to the patch for f4ee8ac. That control lost the device at 87.1 s with DXGI_ERROR_DEVICE_HUNG, before world entry, as in the two earlier attempts. The in-world cost of #2571 in isolation remains unknown.

The two measured 600 s runs finished on driver 621.40. The 300-540 s windows covered 170 presents in 237.51 s and 44 in 236.12 s. Three mesh/pixel shader pairs accounted for 68.8% of the summed GPU intervals in the slow four-frame sample (XCL_GPU_TIMES=4,200). For mesh bf5a7665d0c6631a with PS af68da74e05dbb3c, a fast repeat with the full ranking measured 18.34 ms/frame at 267 calls/frame. The slow tree measured 2364.53 ms/frame at 264 calls/frame. These timestamps cover the two-pass draw path, and the sampled frames can differ in geometry.

I then added identical inner timestamps and GPU-side indirect argument readback to both trees. On the slow tree, the mesh/raster dispatch of this pair accounts for 2392 of its 2426 ms/frame across four frames. For draws executing 2 compute groups and 8 mesh groups with 2560×1440 color and depth surfaces, compute measured 0.0345 vs 0.0346 ms/draw. Mesh/raster measured 0.0408 vs 17.0510 ms/draw (188 fast and 209 slow draws). We have yet to measure emitted primitives and pixel-shader invocations, so the specific shader or coverage change responsible is still open.

The fast diagnostic replay finished its 360 s limit. The slow one read all four frames at 245.8 s, then lost the device at 322.2 s (DXGI_ERROR_DEVICE_HUNG, DRED state 3, no breadcrumbs).

Original November 30 measurements, with the tree label corrected below.

Setup

Frames/s per minute, 300–540 s. The world arrives at 110–125 s in every tree, with the same 4,600–5,400 draws per present.

tree frames/s GPU
3a8745dc (#3497, before #3499) 2.13 · 3.08 · 3.08 · 3.22 · 3.17 100 %, 135 W
c9aa9f8a (#3499) 0.73 · 0.75 · 0.75 · 0.72 · 0.63 100 %, 110 W
da19f00c (#3502) 0.77 · 0.75 · 0.75 · 0.77 · 0.73 100 %, 110 W
5b3c9a4f (#3503) 0.75 · 0.77 · 0.72 · 0.77 · 0.75 100 %, 110 W
da19f00c + #3318 + merge of f4ee8ac including its ancestors 0.23 · 0.18 · 0.18 · 0.18 · 0.20 100 %, ~110 W
1183cd43 (this PR's merge) 0.18 · 0.17 · 0.18 · 0.20 · 0.20 100 %, ~110 W
d52ff48c 0.17–0.22 (2 runs) 100 %, ~110 W
d52ff48c + #3528's commit 49eb78e 0.18 · 0.20 · 0.22 · 0.22 · 0.23 100 %, ~115 W

Also seen while bisecting, gone on current main. The merges of #3501 (20e806f3) and then #2123 (f3bb6649) hung the GPU before the world, in 2 of 2 runs each: 82–87 s, 0x887a0006, DRED state 3, no breadcrumbs, nvlddmkm 153. The #3503 merge before them did not, and this PR's merge after them does not.

Not tested: AMD or other wave64 GPUs, isolated in-world frame time for this PR, or this PR on main without #3499.

AI use: Claude Code (Claude Opus 5.5) built the trees, ran the bisection and the replays and wrote this report. The person running these tests checked it and asked for it to be posted.

December 1 update: Codex (GPT-6) checked the Git ancestry, ran the follow-up replays and drafted the correction.

@Kalmarv

Kalmarv commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Thank you @CharlyRien and @minimalhipster990 for catching both of these!

Opened #3535 to fix @CharlyRien's wave32 register-width bug in ps_masks::forms() (threading o.wave64 into whole_live_out_for_width, uses_for_width, writes, per_lane, and VCC/EXEC masks). On wave32 NVIDIA GPUs, 100% of non-split pixel shaders hit ps_masks, so a wave32 v_cmp -> sN was wrongly killing s(N+1) in both liveness and forward taint and could misclassify a live mask as Form::Own (no ballot).

@minimalhipster990 — if you have a chance to test #3535 (stacked with #3528) on your RTX 4090 world replay, please let us know if that lifts the 0.75 -> 0.20 fps drop. If it still stays at ~0.20 fps with wave32 liveness fixed, the next suspect is Form::Local making EXEC per-lane (non-uniform) across S_CBRANCH_EXEC branches/loops, and we can either gate Form::Local on EXEC or revert #2571 while isolating it.

throny pushed a commit that referenced this pull request Dec 1, 2026
PR #2571 (1183cd4) called x64_masks::whole_live_out(insts, false) and x64_masks::uses(d) inside ps_masks::forms(), both of which assume wave64 register pairs. On wave32 pixel shaders (all non-split PS on wave32 NVIDIA GPUs), a compare writing sN was treated as killing s(N+1) in both liveness and forward taint, allowing an earlier compare into s(N+1) that is still read whole (e.g. by s_bcnt1, s_and_saveexec_b32, or a branch/loop) to be misclassified as Form::Own (no ballot) or have its taint cleared.

Expose x64_masks::uses_for_width and x64_masks::whole_live_out_for_width, pass o.wave64 from dxil::kernel into ps_masks::forms(), and use single-SGPR widths for VCC/EXEC/per-lane/writes in wave32 mode. Reported by CharlyRien on #2571.
@CharlyRien

Copy link
Copy Markdown
Contributor

An RTX 3090 data point for the drop minimalhipster990 bisected to this PR on the 4090: we see the same thing, and on NVIDIA this PR seems to hide a GPU hang from #3501 rather than cause the slowdown on its own.

Stack: main 493dbd3 (has #3535) + #3528 (ba8592a) + #3517 (0b4283d) + 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 53e85fb (before #3499, #3501 and #2571) 2 0.71 and 0.88 presents/s

What we read (not measured):

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 this PR. 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.

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

Labels

area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 gpu:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test) test-only A maintainer reviewed the diff: tests only, no smoke run needed for this revision (CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants