Skip to content

Recompiler: float16 interpolants packed two per dword reach the PS per half - #2513

Open
MacieGx wants to merge 2 commits into
xcl-dev:mainfrom
MacieGx:recomp/f16-packed-interpolants
Open

MacieGx wants to merge 2 commits into
xcl-dev:mainfrom
MacieGx:recomp/f16-packed-interpolants

Conversation

@MacieGx

@MacieGx MacieGx commented Nov 25, 2026

Copy link
Copy Markdown

A retail title (#505) packs its float16 interpolants: two components per dword and up to two signature registers per exp param / v_interp attrN. XCL refused the FSSM tables of such programs (PS input table, VS / mesh output table), fell back to "the N-th register", and so every attribute after a pair read its neighbour's register, plain ones included; a packed dword went raw into one register, and the PS converted it as one float. This PR reads the packing from the tables and unpacks it on both sides, in both translators (HLSL and direct DXIL).

Part of #505.

The console layout, as this PR reads it:

  • component c of a register sits in dword c / 2, the even component in the low half; the PS reads a half with v_interp_p2_f16 (SRC0 bit 8 = the high half);
  • the second register of a pair follows the dwords the first one takes: dword 1 after a .xy register, dwords 2-3 after .xyz / .xyzw;
  • PS input records [6, reg, mask, attr, 0, reg2, packed reg, flags]: flag 8 = float16, flag 16 = byte 5 names the second register; a record that repeats its own register pairs with the next float16 register no other record names;
  • VS / MS output records [6, reg, param, reg, 0, 1 | 3] (1 = float16, 3 = more than one dword): the table does not name the second register, so it is the next float16 register that starts no param of its own.

Evidence, from the programs dumped from a run of the title (no game data in this PR): the exp param enable masks of all 383 packed params in 442 mesh shaders are exactly the predicted dwords; every v_interp_p2_f16 (dword, half) of 376 of the 378 packed PS attribute reads in 362 pixel shaders is a declared component (the other 2 read one half past a .xy register). Programs without a table, and tables without float16 records, are translated as before, except that a mesh program with a table now takes its params' registers from it, as a VS already did.

What is in it

  • Recompiler: a PS reads float16 attributes packed two per dword per half: the PS input table parses the float16 / pair flags and each (dword, half) maps to its element and component (f16_registers, ps_attribute_f16, ps_f16_slot in crates/xcl/src/gpu/recomp/mod.rs); the PS reads that component as a float with the attribute's own interpolation mode (recomp/emit.rs, dxil/lower_gfx.rs). Tests: attribute_tests::f16_packed_attributes (recomp/mod.rs), dxil::core_tests::f16_packed_attributes_interpolate_per_half (dxil/core_tests.rs).
  • Recompiler: VS / mesh exports unpack float16 params packed two per dword: the VS / MS output table parses float16 params (OutParam, MsInterface::params, out_param_registers, out_param_elements in recomp/mod.rs); VS and mesh exports write each half as a float to its own component (recomp/emit.rs, dxil/lower_gfx.rs, dxil/lower_mem.rs, dxil/lower.rs, dxil/kernel.rs); the new MsInterface field in hle/d3d12x/real.rs and recomp/heap_window_tests.rs. Tests: attribute_tests::f16_packed_params, recomp::tests::gpu_mesh_f16_packed_params (recomp/tests.rs), and the VS side of f16_packed_attributes_interpolate_per_half.

494 lines added, 47 removed, about 300 of the added lines tests. The two commits are one feature (the PS side alone still reads raw packed dwords from the VS / MS), split by side so each builds and passes on its own.

Tested

  • NVIDIA GeForce RTX 5080 (driver 621.24, 32-lane waves), AMD Ryzen 7 5800X3D, Windows 11 Pro 10.0.26200, Rust 1.100.0, release builds.
  • cargo build --release --workspace at each commit: OK.
  • First commit: cargo test --release -p xcl --lib -- --test-threads=4 gpu::: 698 passed, 4 failed, 22 ignored (the 4 are fuzz_validate_and_gpu_0..3, below); its two new tests pass.
  • Head: the four new tests pass (cargo test --release -p xcl --lib f16_packed: 4 passed, 0 failed; gpu_mesh_f16_packed_params ran on the GPU, not skipped).
  • Head: cargo test --release --workspace --no-fail-fast -- --test-threads=4: 1423 passed, 4 failed, 46 ignored. The 4 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3 (CreateComputePipelineState E_OUTOFMEMORY); they fail the same way on main 6d12f58 on this machine, and alone.
  • SKIPPED (16 tests): no wave64 on this adapter: dispatch_chain_native_wave64_builds_whole, lower::tests::{a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu, coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu, cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu, the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu}, lower_dxil::tests::{a_per_lane_2d_or_3d_group_runs_on_the_gpu, const_and_null_mask_operands_agree_with_hlsl_on_the_gpu, f64_programs_on_the_gpu, integer_programs_on_the_gpu, mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu}, gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware; f16_programs_on_the_gpu / f32_programs_on_the_gpu: their wave64 cases (no wave64) and three wave32 per-lane cases refused (gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics); heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows; pso_measurement_compiles_an_exact_synthetic_record: cannot disable the driver cache (needs Developer Mode).

Relation to #1975 / #1976

Regression run

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 5080
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 1383 (PresentX 1383)
presents per 2 s (last 3): 35 52 56
device removals: 0
crashes: 0
peak commit: 19703 MB

this PR:

xcl-smoke v1
commit: 3bc875816e45550c3aaa6d44da3b3922b82d18e3
gpu: NVIDIA GeForce RTX 5080
title: 16b5e5d4
seconds: 60
exit: 0x0
frames shown: 1594 (PresentX 1594)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14983 MB

Not tested

  • AMD and Intel GPUs (wave64 paths), debug builds.
  • The effect in the title: only measured on a local branch where the title reaches its world (normal targets become per-pixel instead of flat per surface), not on a build of this PR alone; the regression run checks for regressions only.
  • HANDOFF.md's description of the FSSM records (PS 0, 0, register, 1 flat / 2 interpolated; VS kind, register, param) does not cover the float16 flags read here; not edited.

AI use

  • Claude Code. Claude Opus 5.5 coordinated; a Claude Fable 5.2 subagent found the layout in the dumped programs and wrote the change and its tests; a Claude Opus 5.5 subagent ported it to main, split it into the two commits, ran the tests and wrote this description.

🤖 Generated with Claude Code

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.

xcl-dev#1975 / xcl-dev#1976 parsed the same records with a fixed layout - the second
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.

xcl-dev#1975 unpacked the same params with the second register always in
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>
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@DarkPanda69

Copy link
Copy Markdown

AMD wave64 and debug-build run (both listed as untested), plus an RTX 3060: all 4 new tests pass on both cards, with and without the direct translator, and nothing else changes.

Head 3bc8758 applied on main 6d12f58, debug build, Windows 11 Pro 26200, card chosen with XCL_ADAPTER, cargo test -p xcl --lib -- gpu:: --test-threads=4 on main and with the PR:

  • RX 9070 XT (RDNA4, driver 32.0.32029.2010): gpu_mesh_f16_packed_params ok; it translates with wave64: true and no split, so on this card it runs native wave64. 702 passed, 2 failed, 6 SKIPPED (the same as main). The 2 failures are the AMD fuzz seeds tracked in DXIL fuzz tests: fuzz_validate_and_gpu_1 fails on AMD (seed 722 and others, RDNA2-4), so the default suite is red there #2115, the same on main.
  • RTX 3060 (driver 32.0.16.1088): gpu_mesh_f16_packed_params ok; 704 passed, 0 failed, 24 SKIPPED (the same as main).
  • With XCL_DIRECT_DXIL=1, the only result changes against main, on both cards, are the new f16_packed_attributes_interpolate_per_half, f16_packed_attributes, f16_packed_params and gpu_mesh_f16_packed_params, all ok. No existing test changes.

Not tested: the title, Intel, release build.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

@emirduran707

Copy link
Copy Markdown
Contributor

Independent AMD RDNA4 (native wave64) test report on exact head 3bc875816e45550c3aaa6d44da3b3922b82d18e3 (clean detached checkout, no local changes).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, native wave64, driver 32.0.31044.16), Ryzen 5 5600, 32 GB RAM, Windows 11 Pro 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1425 passed, 2 failed, 46 ignored; 8 SKIPPED (6 in lower_dxil::tests::{f16,f32}_programs_on_the_gpu refused by per-lane form; heap_window_out_of_memory_falls_back_to_the_switch_form; pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.
    • The PR's test passed: gpu::dxil::core_tests::f16_packed_attributes_interpolate_per_half.
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 seed 722 and fuzz_validate_and_gpu_3 seed 1599) are pre-existing on unmodified main on this GPU.

Regression run (60 s retail-title smoke, XCL_NETWORK=0, release)

xcl-smoke v1
commit: 3bc875816e45550c3aaa6d44da3b3922b82d18e3
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1568 (PresentX 1568)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13974 MB

(Matched main 68a284a baseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)

Not tested

  • D3D12 debug layer; Intel GPUs.

AI use

  • Antigravity with Gemini 4 Neon ran the build, test suite, and smoke run and drafted this report.

@SlopTart

Copy link
Copy Markdown

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

gpu_ suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.
Targeted run of the packed-f16 interpolant tests (f16_packed family): 4 passed.

Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

raylitebull added a commit that referenced this pull request Nov 26, 2026
After DCE removes unused components from a multi-dword rawBufferLoad
(e.g. a 4-dword load whose y/z/w extracts were dead), narrowing the
contiguous DXIL mask (15/7/3 -> 1/3/7) based on the highest live
ExtractValue index (< 4, never touching loads whose residency status
index 4 or whole struct escapes) reduces memory traffic and avoids
trailing OOB byte reads.

Also supplies early_depth: false in the cherry-picked #2513 f16 PS
interface test initializer.

Assisted-by: Antigravity (Gemini 4 Neon High)
koboshchan pushed a commit to koboshchan/xcl that referenced this pull request Nov 26, 2026
After DCE removes unused components from a multi-dword rawBufferLoad
(e.g. a 4-dword load whose y/z/w extracts were dead), narrowing the
contiguous DXIL mask (15/7/3 -> 1/3/7) based on the highest live
ExtractValue index (< 4, never touching loads whose residency status
index 4 or whole struct escapes) reduces memory traffic and avoids
trailing OOB byte reads.

Also supplies early_depth: false in the cherry-picked xcl-dev#2513 f16 PS
interface test initializer.

Assisted-by: Antigravity (Gemini 4 Neon High)
@itsSio

itsSio commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Independent dual-PC NVIDIA full-workspace test report on clean head 3bc875816e45550c3aaa6d44da3b3922b82d18e3.

Tested

  • Machine 1: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11 Pro build 26200, rustc 1.97.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug build (XCL_ADAPTER=NVIDIA)
    • cargo build --workspace: exit 0
    • cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1427 passed, 0 failed, 46 ignored (dxil::core_tests::f16_packed_attributes_interpolate_per_half, recomp::attribute_tests::f16_packed_attributes, recomp::attribute_tests::f16_packed_params, and GPU recomp::tests::gpu_mesh_f16_packed_params all pass)
    • SKIPPED: 26 (wave64-only GPU tests, #1426 wave32 f16/cvt refusals, heap_window_out_of_memory_falls_back_to_the_switch_form, pso_measurement_compiles_an_exact_synthetic_record)
  • Machine 2: NVIDIA GeForce RTX 2080 SUPER (driver 32.0.16.1088), AMD Ryzen 5 5600X, 16 GB RAM, Windows 11 Pro build 26200, rustc 1.99.1 (stable-x86_64-pc-windows-msvc), Windows SDK 10.0.26100 DXC 1.8.2502.11, debug build (XCL_ADAPTER=NVIDIA)
    • cargo build --workspace: exit 0
    • cargo test --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1427 passed, 0 failed, 46 ignored (all 4 f16 attribute/GPU tests pass)
    • SKIPPED: 29 (same 26 as Machine 1 plus 3 requiring d3d12SDKLayers.dll)

Not tested

  • Retail title / scripts/smoke.ps1 runs
  • Release builds (--release)
  • AMD / Intel GPUs, native wave64, Linux / Wine / vkd3d-proton

AI use
Ran via Samaritan:

  • Google Antigravity CLI (Claude Opus 5.5 (High)): built the branch and ran the workspace test suite on both NVIDIA machines.
  • Google Antigravity CLI (Gemini 4 Neon (High)): coordinated the runs and wrote this test report.

@luckyteagirl luckyteagirl 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.

gpu/recomp/mod.rs:500: ps_f16_slot falls back to any element at the register when its mask excludes the requested half. That makes an absent packed component read the PC producer's value instead of zero. The new f16_packed_attributes_interpolate_per_half fixture already requests TEXCOORD1.w and expects zero, but its PC VS writes zero there, so it cannot distinguish the paths.

On the exact head 3bc875816e45550c3aaa6d44da3b3922b82d18e3, I changed only that fixture's PC VS TEXCOORD1.w from 0.0 to 0.75 (and put the direct PS pair first for a second run), leaving the expected zero unchanged. With XCL_ADAPTER=6800M, XCL_REQUIRE_GPU=1, the focused test failed in both separate runs: PC VS + HLSL PS and PC VS + direct PS each returned 0.75 for the absent component at pixel (0,0), expected 0.0 (exit 101, 1 failed/1,327 filtered each). The HLSL path indexes component 3 and direct DXIL loads that column. Could the lookup return None for an undeclared half and retain the strengthened fixture so both translators take their zero path?

This is a focused modified-fixture GPU result, not a retail-title run or full-suite result. AI-assisted review with Codex.

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.

7 participants