Skip to content

Recompiler: float16 params reach the PS as the floats of their halves - #3584

Open
CharlyRien wants to merge 5 commits into
xcl-dev:mainfrom
CharlyRien:pr/f16-flag1-halves
Open

CharlyRien wants to merge 5 commits into
xcl-dev:mainfrom
CharlyRien:pr/f16-flag1-halves

Conversation

@CharlyRien

@CharlyRien CharlyRien commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #2513 (MacieGx, float16 interpolants packed two per dword); only the commits above #2513's two belong here. #2513's two commits are included rebased onto current main (b2b1f109), with three conflicts resolved: main's integer-to-float conversion of PS inputs in v_interp_p2_* (36e1c89) is kept next to #2513's per-half mapping, and main's vok / pok mesh guards are kept with #2513's params.

The first of them (27332a4e) is a port of b6ee86a1 from Jockerino's fork (https://github.com/Jockerino/xcl-fork, GPL-3.0-or-later), with the author's agreement. It fixes the flag-1 case we reported on #2513 (#2513, 29/11): a float16 record with flag 1 is one half per dword (component c in the low half of dword c, exported over four dwords), not two halves a dword; only flag 3 is packed. Taken as packed, a flag-1 .xyzw param lost dwords 2-3 and its components 1-3 read the wrong halves. It also bitcasts the HLSL VS export for every float element, and gives a float16 PS input the interpolation its reads ask for, in both translators.

What is in it

  • 2790f41d, 6d0d0b63: Recompiler: float16 interpolants packed two per dword reach the PS per half #2513 (MacieGx), rebased onto main (gpu/dxil/lower_gfx.rs, kernel.rs, recomp/emit.rs, recomp/mod.rs, tests).
  • 27332a4e: flag 1 vs flag 3, from the fork's b6ee86a1 (recomp/mod.rs ParamLayout / F16Param, recomp/emit.rs, dxil/lower_gfx.rs, dxil/lower_mem.rs, 5 tests).
  • 44b3dcd0: a float16 half that no PS input element declares reads 0 (recomp/mod.rs ps_f16_slot): it fell back to the register's first element, so the PS read another element's component. Found by review, then counted in the title's shader pack: 6 pixel shaders (character shaders) read such a half (channel 3 of a packed attribute whose register declares .xy only). Test: two such halves in f16_packed_attributes.
  • 7de960d3: no layout change (the HLSL / DXIL produced is the same); each stage logs once per shape what is right only if the other stage chose the same float16 layout: a VS / MS record and its export that disagree (F16Param::disagrees, now called in out_param_layout), a flag-1 param exported packed, and a PS v_interp_p2_f16 read of a flag-1 attribute beyond the low half of dword 0 (after Foniass's review). Test: a_ps_read_of_a_flag1_attribute_beyond_its_first_half_assumes_packing, and the layout test checks disagrees.

Tested

Regression run

  • scripts/smoke.ps1, 60 s, the retail title, XCL_PREPARE=0, cold shader cache on both sides; main first, then this head: 516 frames vs 543 (95 %), peak commit 16,013 vs 15,844 MB, no removal, no crash.
xcl-smoke v1
commit: b2b1f109d27e746a62ec95b04dd1f9924452e682
gpu: NVIDIA GeForce RTX 3090
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 543 (PresentX 543)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 15844 MB
xcl-smoke v1
commit: 7de960d31e2c0b101db6d675d124c5c385e19196
gpu: NVIDIA GeForce RTX 3090
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 516 (PresentX 516)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 16013 MB

Not tested

  • AMD and wave64 hardware.
  • Plain main in the world (our tree carries other changes, listed above).
  • Edge cases from a read-only review of Recompiler: float16 interpolants packed two per dword reach the PS per half #2513 + b6ee86a1, checked against every program of the retail title's shader pack (12,095 PS, 11,518 VS / MS) and the 1,375 graphics pipelines a run used: a half nothing declares (6 PS, fixed in 44b3dcd0); a float16 attribute without a second register read by v_interp_mov_f32 (35 PS in the used pipelines, all fed by a flag-1 VS param, so the one-half-per-dword reading is right: 0 mismatches); a one-half-per-dword attribute read by v_interp_p2_f16 at a channel > 0 (0 cases); a flag-1 export with a partial mask (0 cases). Not checked on other titles.
  • Changes for programs without float16 params (from Recompiler: float16 interpolants packed two per dword reach the PS per half #2513, read, not measured): a mesh shader now uses its output table when the table parses, so a table whose order differs from the OSG1 registers moves its exports (and an empty table that parses drops them); the PS input-table parser also accepts records with byte 6 < byte 1 without a float16 flag, which can replace the old "N-th register" fallback; the HLSL VS export now bitcasts every element HLSL declares float (types other than 1 and 2), where it converted every type but 3.

AI use

MacieGx and others added 3 commits December 1, 2026 15:14
A retail title's world pixel shaders (xcl-dev#505; 173 of its 362) pack their
float16 interpolants: two components per dword (component c of a
register in dword c / 2, the even one in the low half) and up to two
signature registers per attribute, the second after the dwords the first
one's components take (1 for .xy, 2 for .xyz / .xyzw). The PS reads each
half with v_interp_p2_f16, SRC0 bit 8 choosing the high one.

XCL refused the PS input table of such programs (records [6, reg, mask,
attr, 0, reg2, packed reg, flags]: flag 8 = float16, flag 16 = byte 5
names the second register, byte 6 below byte 1 from the first pair on),
so every attribute, plain ones included, fell back to "the N-th
register" and the ones after a pair read their neighbour. The PS also
converted the raw packed dword as a float, ignored the high bit and
declared the float16 inputs nointerpolation.

Now the table parses, each (dword, half) of a packed attribute maps to
its element and component (f16_registers, ps_f16_slot; a record that
repeats its own register pairs it with the next float16 register no
other attribute names), and the PS reads that component as a float,
interpolated with the attribute's own mode. Both translators (HLSL and
direct DXIL).

The layout was checked on the title's dumped programs: every
v_interp_p2_f16 (dword, half) of 376 of 378 packed attributes in 362 PS
is a declared component (2 read one past a .xy register).

Not covered here: the VS / mesh side still exports the packed dwords
raw (the next commit), so the GPU test feeds the PS from a PC VS that
hands over each component as a float.

register always in dwords 2-3, a repeated register paired with itself -
which does not match the title's programs after a .xy register; both
have since dropped their float16 part in favour of this change.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The other half of the previous commit: the VS and mesh (NGG) programs
that feed those pixel shaders export their float16 interpolants packed
the same way - two components per dword, up to two signature registers
per exp param.

XCL refused the output table of such programs (records [6, reg, param,
reg, 0, 1 | 3]: 1 = float16, 3 = more than one dword) and fell back to
"the N-th register", so every param after a pair went to its
neighbour's register; a packed param went raw into its first register
alone. A mesh program never used its table at all.

Now the table parses for VS and mesh programs (MsInterface::params) and
a packed param is unpacked where it is exported: each half goes as a
float to its own component of its own element, in the VS outputs and in
the mesh record, in both translators. The table does not name the second
register of a pair: the float16 registers pair up in order, so it is the
next one no other param starts with (f16_registers).

Checked on the title's dumped programs: the enable mask of every exp
param of 383 packed params in 442 MS is exactly the predicted dwords.

A mesh program with a table now takes its params' registers from it,
float16 or not, as a VS already did; without one nothing changes.

dwords 2-3 and paired a mesh program's registers without its table; it
has since dropped that part in favour of this change.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The two commits before this one (PR 2513, ported) take every float16 record of
a VS / mesh output table - flag 1 or 3 - as two halves a dword. The retail title
(xcl-dev#505) has two kinds (PR 2513's thread, CharlyRien 2026-11-29, and its own
listings): flag-3 records packed in dwords 0-1, with
filler in dwords 2-3 of an .xyzw register (exp param 7: two v_pack_b32_f16, 0
and 0x3c00, en 0xF), and flag-1 records on .xyzw registers exported over four
dwords, a half in the low bits of each (four v_and_b32 v, 0xffff, h, en 0xF).
Taken as packed, the second kind lost dwords 2-3 and its components 1-3 got the
wrong halves.

A flag-3 record is packed; a flag-1 one only where its export writes exactly
its packed dwords and not also one dword per component, else one half a dword:
component c is the low half of dword c (ParamLayout, F16Param). Either way each
component reaches its element as the float of its half, in the VS export and
the mesh store of both translators, so a float16 element is an ordinary float
however the PS reads it: interpolated by v_interp_p2_f16 (the PR's single
float16, a flag-1 .x read so), or flat by v_interp_mov_f32, which now gives the
half of a float16 attribute's float back in the low bits, as the title's
v_cvt_f32_f16 takes it - both halves of the dword where the PS record names a
second register (packed). The round trip is exact for every half but a NaN's
payload.

On the HLSL path the VS export assigned a dword to a float output as a number
for every component type but 3 (the thread, 13:44Z: a raw half 1.0 arrived as
0, 0.7 as 2048); it is now bitcast for every element HLSL declares float (all
but types 1 and 2). And a float16 PS input takes the interpolation its reads
give it - flat where v_interp_mov reads it, interpolated where v_interp_p1 / p2
do - where it was flat unless the PS table marked it packed; integers stay
flat. Both translators.

Tests, each failing without its part:
- dxil::core_tests::f16_params_reach_the_ps_as_the_floats_of_their_halves: the
  title's two kinds (flag 3 packed with filler, en 0xF; flag 1 over four
  dwords) and a flag-1 .x, from an HLSL and a direct VS to a PC PS;
- dxil::core_tests::f16_params_reach_a_console_ps_however_it_reads_them: the
  same from a console VS to a console PS reading them by v_interp_p2_f16 per
  half, by v_interp_mov_f32 and v_cvt_f32_f16, and the .x interpolated by
  v_interp_p2_f16 - HLSL and direct, and across;
- dxil::core_tests::f16_ps_inputs_take_the_mode_their_reads_give_them;
- recomp::attribute_tests::a_float16_params_layout_follows_its_record_and_its_export;
- recomp::tests::a_float16_ps_input_takes_the_mode_its_reads_give_it.

Ported from Jockerino/xcl-fork b6ee86a1 (https://github.com/Jockerino/xcl-fork,
GPL-3.0-or-later), written there on top of the fork's own port of xcl-dev#2513, with the
fork author's agreement. Moved onto main b2b1f10 + xcl-dev#2513: conflicts in lower_gfx.rs
(main's integer-to-float conversion of PS inputs, kept) and recomp/mod.rs.

Co-authored-by: Jockerino <51916136+Jockerino@users.noreply.github.com>
Assisted-by: Antigravity CLI (Gemini 4 Neon), conflict resolution
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs-pr-check Failing the PR description check (CONTRIBUTING.md) and removed needs-pr-check Failing the PR description check (CONTRIBUTING.md) labels Dec 1, 2026
ps_f16_slot fell back to the register's first element when no element declared the
component of a (dword, half): the PS then read another element's component instead
of the 0 its doc comment promises. In a retail title's shader pack 6 pixel shaders
(character shaders) read such a half: channel 3 of a packed attribute whose register
declares .xy only. Now the slot is None and both translators read 0.

Test: f16_packed_attributes checks two such halves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CharlyRien
CharlyRien marked this pull request as ready for review December 1, 2026 16:58
@fromthemoonx

fromthemoonx commented Dec 1, 2026 •

Copy link
Copy Markdown

Rerun on the new head (7de960d3: one commit that logs the float16 layouts only the other stage can confirm; the HLSL / DXIL produced is unchanged). The earlier report, on 44b3dcd0, is below.

merge-check
base: 1c8b551
head: 7de960d
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2918 passed, 1 failed, 51 ignored (base: 2909 passed); SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps), the same set as base; failing: hle::xaudio2::tests::xma2_source_voice_decodes_and_manages_lifetime. Not this PR: it is the race #3551 fixes, and it passed alone 3 of 3 on this merge.
review: read 7de960d3 (3 files, +75 -6). No correctness problem found; logging only.

  • The VS / MS export path now calls F16Param::disagrees and logs a record whose export matches neither layout, and a flag-1 param exported packed.
  • Both PS translators log a v_interp_p2_f16 read of a flag-1 attribute past the low half of dword 0. Each shape is logged once per process (the line does not name the shader).
  • The lines show up in the suite, for example float16 PS read: v_interp_p2_f16 reads flag-1 attribute 0 at channel 1 as packed halves: right only if its VS exports it packed and float16 export: param 1 (flag-1 record) exported over dwords 0x7, neither its packed dwords 0x3 nor one a component 0xf: laid out Halves.
  • The 10 named tests (the 9 earlier plus a_ps_read_of_a_flag1_attribute_beyond_its_first_half_assumes_packing), with XCL_REQUIRE_GPU=mesh: 3 of 3 rounds, 10 passed, none skipped.
  • The layout disagreement Foniass found is now logged, not fixed: a mismatched VS / PS pair still reads the wrong half (his follow-up). The author's survey of one title's pack found no such pair. Another title's would show these lines. I missed this point in my first report.
  • No retail title on this machine.
    performance: none: a set lookup per float16 export / read at translation time.
    verdict: safe to merge
    hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)
Earlier report on 44b3dcd (base 6bfb5c5)
merge-check
base: 6bfb5c5153ccc23517daf30aa1071ddb0fadb53c
head: 44b3dcd0e170f9a3921cc1e6eaa3a3218ba84aaf
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2912 passed, 1 failed, 51 ignored (base: 2904 passed, 0 failed, 51 ignored); SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps), the same set as base; failing: `hle::xaudio2::tests::xma2_source_voice_decodes_and_manages_lifetime` (left 2, right 1). Not this PR: it is the shared-counter race #3551 fixes, and it passed alone 3 of 3 on this merge.
review: read the whole diff (all 4 commits, so #2513's two as well: 11 files, +972 -54). No correctness problem found.
- The 9 new tests by name with `XCL_REQUIRE_GPU=mesh` on this wave32 GPU: 3 of 3 rounds, 9 passed, none skipped. The GPU ones (`f16_params_reach_the_ps_as_the_floats_of_their_halves`, `f16_params_reach_a_console_ps_however_it_reads_them`, `gpu_mesh_f16_packed_params`, ...) ran.
- Mutation: `F16Param::layout` always `Packed` (the flag-1 fix undone) fails `a_float16_params_layout_follows_its_record_and_its_export`, `f16_params_reach_the_ps_as_the_floats_of_their_halves` and `f16_params_reach_a_console_ps_however_it_reads_them`. Good.
- Mutation: `ps_f16_slot` ignoring the element's mask (the top commit undone) fails `f16_packed_attributes`. Good.
- Changes that also reach programs without float16, worth knowing:
  - Mesh `exp param N` now follows the FSSM output table (`MsInterface::params` from `vs_output_table`) where it used the N-th distinct register (`param_registers`). This applies to every mesh program with a table, float16 or not. It matches what the VS already did; the description's 442 MS are its evidence. No title was run here.
  - `ps_input_table` accepts a record whose byte 6 is below its register (`r[6] > r[1]` rejects, was `r[6] != r[1]`), also in tables with no float16 pair. Before, such a table was refused and the attributes fell back to distinct-register order.
  - The HLSL VS export now writes `asfloat` for every element type other than 1 / 2 (uint / sint), not only type 3.
- `src/gpu/recomp/{emit,mod}.rs` and `src/gpu/dxil` are in the translator identity, so cached translations rebuild once after the update.
- Provenance: the fork commit is credited in `27332a4e` (`Co-authored-by: Jockerino`, GPL-3.0-or-later, the author's agreement), and #2513's commits keep MacieGx as author.
- No retail title on this machine: the title's float16 shaders were not translated or drawn here.
performance: not measured. Float16 halves cost a shift and an `f16tof32` per component at export; programs without float16 records take the old paths (apart from the mesh table above).
verdict: safe to merge
hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)

@github-actions github-actions Bot added needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) and removed needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU labels Dec 1, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Review (head 44b3dcd, diff read, not a merge-check):

  • The PS and the VS can disagree on a non-pair float16 attribute's layout. The VS picks Halves or Packed for a flag-1 param from the export's en (out_param_layout, gpu/recomp/mod.rs ~769-778), but the PS picks it from the instruction alone: v_interp_p2_f16 always takes the packed reading (ps_f16_slot, ~817; emit.rs ~2515, lower_gfx.rs ~418) and v_interp_mov_f32 always the one-half reading (emit.rs ~2535, lower_gfx.rs ~430). So v_interp_p2_f16 reading channel 1 of a flag-1 .xyzw param exported over four dwords (the shape the description calls the title's usual one) gets component 2, and channels 2-3 read 0; v_interp_mov_f32 on a flag-1 param exported packed gets only the low half. The description counts 0 such reads in one title, but nothing detects or refuses these shapes.
  • F16Param::disagrees is never called outside tests. mod.rs ~750 computes when a record and its export disagree, but no translator path calls it (out_param_elements, ~799, is also test-only), so a mismatched export silently gets the Halves guess with no log line. That is the one signal that would make the shapes above visible on other titles.

Fine: the flag-1/flag-3 split, the half extraction and the float bitcast of float16 outputs match between the HLSL and direct DXIL VS/MS paths; a half no element declares now reads 0 in both PS translators; the GPU tests cover each case through both translators. This carries #2513's two commits rebased and fixes its flag-1 handling, so merging it supersedes #2513.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

Review on PR 3584 (Foniass): the VS picks a flag-1 param's layout from its
export, the PS from its instruction, and nothing showed when they could
disagree; F16Param::disagrees was only used by tests. Each stage now logs once
per shape what is right only if the other made the same choice: an export
that disagrees with its record, a flag-1 param exported packed (a PS reading it
with v_interp_mov_f32 gets the low half), and a v_interp_p2_f16 read of a
flag-1 attribute beyond the low half of dword 0 (right only if its VS packed
it). The layouts chosen do not change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added needs-pr-check Failing the PR description check (CONTRIBUTING.md) and removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU labels Dec 1, 2026
@CharlyRien

Copy link
Copy Markdown
Contributor Author

Thanks, both points are right (checked on 44b3dcd).

  • The PS and the VS pick a flag-1 param's layout independently (export en vs instruction), and nothing detected a disagreement. On the retail title I surveyed its shader pack offline before opening the PR: across all 12095 PS programs, no v_interp_p2_f16 read of a flag-1 attribute beyond channel 0; across its 67 flag-1 VS/MS records, no export that disagrees with the record; and the 41 used pipelines that pair a flag-1 export with a PS read are all consistent (VS one half a dword + v_interp_mov_f32). So this title is not affected, but nothing protects another one.
  • F16Param::disagrees was indeed test-only.

New commit 7de960d3 makes these shapes visible without changing any layout (the HLSL / DXIL produced is the same): each stage logs once per shape what is right only if the other stage made the same choice:

  • VS / MS export: a record and its export that disagree (disagrees, now called in out_param_layout), and a flag-1 param exported packed (a PS reading it with v_interp_mov_f32 would get only the low half);
  • PS: a v_interp_p2_f16 read of a flag-1 attribute beyond the low half of dword 0 (right only if its VS packed it).

It does not refuse anything: with VS and PS translated separately there is no way to know which side is wrong, and a consistent packed flag-1 pair logs both lines (bounded by the once-per-shape dedup). Linking the two at PSO creation would need both stages' layouts outside the translation cache; I left that out of this PR.

Tested on 7de960d3 (RTX 3090, Windows 11, release unless said): the 10 named tests (the 9 of the PR and a_ps_read_of_a_flag1_attribute_beyond_its_first_half_assumes_packing) on the GPU: 10 passed, no SKIPPED. Whole suite (debug, --test-threads=4): 2910 passed, 2 failed, 51 ignored; the 2 failures are the same two e2e debug-layer tests that fail on main on this card. Smoke (60 s, cold cache): 516 frames vs 543 on main b2b1f109 (95 %), peak commit 16,013 vs 15,844 MB, no removal, no crash; the PR description's blocks are updated.

AI use: Claude Code (Claude Opus 5.5) checked the points, wrote the commit, ran the tests and wrote this reply, posted at my request; Gemini 4 Neon (Antigravity CLI) reviewed the commit.

@github-actions github-actions Bot removed the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Dec 1, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Follow-up review (head 7de960d, since 44b3dcd, diff read, not a merge-check):

  • The PS and the VS can disagree on a non-pair float16 attribute's layout: partly fixed. Each stage now logs the shapes that are right only if the other stage chose the same layout: the VS a flag-1 param exported packed (flag1_packed, gpu/recomp/mod.rs ~812), the PS a v_interp_p2_f16 read of a flag-1 attribute past the low half of dword 0 (note_ps_f16_read, ~784, from emit.rs ~2516 and lower_gfx.rs ~420). The translation still picks each stage's layout on its own, so a v_interp_p2_f16 read at channel 1 of a flag-1 .xyzw param exported over four dwords still gets component 2, and a v_interp_mov_f32 of a flag-1 param exported packed still gets only the low half; nothing compares the two stages at link time or refuses the pair. The log lines are once per shape for the process and do not name the shader.
  • F16Param::disagrees is never called outside tests: fixed. out_param_layout (~808) now calls it on the VS, HLSL MS and DXIL MS paths and logs a record whose export matches neither layout. out_param_elements (~842) is still test-only.

New: none. 7de960d3 changes only logging, both PS translators make the same check, and the new unit tests cover ps_f16_read_assumes_packed and flag1_packed.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@claudetools-gh

Copy link
Copy Markdown

Tested head 7de960d3 on another card, cherry-picked onto an older tree. Our lab line is main from late November plus local commits. Main's 36e1c899 went in first, since this PR builds on it. The only conflict was a test in dxil/robustness_tests.rs: our older version of the test needed the new params: None field on MsInterface.

RTX 5070 Ti 16 GB, driver 621.40, Windows 11, release build, direct DXIL for graphics (the default). Same title, a new game, so the intro cutscenes are compared at the same moments. Two runs without the PR, one with it. The preparation took 16 s and there was no crash or device removal.

What changed, compared with the reference footage:

  • Night police stop (Lucia and Jason with their hands up): Lucia's white top was black in both runs without the PR. With it, it is white, as in the footage. Jason's face and black tank top also look right.
  • Living room on the sofa: without the PR, Jason's face was a flat black mask. With it, the face is shaded normally.

Still off with the PR, in case it helps narrow the remaining cases:

  • Jason's white tank top in the living-room scene renders dark grey.
  • Lucia's dark brown hair renders pale grey or near white. A XCL_DUMP_TARGETS frame with the PR, in the prologue cell, has the hair dark brown in the albedo target and near white in the lit target, so the colour comes from the lighting pass.
  • Lucia's eyes render black.
  • One straight hair strand crosses Jason's face.

AI-assisted.

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of 7de960d3: 6 finding(s) (4 high, 2 medium), most severe first.

  1. High crates/xcl/src/gpu/recomp/emit.rs:2395: The float16 param path calls exp_comp(srcs, compr, dw) and then shifts by 16*half. (inline)
  2. High crates/xcl/src/gpu/recomp/mod.rs:678: On the VS/MS side, f16_registers treats every flag-3 param as a pair and gives it the lowest float16 register above it that no table entry starts. (inline)
  3. High crates/xcl/src/gpu/recomp/mod.rs:950: Mesh shaders now take params from vs_output_table with no sanity check, so a table that parses but is empty or wrong replaces the earlier "N-th distinct OSG1 register" mapping and drops or moves every param export. (inline)
  4. High crates/xcl/src/gpu/recomp/mod.rs:858: The PS side reads a flag-1 (unpaired) float16 attribute with v_interp_p2_f16 as packed (comp = 2*chan + high), while the VS side lays out the title's usual flag-1 export (en 0xF) as Halves (component c in the low half of dword c), so t.... (inline)
  5. Medium crates/xcl/src/gpu/recomp/mod.rs:680: Not certain about this one: the dword where a pair's second register starts comes from the declared width of the first register in each stage's own signature (PS inputs on one side, VS/MS outputs on the other). (inline)
  6. Medium crates/xcl/src/gpu/dxil/lower_gfx.rs:436: v_interp_mov_f32 of an unpaired float16 attribute uses place from ps_attribute_slot, which falls back to the register's first element when no element declares the channel. (inline)

These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

let v = Self::exp_comp(srcs, compr, c);
let v = if e.component_type == 3 { format!("asfloat({v})") } else { format!("{v}") };
// float16: component c is the float of its half (`ParamLayout::place`)
let (dw, half) = layout.place(first, c);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High: The float16 param path calls exp_comp(srcs, compr, dw) and then shifts by 16*half. For a COMPR export, exp_comp already returns a 16-bit half picked by component index, so the half is selected twice and the layout is applied in the wrong space. The same code is at emit.rs:2463 (MS), lower_gfx.rs:341 (DXIL VS) and lower_mem.rs:2710 (DXIL MS). For exp param0 compr en=0x3 of a packed float16 param (srcs[0] = c0|c1<<16), component 1 maps to dw 0, half 1. exp_comp(.., 0) gives srcs[0] & 0xFFFF, and >> 16 of that is 0, so c1 reads 0.0. The dwords mask is also built per half (0x3 for one dword), so F16Param::layout / disagrees compare against the wrong mask. For COMPR, reading the raw dword (not exp_comp) before shifting would fix all four sites.

let second = match second {
Some(r) if r != first => Some(r),
_ if !pair => None,
_ => sig.iter().filter(|e| e.component_type == 6 && e.system_value == 0 && e.register > first && !claimed(e.register)).map(|e| e.register).min(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High: On the VS/MS side, f16_registers treats every flag-3 param as a pair and gives it the lowest float16 register above it that no table entry starts. It never excludes registers another flag-3 param has already taken as its second, and flag 3 only means "more than one dword", not "has a second register". With float16 outputs r1, r3, r4 (.xyzw), p0 = r1 flag 3 (one register packed in dwords 0-1, filler 0/0x3c00 in dwords 2-3, the title's exp param 7 shape) and p1 = r3 flag 3 (r3+r4), claimed = {1,3}, so p0 also takes r4 and writes r4 from its filler dwords (0.0, 1.0). If p0 is exported after p1, the PS reads filler instead of p1's real data, and p0's packed mask gains 0xC, which changes the disagreement check. Tracking claimed seconds, and only pairing when the param's dwords actually extend past the first register, would avoid it.

threads,
max_vertices: (p.ms_max_vertices as u32).clamp(1, 256),
max_primitives: (p.ms_max_primitives as u32).clamp(1, 256),
params: vs_output_table(&f.data),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High: Mesh shaders now take params from vs_output_table with no sanity check, so a table that parses but is empty or wrong replaces the earlier "N-th distinct OSG1 register" mapping and drops or moves every param export. An MS whose FSSM has count 0 at +0x1D4+0xC0 (or a sub-version-5 MS whose table holds unrelated records) parses to Some(vec![]). out_param_layout then returns no elements for every exp param N, each param becomes a dummy, and the PS reads 0 for every attribute where it used to be correct. Falling back to the old mapping when the table is empty or doesn't cover the exported params would keep MS working.


/// The place in `ranked(inputs, false)` and the component of the float16 in half `high` of
/// dword `chan` of a packed attribute (`regs`: `ps_attribute_f16`). None: no such component.
pub fn ps_f16_slot(ps: &PsInterface, regs: &[(u32, usize)], chan: usize, high: bool) -> Option<(usize, usize)> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High: The PS side reads a flag-1 (unpaired) float16 attribute with v_interp_p2_f16 as packed (comp = 2*chan + high), while the VS side lays out the title's usual flag-1 export (en 0xF) as Halves (component c in the low half of dword c), so the two stages disagree, and the PR only logs it. For a flag-1 .xyzw param exported over en 0xF, a PS v_interp_p2_f16 attr0.y (chan 1, low half) maps to PS component 2, so it reads the VS's .z where the console reads .y. A high-half read of chan 0 gets .y instead of the high half of dword 0 (0 on hardware). Both stages need to use the same layout decision for flag-1 params.

_ if !pair => None,
_ => sig.iter().filter(|e| e.component_type == 6 && e.system_value == 0 && e.register > first && !claimed(e.register)).map(|e| e.register).min(),
};
let width = sig.iter().filter(|e| e.system_value == 0 && e.register == first).map(|e| 8 - e.mask.leading_zeros() as usize).max().unwrap_or(4);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: Not certain about this one: the dword where a pair's second register starts comes from the declared width of the first register in each stage's own signature (PS inputs on one side, VS/MS outputs on the other). So a PS that declares fewer components than the VS writes puts it at a different dword. With VS/MS r1 .xyzw (second register at dword 2) and the PS's ISG1 declaring r1 as .xy (second at dword 1), the PS read of chan 1 goes to the second register while the VS wrote r1.zw there. The PS gets r2's values in place of r1.zw and is off by one dword from then on. Taking the width from the producing stage on both sides would make them agree.

// second register (packed)
let f16_mov = match ps_attribute_f16(&ps, attr as usize).filter(|_| name == "v_interp_mov_f32") {
Some(regs) if ps.attrs.as_ref().and_then(|t| t.get(attr as usize)).is_some_and(|a| a.pair.is_some()) => Some([ps_f16_slot(&ps, &regs, chan as usize, false), ps_f16_slot(&ps, &regs, chan as usize, true)]),
Some(_) => Some([place, None]),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: v_interp_mov_f32 of an unpaired float16 attribute uses place from ps_attribute_slot, which falls back to the register's first element when no element declares the channel. That's the bug 44b3dcd fixed only for v_interp_p2_f16, and emit.rs:2540 has the same code. A flag-1 float16 attribute whose register declares only .xy, read flat at chan 2 or 3, returns to_f16 of another element's component instead of 0, the same wrong-component read 44b3dcd reported for 6 PS in the title's pack.

@bmjask

bmjask commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.

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

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants