Skip to content

[upstream #1934] Direct DXIL: XCL_DXIL_DIFF=1 differential kernel runs (both backends) - #227

Draft
ufoptg wants to merge 87 commits into
mainfrom
upstream-pr/1934
Draft

ufoptg wants to merge 87 commits into
mainfrom
upstream-pr/1934

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

XCL_DXIL_DIFF=1 runs the recompiler's kernel tests through both HLSL + DXC and the direct DXIL translator and fails on any difference. XCL_DXIL_DIFF_TABLE=<path> also records each paired program, for a per-opcode parity table. This is the proof the direct DXIL spec asks for before phase 7 (default-on). With the variable unset the tests run as before.

Draft: the head commit has not been built or tested yet.

What is in it

  • gpu/recomp/diff_kernel.rs: pairing, comparison and mismatch report, with tests
  • gpu/recomp/diff_table.rs: the per-program log and per-opcode summary, with tests
  • gpu/recomp/runner.rs, mod.rs: early returns taken only when the mode is on or a container was paired
  • gpu/recomp/tests.rs: pairs the tests that compile their own HLSL
  • docs/specs/2026-11-24-direct-dxil.md: 9 lines describing the switch (can be dropped if you prefer the spec untouched)

Tested
These runs are from before the final rebase, on a combined branch (376f968, based on main 689f2db; it holds this change, the other half of the differential mode, and six direct-translator parity fixes), not on this PR's head commit.

  • Windows 11 x64, NVIDIA GeForce RTX 5080 16 GB, cargo test debug build. Driver, CPU and Rust versions were not recorded.
  • cargo test -p xcl --lib recomp::diff_kernel -- --nocapture --test-threads=1: passed.
  • XCL_DXIL_DIFF=1 (with XCL_DXIL_DIFF_TABLE, XCL_DIRECT_DXIL unset), cargo test -p xcl --lib recomp:: -- --test-threads=1: 285 tests ran, 279 passed, 6 reported HLSL / direct mismatches. Not all of the 285 run both backends (some only translate). The combined tree had direct-translator fixes that this PR does not, so this PR alone may report differently.
  • Kernel-side mismatches: gpu_compute_tg_size_counts_a_partial_last_wave (HLSL 2, direct 1) and two 1–5 ULP floating-point differences in BVH ray intersection. Three more were wave64 VS / PS draws, found by the graphics half (separate PR).
  • Per-opcode table from that sweep: 71 rows, 69 matched, 2 mismatched.

Regression run
Not run: there are no xcl-smoke blocks for this change.

Not tested

AI use

  • Code and tests: written by Claude Opus 5.5 in an agent session (Duet) with no Windows or GPU.
  • RTX 5080 test runs above: a Claude Sonnet 5.5 agent.
  • Overlap check, rebase and this description: Claude Code, Claude Sonnet 5.5.

Mirror of xcl-dev#1934 (auto-synced, do not edit).

0x6461726B and others added 30 commits November 24, 2026 04:14
…LOAT

PC D3D12 rejects ALLOW_RENDER_TARGET and ALLOW_UNORDERED_ACCESS on DXGI_FORMAT_R9G9B9E5_SHAREDEXP (67) with E_INVALIDARG (0x80070057). In Series S (Lockhart) mode, a retail title creates a 1920x1080 format-67 target with flags 0x300005 during startup and aborts on the error.

Promote format-67 resources with RT/UAV flags and their RTV/UAV/SRV views to DXGI_FORMAT_R11G11B10_FLOAT (26, same 32 bpp unsigned HDR float with full PC RTV/UAV/SRV support), while keeping sampled-only format-67 textures unchanged.
The `title:` line of an xcl-smoke block printed the game folder's name,
and folder names are whatever people called their copy, so PR
descriptions ended up naming specific copies of a commercial game
(xcl-dev#677). It now prints the first 8 hex digits of the SHA-256 of the
folder name (trimmed, UTF-8). pr_check.py only compares the main and PR
blocks' titles for equality, so the check is unchanged, and two
different folders still get different titles. Existing blocks can be
converted with the same function (Python:
hashlib.sha256(name.strip().encode()).hexdigest()[:8]).

-Title <label> prints a label of your choice instead. Control, format
and line/paragraph separator characters and backticks are refused:
pr_check.py splits lines with str.splitlines(), so a U+2028 in a label
would otherwise add keys such as `commit:` to the block.

scripts/smoke-title.tests.ps1 checks hashes of ASCII, accented, CJK and
emoji names against Python's, a trailing backslash, -Title, and the
refused labels, with a stand-in for xcl.exe.

Fixes xcl-dev#677
…ites and kernelx

A kernel VirtualQuery on a 4 GiB OpenExistingHeapFromAddress coherent UMA window walks the entire region (~75-80 ms) while holding MmLockAddressSpace, stalling GetWriteWatch on other threads.

eh::is_writable already checks uma.in_committed_window() first; extend the same fast path to cpu_writes (write_now, write_u64_now, writable), kernelx (VirtualQuery, VirtualQueryEx, XMemVirtualQuery, committed_range, committed_page_in), and list_x frame-trace diagnostics.
The recompiler's Mode::Geometry as a direct compute pass: the ES for the
three vertices of 21 triangles per group (pre-fetched inputs), s_setpc_b64
into the GS, s_sendmsg GS emit / cut building strip triangles per lane, and
the mesh record (vertex / triangle counts, vertices copied from the GS
output area in LDS, triangles) written after wave prefix sums. The split
wave64 form runs the ES in both hardware waves, then a group barrier and the
GS in the lower wave with fresh registers, as the HLSL kernel does.
cfg::Cfg::build_geometry, lower_geom.rs; pso::console_geometry tries it
under XCL_DIRECT_DXIL=1 (HLSL fallback); coverage routes Mode::Geometry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ect translator

ops.rs: TexKind::D2MS / D2MSArray, texture_load_sample, Texture2DMSGetSamplePosition,
RenderTargetGetSampleCount / SamplePosition. lower_image.rs: image_load and
image_msaa_load (one component of four samples) on 2D MSAA (array) T#s, the fragment
index as sample index (no FMASK in D3D12), samples past the count read 0;
image_get_resinfo (one level). Stores / atomics (RWTexture2DMS, SM 6.7) and sampling
stay translation errors. runner.rs (test only): TexDim::D2Ms / D2MsArray filled
sample by sample with a per-sample draw.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Programs writing a non-default MODE[1:0] track MODE[1:0] / FP_DENORM single in an SSA
variable; f32 add/sub/mul/fma/mad/fmac/fmamk/fmaak/div_fmas, int and f64 conversions,
ldexp and sqrt compute exactly (f64 products, TwoSum) and round on the bits by the
mode, denormals flushed as FP_DENORM says. Constant modes fold, run-time modes
select per instruction. Direct-only (DXIL has no directed rounding). Tests against an
integer CPU reference; docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Restores fuzz_tests.rs, left out of xcl-dev#1426 only for the diff-size limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed FUZZ_WATCH

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…copies, TRANSLATOR_VERSION 5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…v#1307)

The structured form wraps the items that follow a forward jump in a guard
that lists every pending skip flag, and reopens it whenever the set
changes. With many flags pending at once that grows with the square of
the flags. Since b8b1f49 one compute program of the retail pack reaches
it: 148 MB of HLSL from 334 KB of code (3 861 flags, guards of up to 597
terms, 99 MB in guard lines), against 14 MB as pc blocks. DXC on that
fits the host's commit growing about 1 GB/s until it runs out, seen with
b8b1f49 and not without it.

Structured code longer than 128 bytes per byte of program is now
translated as pc blocks. Over the whole pack (CPU-side translation of
every program, macOS), only that program changes, to 13.8 MB. The next
largest structured program is at 61 bytes per byte. Every other program
comes out as it does on main, so b8b1f49's gain stays (1 670 -> 170
programs as pc blocks).

oversized_structured_code_falls_back_to_pc_blocks: 200 conditional
forward jumps whose targets all follow them, in order, cross the bound;
50 do not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…SLATOR_VERSION 6

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-oom

dxil: eliminate giant-shader IR and CFG blowup in FormatLoad and multi-window memory
… the sweep report

image_get_lod rejected MIMGs whose S# the console built from constants (79 PS
of the GTA VI pack, the only non-geometry gap of a full sweep). The static/heap
sampler choice moves into Lw::mimg_sampler, shared by sample/gather and get_lod.
The coverage report also keeps the 10 slowest programs (text output), to chase
the translation-time tail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The console orders a dispatch that writes indirect arguments before the
ExecuteIndirect that reads them with a barrier that reaches the PC as a
UAV barrier. NVIDIA's driver (RTX 5090) fetches the arguments without
waiting for it: the ExecuteIndirect ran the count the memory held before
the list, also when the dispatch wrote it through another resource over
the same memory, as translated shaders do through the memory windows.
A transition to INDIRECT_ARGUMENT makes the driver wait - of any buffer,
as measured - so each ExecuteIndirect is now recorded between two
transitions of a buffer of XCL's own (the title's buffer is in the
title's state).

Only lists XCL made (list_x::on_create) get the transitions, and not
bundles; the type comes from list_x's state (list_x::tracked_list_type),
not a call to the list, so a list XCL does not track gets no calls.

Test: execute_indirect_reads_the_arguments_written_before_it (GPU):
40 of 40 tries ran the old count without the transitions, 0 with them.

Assisted-by: omp (Claude Opus 5.5)
A backend that writes DXIL itself keeps the console CFG, so each lane can
branch on its own EXEC bit instead of every vector write being guarded and
branchy programs going through the `pc` dispatcher. This is the analysis it
needs: every lane mask is followed as a per-lane boolean function (a BDD
over the lanes' compare / carry results, uniform SCCs and unresolved
joins), mask branches are taken lane by lane, and a forward dataflow gives
what holds in each lane reaching a block. A vector instruction keeps its
guard only where reaching it does not imply the lane's EXEC bit.

Loop heads are guessed from their forward edges and checked against the
back edges; a wrong guess becomes an atom and only that head recomputes.
Results too large for a per-step node budget are weakened to atoms, which
only costs precision. Indirect jumps and irreducible loops are refused.

Nothing translates with it yet: `xcl shaders --recomp` prints its counts.
On the retail pack: 25 695 of 26 698 programs analysed (983 indirect
jumps, 20 irreducible), 10.65 M of 28.71 M vector instructions still
guarded (37.1 %), 9 015 programs with no guard at all, 700 CPU-s for the
whole pack (slowest program 1.5 s).
`dxil::assemble::assemble` turns a module written as LLVM IR text (or
bitcode) into a signed container: dxcompiler.dll's assembler builds the
container from the module's `dx.*` metadata, dxil.dll's validator checks and
signs it. No HLSL front end and no optimiser: a retail compute program's
module (8.6 MB of IR, 1 MB of DXIL) takes 0.75 s, its HLSL 25 s through DXC.

This is the text path under the module builder (`to_text()`), so the
lowering can run real programs on the GPU before the binary writer is done.

The test assembles a hand-written CS of the ABI root signature, runs it on
the GPU and checks its output, and checks that a use before its definition
is refused by the validator. A module needs an `!llvm.ident`: without one
it validates but the AMD driver faults in CreateComputePipelineState.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XTYmP5ub3Zjdi8PYaDNwsV
The direct backend's lowering, for kernel mode first. The console CFG is
kept and every register dword is an SSA value, built on the fly while the
blocks are lowered (`ssa.rs`). EXEC is each lane's own bit: mask branches
are per-lane branches and a vector write keeps `select(bit, new, old)` only
where the lane-mask analysis could not prove the bit set. An SGPR has a
number view and, when it holds a mask, a lane-bit view; a number read where
a mask was written (or the reverse across a join) is refused once every phi
is complete, and the program stays on the HLSL path. At the end, where every
lane is back, a mask stored as a number is the wave's ballot.

A mask written in a block some lanes skip (a loop lanes leave one by one,
an arm some lanes jump over) and read after they meet again differs from
the console, whose whole-wave write left the absent lanes' bits 0. Those
blocks are found from the post-dominators of the lane branches; such reads
are refused, and kernel mode's final store reports those registers.

The IR goes through an `Ir` trait, the part of the DXIL module builder the
lowering needs. The tests run it lane by lane on a CPU interpreter, and run
the same programs through the HLSL path on the GPU: every register agrees
(GTX 1650, wave32). The analysis now exports its CFG for the lowering.
`s_load_dword{,x2,x4,x8,x16}` and `global_` / `flat_` `load` / `store_dword
{,x2,x3,x4}` on the flat memory, with the addressing of the HLSL path's
single-window form. A guarded load runs in every lane and keeps the old
register where the lane's EXEC bit is clear (a raw buffer read out of range
is 0, so an inactive lane's address can't fault). A guarded store gets a
block of its own that only the lanes with their bit enter, and the rest of
the console block continues after it; the blocks are reserved before the
SSA form is built, so the predecessor lists stay exact.

The CPU interpreter in the tests gets the memory too, and the comparison
with the HLSL path on the GPU now also checks the memory after the run: a
program with an SMEM load, a per-lane load, a guarded store and an
unguarded one agrees word for word (GTX 1650, wave32).
The lowering takes a stage: kernel (the runner's ABI, as before) or a
compute program. In compute mode the user SGPRs come from `io`, then the
group ids and TG_SIZE the program enables, the thread ids go into v0–v2,
EXEC starts as every lane that runs, and the program ends without storing
registers (so kernel mode's report of stale masks does not apply).

One-dimensional groups only for now: in a 2-D / 3-D group the PC driver
need not give a wave consecutive threads, which the console does; the HLSL
path reorders them and those programs stay on it here.

A compute program with user SGPRs and the group id, over three groups of
64 threads, writes the same memory through the HLSL path on the GPU and
through the lowering on the CPU (GTX 1650, wave32).
`lower_dxil` implements the lowering's `Ir` trait on xcl-dev#1426's `Shader` /
`Module`: blocks, phis, integer ops, compares, `select`, the lane / thread
/ group ids, `waveActiveBallot`, and raw buffer access on the ABI's root
UAVs. A phi the SSA construction finds trivial keeps its identical incoming
values (the builder has no use replacement; the driver folds them).

Kernel and compute programs in their per-lane form now become signed DXIL
containers with no HLSL and no DXC, and run on the GPU: the lowering's test
programs agree with the CPU interpreter and with the HLSL path, registers
and memory (GTX 1650, wave32). The lowering's test programs are visible to
the crate's tests for this.
…kipped

An SGPR number or SCC written in a block that lanes leave one by one (a
waterfall loop's key, a counter of the passes) and read after they meet
again is each lane's own value in the per-lane form, where the console has
the last pass's. Such reads are refused like the stale masks, so those
programs fall back; kernel mode's final store reports the registers.
Taking the last-leaving lane's value is left for later. Reported by Sr-0w
on xcl-dev#1269 while putting wave operations on top of the lowering.

Two fixes on the way: a VOP3 instruction's op_sel was never refused (the
field is `OP_SEL`, not `OPSEL`), and an SOP1 mask-width op counted s0 as a
second source because `SSRC1`, which SOP1 lacks, defaulted to 0. The
assemble test declares validator 1.6, the oldest that knows SM 6.6.
At the kernel exit, lower_kernel pushes only r to `stale` for a mask some
lanes kept their own older bits of. In wave64, r + 1 is stored from the
upper half of the same ballot, so it carries the stale bits too, but it
was not reported: VCC after a loop that lanes leave one by one gave
[106] instead of [106, 107].

Found by a wave64 version of the GPU comparison with the HLSL path (the
existing one runs only wave32 programs): on an RX 7800 XT (native
wave64), `leaving loop` differed in s107, 0xFFFFFFFF in the lowering
against 0x80000000 on the GPU, where only lane 63 was active in the
last v_cmp.

Tests: the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu (the
five programs with _B64 mask operations and lane thresholds past 32,
native wave64 form, skipped without wave64) and
a_wave64_mask_left_behind_is_reported_in_both_halves (CPU only). Both
fail without the fix.

Assisted-by: Claude Code (Claude Opus 5.5)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The lowering now takes v_readfirstlane, v_readlane, v_writelane, DPP16 and
DPP8 sources, v_permlane16 / v_permlanex16, ds_swizzle_b32, v_mbcnt and
s_bcnt0 / s_bcnt1 / s_ff1 of a mask, in wave32 and wave64 (lower/wave.rs).
`Ir` gains `read_lane` (WaveReadLaneAt) and `count_bits`.

A lane reads another through `read_lane`, which needs that lane to be at
the same instruction. Lanes are where the console has them, except those
that went the other way at a lane branch. So a read of a lane in EXEC is
always defined (readfirstlane, and DPP / permlane / swizzle without
fetch-inactive, whose source outside EXEC gives 0 or keeps the
destination). A read of any lane (readlane, writelane, fetch-inactive) is
refused in a block not every lane reaches, and the program stays on HLSL.
A mask read as a number is the ballot of its bits: exact for EXEC (a lane
elsewhere is outside it), and for any mask where every lane is here.

The CPU interpreter runs a wave operation over the lanes waiting at it
(the first such point in block order), instead of requiring every lane
there; a waterfall loop's readfirstlane needs this.

Tests: the operations on the CPU in wave32 and wave64 with expected
values; a waterfall loop; a readlane in that loop is refused; and both
programs agree with the HLSL path on the GPU, register by register, in
wave32 and wave64 (RX 7800 XT). Registers the waterfall loop writes and
the program reads after it (an SGPR, the saved EXEC) are left out of the
comparison: each lane keeps its own last pass's value there, which the
lowering does not refuse yet. A stale wave64 mask's second register is
treated as stale too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XTYmP5ub3Zjdi8PYaDNwsV
… lowering

Sr-0w's cross-lane operations add Ir::read_lane and Ir::count_bits; on xcl-dev#1426's builder they are waveReadLaneAt and countbits.
`xcl shaders --recomp` now builds every compute program of the pack both
ways: in its per-lane form (`lower_dxil::compute_code`) and in xcl-dev#1426's
per-instruction form (`gpu::dxil::kernel::translate_compute`), and prints
how many each covers, the DXIL size where both do, and why the per-lane
form refused the rest.

The first pass: per-instruction 2 689 of 2 689, per-lane 4. The commonest
refusals were `v_nop` (now nothing), `s_setreg*` of MODE (now nothing: only
float instructions read it, and the lowering refuses every float
instruction so far), 2-D / 3-D groups, and the three-source integer ops,
now lowered (`v_lshl_add_u32`, `v_add_lshl_u32`, `v_lshl_or_b32`,
`v_and_or_b32`, `v_or3_b32`, `v_xor3_b32`, `v_add3_u32`).
vladbondarenko97 and others added 30 commits November 24, 2026 18:00
… path and per lane

Two programs in the shape of the f32 ones (`f16_programs_on_the_gpu`):
- f16 VOP1 / VOP2 / VOP3: ties to even, denormal results and their
  ties, overflow to infinity, a fused fma just below a tie (lane 1:
  double rounding through f32 lands on the tie), NaN into min / max /
  med3, OP_SEL source and destination halves, omod and clamp, ldexp into
  denormals, rndne (-0 at lane 15), f16 <-> i16 / u16;
- VOP3P packed math: OP_SEL / OP_SEL_HI swapped and broadcast halves,
  NEG / NEG_HI, f16 clamp, saturating u16 / i16 (clamp), wrapping
  sub / mul_lo / mad, and v_cvt_pkrtz_f16_f32 (65504 for the out-of-range
  values).
The HLSL path's registers are checked against values computed in Rust
(`check_f16_*`, `f16_bits` rounding to nearest even), and the per-lane
DXIL is compared with the HLSL path register for register, as for f32.
The GPU loop of `f32_programs_on_the_gpu` is now `programs_on_the_gpu`.

Left out of the Rust checks: the f16 results the HLSL path rounds with
`f32tof16` (v_add/sub/fma/fmac/ldexp/cvt_f16_u16, v_pk_add/fma). Their
rounding is the driver's: on NVIDIA it rounds toward zero, where the
console rounds to nearest even (MODE.FP_ROUND = 0), e.g. 0x3C01 + 2^-11
gives 0x3C01 for 0x3C02. The per-lane comparison still covers them.

On 3511bb9 (RTX 3080 Ti, wave32) the HLSL path passes every check and
the per-lane form takes both programs, but it gives v_mul_f16 and
v_pk_mul_f16 rounded toward zero (xcl-dev#1426 writes them through
LegacyF32ToF16, the HLSL path through `f32_to_f16_rm`): x * 65504 is
0x7BFF for infinity (lanes 1-31) and the denormal ties of x * 2^-15 go
down (lanes 3, 7, ..., 31), so the per-lane half fails there. The wave64
halves are SKIPPED (no 64-lane waves).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Coalesce maximal straight-line runs of guarded vector instructions under
an unchanged EXEC mask (absorbing pure no-ops like s_waitcnt) into a
single per-lane EXEC branch lowered unguarded, merging updated registers
with SSA phis at the continuation block. Runs are emitted when they
contain a side-effecting instruction (stores, atomics, non-read DS, EXP)
or at least two guarded instructions; standalone guarded VALU/loads keep
a select. Runs stop at scalar/mask/SCC writes (including V_CMPX and
VOP3_SDST_ENC), cross-lane ops, and implicit-derivative image ops.

Track block def/use ownership in stale() so splitting a partial console
block into multiple runs keeps earlier definitions in the same console
block non-stale while keeping definitions inside a run block partial.

Assisted-by: Antigravity (Gemini 4 Neon)
Reviewed-by: Claude Code (Claude Opus 5.5, xhigh)
…ck's write

`stale()` keys each scalar value by the block that made it. A write in
a block some lanes skip of a value made elsewhere (an older mask copied
with `s_mov s4, s0`, a constant the builder shares) kept the older
block, so a read after the lanes meet was not refused although the
console's write reached every lane and each lane here kept its own.
Such a write now gets a copy of its own (`or v, 0`) defined in the
partial block.

Found by MiguelMachado-dev while writing guard coalescing.
`mask_reg` built its upper-dword answer with `then_some((r - 1, true))`,
which evaluates `r - 1` even when the condition is false, so a
cross-lane scalar op on s0 overflowed in debug builds
(`xcl shaders --recomp` panicked). It is lazy now (`then`).

Found and fixed by nobodyttk (xcl-dev#1269).
A few large programs kept the sweep running for over an hour (the
adapter's trivial-phi replacement walks the whole module each time).
They now count as "timeout: over N s" refusals, as the direct form's do.
`compute_with` passed `WaveSize(64)` to `Lw::finish` for a wave64 program
in the split form, so on a GPU with 32-lane waves only (the runtime's
split path) `CreateComputePipelineState` refused it (0x80070057 on a
GTX 1650): no split program reached the GPU through the runtime. The
split form now asks for 32-lane waves, as `compute_split` does. Test:
the 2-D / 3-D id programs in the split form through `compute_with`,
against the CPU lowering's wave64 run.

Also: `can_coalesce` uses `whole_quad` instead of its own copy of it.

Both found by MiguelMachado-dev, reading the code.
Each D3D vertex invocation is one lane, so no lane of a VS is outside
EXEC at launch (gefydev's answer in xcl-dev#1269). The lane-mask analysis now
takes a VS's launch EXEC as every lane (`LaunchExec::All`, as for
compute), and the lowering sets each lane's EXEC bit at the program's
first block, so a VS that never writes EXEC keeps no guard. Only a PS
takes the launch EXEC as unknown.

Tested on an RTX 4090 (Windows 10 22H2, DXC 1.8.2502):
- cargo test -p xcl --lib -- recomp::lower recomp::lane_masks gpu::dxil
  --test-threads=4: 133 passed, 0 failed, 1 ignored;
- cargo test --workspace --no-fail-fast -- --test-threads=4: lib 869
  passed, 0 failed, 22 ignored; every other test binary passed;
- with the VS's launch EXEC taken as unknown again,
  a_ps_helper_lane_runs_the_program_but_does_not_store fails (the VS's
  store keeps its guard).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DxilIr's Sink::replace called Module::replace_all_uses for every trivial
phi the SSA construction drops, and each call walks every instruction and
metadata entry of the module, so the per-lane lowering took time
(trivial phis) x (module size), about quadratic in the program's size.
A CPU profile (WPR) of one 80 KB retail compute program put
replace_all_uses and the heap at the top: survey_compute_code took 18.5 s
of the program's 19.3 s, and the CS + MS per-lane survey
(XCL_RECOMP_STAGES=CS,MS XCL_RECOMP_NO_HLSL=1) did not finish in 10
minutes on a 12-thread i5-11600. The runtime's per-lane form
(XCL_PER_LANE=1) goes through the same adapter.

replace now records old -> new, and DxilIr::finish makes all of them in
one pass (Module::replace_uses, which follows a chain a -> b -> c as the
calls one at a time in order did) before xcl-dev#1426's Lw seals its blocks.
Nothing reads an instruction's operands back before then: the SSA
construction resolves a replaced phi through its own forward map, and
Lw's SSA only compares the values it holds. replace_all_uses stays and
goes through replace_uses.

Test: a batched map with a chain gives the same container as
replace_all_uses one at a time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
xcl-dev#1693 put memory windows through the descriptor heap in xcl-dev#1426's lowering
(XCL_HEAP_WINDOWS), so compute_with no longer refuses them: with several
windows the per-lane form's memory instructions go through Lw, which
now reads the window from the heap.
Extend coalesced_foreign_runs_agree_on_the_gpu to also run coalesced_run(true)
through compute_with with wave64=true, split=true and 4 memory windows
(cut = 40, spanning both wave32 halves) so wave64 coalesced runs are checked
on 32-lane hardware too.

Assisted-by: Antigravity (Gemini 4 Neon)
On CI the adapter is WARP, which has neither 32- nor 64-lane waves, and
every per-lane GPU test failed there in CreateComputePipelineState
(0x80070057) instead of skipping. They now require a GPU that runs
`[WaveSize(32)]` programs, as `recomp::tests::gpu_ready` does, and skip
with "no GPU with 32-lane waves" otherwise. With XCL_ADAPTER=warp the
lib runs 876 passed, 0 failed, 22 ignored.
…odes it drops

Two correctness gaps on programs the per-lane form took, found by
Kalmarv's review of xcl-dev#1745 with GPU programs against the HLSL path:

- A branch on whether any lane of a mask is set (`s_cbranch_vccz` /
  `vccnz`, `s_cbranch_scc*` after a mask op or `s_cmp_lg` of a mask) and
  a scalar read of such an SCC (`s_cselect`, `s_cmov`, `s_addc`,
  `s_subb`) decide for the whole wave on the console. The analysis took
  each lane's own bit, which differs in the lanes in EXEC that lack the
  bit (VCC = lanes 0-15, EXEC = all 32: 7 where the console gives 0). They
  are now taken only where the condition is the same in every lane that
  reaches with its EXEC bit (`s_and_saveexec` then `s_cbranch_execz`, or
  VCC equal to EXEC), and refused otherwise. The analysis test that
  stated the old assumption (a vccz branch is a lane branch) now states
  the rule.
- `s_setreg` of MODE was a no-op, so a non-default rounding mode was
  dropped where xcl-dev#1426 and the HLSL path refuse the program. MODE writes
  now go to xcl-dev#1426's lowering, and the adapter sets `dyn_rm` /
  `has_f64_round_op` as xcl-dev#1426's translator does, so `s_round_mode` and
  `s_setreg` refuse what they cannot honour. Denormal-only writes are
  still taken.

Tests: Kalmarv's five branch / select programs are refused, and a
uniform one is taken; f32 by `s_setreg` and f64 by `s_round_mode` /
`s_setreg` are refused (the f32 one was taken before the fix), and a
denormal-only write is taken.
thehollowedone's program on xcl-dev#1745: `s_and_b32 s0, vcc, exec` sets SCC
in a loop's body and the next iteration's `s_cselect_b32` reads it. The
loop head's join counted only the edges whose masks it uses, and back
edges do not count there, so the SCC came out a uniform value and the
per-lane form selected by each lane's bit: 7 where the console gives 5
in lanes 16-31. The mask-op flag now comes from every incoming edge,
back edges included, and an unknown SCC that is a lane's on some edge is
an unknown lane condition, so the whole-wave rule refuses it.

Test: his program is refused (it was taken before the fix).
Pipodi's review of xcl-dev#1745: the translated-cache identity of `XCL_PER_LANE`
entries did not include the per-lane form's sources, so a cached
container outlived a change to the lowering. build.rs hashes them into
XCL_PER_LANE_SOURCE_ID, which only the per-lane entries' identity
includes (the HLSL path's entries keep theirs).
Recompiler: a per-lane form for the direct DXIL backend (XCL_PER_LANE)
Direct DXIL: image_get_lod accepts static samplers
D3D12.X: promote R9G9B9E5_SHAREDEXP render/UAV targets to R11G11B10_FLOAT
D3D12.X: an ExecuteIndirect reads the arguments written before it
D3D12.X: eliminate multi-heap UpdateTileMappings and per-texture Signal stalls in vram::Pages
Resolve kernel.rs against main's Lw::new refactor: the geometry entry's
res buffer, LDS, 64-thread groups and f32_rm/geom fields move into
Lw::new. TRANSLATOR_VERSION 7 (main's 6 + 1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nearly 1000 PRs are open. actions/stale (pinned to v11.0.0's commit) labels a PR without activity
for 3 days `stale`, says what to do about it, and closes it 4 days later if nothing happens.
Issues are left alone; PRs labelled `goal:world-load` or `keep-open` are exempt. A manual run is a
dry run unless told otherwise.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Direct DXIL: geometry mode, MSAA loads and directed f32 rounding
…ver-crashes

dxil: emit MSAA textureLoad before getDimensions to avoid amdxc64 crash
Memory: skip VirtualQuery on committed coherent UMA windows in cpu_writes and kernelx
…ast-boot

Fast-boot: opt-in Bink intro skip, frame interval override, device type and TTS mute env vars
The direct DXIL spec's testing strategy asks for every recompiler kernel
test to run through both backends with identical results; the runner
picked one backend by XCL_DIRECT_DXIL. With XCL_DXIL_DIFF=1,
runner::run_code, run_code_with and run_program (through run_code)
translate the program with HLSL + DXC and with the direct translator,
run both kernels with the same inputs and compare SGPRs, SCC, every
lane's VGPRs, exports, flat memory and the UAV test textures. A
difference is an error naming the field, the first 8 differing slots
(lane/register decoded, HLSL and direct value in hex) and the count; a
program the direct translator refuses keeps the HLSL result (counted,
each distinct reason logged once), so the existing suite runs unchanged
in this mode. Panics, validation and builder failures of the direct
translator are errors, not refusals.

Tests that compile the HLSL kernel themselves (kernel_wave, run_wave and
kernel-mode direct_or in recomp/tests.rs) pair the container with its
direct translation (diff_kernel::pair); every later runner::run* of
that container on the same thread runs both and compares, so a test
that runs one kernel from many states is compared for each. Compute-mode
programs from direct_or are paired too: runner::dispatch then compares
the flat memory both dispatches leave (dispatch_timed stays one run).

Each backend stores only the registers it uses, so a register one side
leaves unstored (0) while the other stores its unchanged input value is
not a difference: an SGPR on its own, a VGPR only when that holds in
every lane that ran.

The comparison lives in the new recomp/diff_kernel.rs; runner.rs gains
early returns in run_code, run_code_with, run_with_statics and
dispatch, tests.rs one pairing line in kernel_wave, kernel- and
compute-mode branches in direct_or, and diff_pair for two compute
tests that compile their own HLSL (the safe-barrier test's multi-warp
loop only: main's direct s_barrier does not handle early-exited waves).
Without the variable nothing changes.

With XCL_DXIL_DIFF_TABLE=<path> as well, each paired program appends one
line to <path> (test thread name, FNV-1a hash of the program, matched /
mismatched / refused / failed, its distinct RDNA2 mnemonics), one
append-mode write per line and once per program and outcome, so the
per-opcode parity table needs no exit hook. The new recomp/diff_table.rs
holds the recording and summarise/table, which count per opcode the
distinct programs containing it by their worst outcome; with
XCL_DXIL_DIFF_SUMMARY=<path> its summary test prints that table and
writes it to <path>.summary.tsv.
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.