Recompiler: translate v_div_fixup_f16 in both backends #1915

Manually merged
github merged 1 commit from gh-pr/1915/head into gh-pr/1915/base 2026-11-26 05:09:26 +00:00
Owner

@⁠oni-swr on GitHub · 2026-11-24 23:03 UTC · original
oni-swr:recompiler/div-fixup-f16 → main · +14 −1 · 4 files · 1 commits · merged 2026-11-25 02:01 UTC

v_div_fixup_f16 (VOP3: quotient, denominator, numerator as f16) had no case in the HLSL emitter or in the direct-DXIL lowering, so a program using it was reported unsupported. It is v_div_fixup_f32 on half operands; both backends now reuse their existing div_fixup helper and round through the normal f16 result path (modifiers, op_sel and MODE rounding come with it). No open or closed PR touches it (searched div_fixup, f16); the neighbouring v_qsad/v_mqsad (#909, closed) and s_quadmask (#814, #1473) are not touched.

What is in it

  • gpu/recomp/emit.rs: v_div_fixup_f16 in the f16 rounded-op list and the f16 match arm.
  • gpu/dxil/lower_wide.rs, gpu/dxil/lower.rs: the same in the direct-DXIL lowering and its f16 rounding list.
  • gpu/recomp/tests.rs: div_fixup_f16_instruction – translation is complete and emits div_fixup over the three f16 sources. It fails on main (t.complete() is false) and passes with the change.

Tested

  • AMD Radeon RX 7800 XT (driver 32.0.31035.1003), Ryzen 7 5700X3D, Windows 11 build 26200, Rust 1.100.0 MSVC (debug for tests, release for scripts/smoke.ps1).
  • cargo test -p xcl --lib div_fixup_f16 -- --nocapture (XCL_ADAPTER="RX 7800 XT"): 1 passed, 0 failed (also verified on main with only the test added: 0 passed, 1 failed).
  • cargo test -p xcl --lib gpu::recomp:: -- --test-threads=4 f16 (XCL_ADAPTER="RX 7800 XT"): 266 passed, 0 failed, 18 ignored (6 SKIPPED lines: 4 in f16_programs_on_the_gpu and 2 in f32_programs_on_the_gpu for refused #1426 per-lane ops).
  • Full workspace on RX 7800 XT (XCL_ADAPTER="RX 7800 XT"):
    • cargo test --workspace --locked -- --test-threads=4 (lib): 926 passed, 1 failed, 25 ignored (6 SKIPPED lines above). The 1 failure is gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 722: res[30] = 0x1, CPU 0x7fffffff, an unrelated switch/waveReadLaneFirst fuzz case).
    • cargo test --workspace --locked --test '*' --bins -- --test-threads=4: 49 passed, 0 failed, 20 ignored (1 SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows; all e2e tests pass on hardware GPU).
  • Earlier WARP run (XCL_ADAPTER=warp, debug): cargo test --workspace --locked --no-fail-fast -- --test-threads=4: 974 passed, 2 failed (e2e WARP crashes), 45 ignored, 260 SKIPPED lines; cargo clippy -p xcl --all-targets --locked -- -D warnings had 732 pre-existing errors on main and with this change, none in the changed lines.

Regression run

scripts/smoke.ps1 -Game <retail title> -Seconds 60 with XCL_ADAPTER="RX 7800 XT", release builds from clean trees on main (689f2db477c3) and PR head (74fe4c2b4935).

main:

xcl-smoke v1
commit: 689f2db477c3c062cf162649781640ef8a977c18
gpu: AMD Radeon RX 7800 XT
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1587 (PresentX 1587)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14956 MB

PR:

xcl-smoke v1
commit: 74fe4c2b4935007dc6848176488d2d4508621145
gpu: AMD Radeon RX 7800 XT
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1575 (PresentX 1575)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15090 MB

PR vs main: 1575 / 1587 frames (99.2 %), peak commit 15090 / 14956 MB (100.9 %), 0 device removals, 0 crashes.

Not tested

  • No per-instruction GPU readback test of v_div_fixup_f16 result values (the added test checks HLSL translation and completeness); whether the retail title in the smoke run executes v_div_fixup_f16 was not verified.
  • NVIDIA GPUs and non-RX 7800 XT hardware.

AI use

  • Claude Code with Claude Opus 5.5 and Claude Sonnet 5.5: found the gap by diffing the ISA spec against both backends, wrote the change and test, ran initial validation, wrote the initial description.
  • T3 Code with Gemini 4 Neon: ran the RX 7800 XT tests and scripts/smoke.ps1 regression pair, updated the description.
**@⁠oni-swr** on GitHub · 2026-11-24 23:03 UTC · [original](https://github.com/xcl-dev/xcl/pull/1915) `oni-swr:recompiler/div-fixup-f16` → `main` · +14 −1 · 4 files · 1 commits · merged 2026-11-25 02:01 UTC `v_div_fixup_f16` (VOP3: quotient, denominator, numerator as f16) had no case in the HLSL emitter or in the direct-DXIL lowering, so a program using it was reported unsupported. It is `v_div_fixup_f32` on half operands; both backends now reuse their existing `div_fixup` helper and round through the normal f16 result path (modifiers, op_sel and MODE rounding come with it). No open or closed PR touches it (searched `div_fixup`, `f16`); the neighbouring `v_qsad`/`v_mqsad` (#909, closed) and `s_quadmask` (#814, #1473) are not touched. **What is in it** - `gpu/recomp/emit.rs`: `v_div_fixup_f16` in the f16 rounded-op list and the f16 match arm. - `gpu/dxil/lower_wide.rs`, `gpu/dxil/lower.rs`: the same in the direct-DXIL lowering and its f16 rounding list. - `gpu/recomp/tests.rs`: `div_fixup_f16_instruction` – translation is complete and emits `div_fixup` over the three f16 sources. It fails on main (`t.complete()` is false) and passes with the change. **Tested** - AMD Radeon RX 7800 XT (driver 32.0.31035.1003), Ryzen 7 5700X3D, Windows 11 build 26200, Rust 1.100.0 MSVC (debug for tests, release for `scripts/smoke.ps1`). - `cargo test -p xcl --lib div_fixup_f16 -- --nocapture` (`XCL_ADAPTER="RX 7800 XT"`): 1 passed, 0 failed (also verified on main with only the test added: 0 passed, 1 failed). - `cargo test -p xcl --lib gpu::recomp:: -- --test-threads=4 f16` (`XCL_ADAPTER="RX 7800 XT"`): 266 passed, 0 failed, 18 ignored (6 `SKIPPED` lines: 4 in `f16_programs_on_the_gpu` and 2 in `f32_programs_on_the_gpu` for refused `#1426` per-lane ops). - Full workspace on RX 7800 XT (`XCL_ADAPTER="RX 7800 XT"`): - `cargo test --workspace --locked -- --test-threads=4` (lib): 926 passed, 1 failed, 25 ignored (6 `SKIPPED` lines above). The 1 failure is `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1` (`seed 722: res[30] = 0x1, CPU 0x7fffffff`, an unrelated `switch`/`waveReadLaneFirst` fuzz case). - `cargo test --workspace --locked --test '*' --bins -- --test-threads=4`: 49 passed, 0 failed, 20 ignored (1 `SKIPPED`: `heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows`; all e2e tests pass on hardware GPU). - Earlier WARP run (`XCL_ADAPTER=warp`, debug): `cargo test --workspace --locked --no-fail-fast -- --test-threads=4`: 974 passed, 2 failed (`e2e` WARP crashes), 45 ignored, 260 `SKIPPED` lines; `cargo clippy -p xcl --all-targets --locked -- -D warnings` had 732 pre-existing errors on main and with this change, none in the changed lines. **Regression run** `scripts/smoke.ps1 -Game <retail title> -Seconds 60` with `XCL_ADAPTER="RX 7800 XT"`, release builds from clean trees on `main` (`689f2db477c3`) and PR head (`74fe4c2b4935`). main: ``` xcl-smoke v1 commit: 689f2db477c3c062cf162649781640ef8a977c18 gpu: AMD Radeon RX 7800 XT title: 2c508222 seconds: 60 exit: 0x0 frames shown: 1587 (PresentX 1587) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14956 MB ``` PR: ``` xcl-smoke v1 commit: 74fe4c2b4935007dc6848176488d2d4508621145 gpu: AMD Radeon RX 7800 XT title: 2c508222 seconds: 60 exit: 0x0 frames shown: 1575 (PresentX 1575) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15090 MB ``` PR vs `main`: 1575 / 1587 frames (99.2 %), peak commit 15090 / 14956 MB (100.9 %), 0 device removals, 0 crashes. **Not tested** - No per-instruction GPU readback test of `v_div_fixup_f16` result values (the added test checks HLSL translation and completeness); whether the retail title in the smoke run executes `v_div_fixup_f16` was not verified. - NVIDIA GPUs and non-RX 7800 XT hardware. **AI use** - Claude Code with Claude Opus 5.5 and Claude Sonnet 5.5: found the gap by diffing the ISA spec against both backends, wrote the change and test, ran initial validation, wrote the initial description. - T3 Code with Gemini 4 Neon: ran the RX 7800 XT tests and `scripts/smoke.ps1` regression pair, updated the description.
v_div_fixup_f16 (VOP3, quotient / denominator / numerator in f16) had no
case in the HLSL emitter or in the direct-DXIL lowering, so any program
using it was reported as unsupported and fell back. It is v_div_fixup_f32
on half operands: both backends now reuse their existing div_fixup helper
and round the result to f16 through the usual f16 result path.

The CPU test translates the instruction and checks it is complete and
emits div_fixup over the three f16 sources; it fails without the change.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:09:24 +00:00
github manually merged commit 74fe4c2b49 into gh-pr/1915/base 2026-11-26 05:09:26 +00:00
Author
Owner

@⁠frenziedcoder on GitHub · 2026-11-25 01:22 UTC · original

NVIDIA test report for 74fe4c2: no new test failures (the 4 that fail also fail on 689f2db), its own test div_fixup_f16_instruction passes, and a clean smoke pair on the retail title (1652 vs 1657 frames).

Tested

  • NVIDIA GeForce RTX 5080 16 GB (driver 617.14, 32-lane waves), AMD Ryzen 7 9800X3D, 64 GB, Windows 11 Pro 25H2 (26200.9974), rustc 1.100.0 stable-x86_64-pc-windows-msvc, DXC 1.8.2502.11 (SDK 10.0.26100.0). Exact head 74fe4c2b4935007dc6848176488d2d4508621145, no local changes.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4 (debug): 972 passed, 4 failed, 45 ignored; the PR's own test div_fixup_f16_instruction passes. SKIPPED: gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu (no wave64), gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu (no wave64), gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu (no wave64), gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu (no wave64), gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu (no wave64), gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu (f16 arithmetic, wave64: no wave64), gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu (f16 packed, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 arithmetic, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 compares, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 conversions, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 rounding, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 three-source, wave64: no wave64), gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu (f32 transcendentals, wave64: no wave64), gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu (f64, wave64: no wave64), gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu (integer arithmetic, wave64: no wave64), gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu (integer carries, wave64: no wave64), gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu_wave32_program_in_wave64_hardware (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • The 4 failures are fuzz_validate_and_gpu_0, fuzz_validate_and_gpu_1, fuzz_validate_and_gpu_2, fuzz_validate_and_gpu_3 in gpu::dxil::fuzz_tests. They fail the same way on the base 689f2db here (0x8007000E from CreateComputePipelineState on seeds 70, 545, 1019 and 1507, the NVIDIA refusal @⁠PHeitor1 reported on #1679), so this PR adds no failure.
  • test_title_draws_with_a_root_signature_under_the_debug_layer reports ok, but this machine has no D3D12 debug layer (debug layer requested but unavailable … (0x887A002D)), so it ran without the layer and is no evidence either way.

Regression run (scripts/smoke.ps1 -Seconds 60, release, the retail title of #505 at its start screen; XCL_PSO_PRELOAD=0 for both builds, because this machine's preload list holds the program of #1307)

base (689f2db, this PR's merge base with main):

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

this PR:

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

Not tested: the world load (the smoke runs stop at the start screen, so code that only runs later is not exercised there); AMD.

AI use: Claude Code (Claude Opus 5.5) built and ran the tests and smoke runs on my machine and wrote this report; I checked it.

**@⁠frenziedcoder** on GitHub · 2026-11-25 01:22 UTC · [original](https://github.com/xcl-dev/xcl/pull/1915#issuecomment-7149476990) **NVIDIA test report for `74fe4c2`: no new test failures (the 4 that fail also fail on `689f2db`), its own test `div_fixup_f16_instruction` passes, and a clean smoke pair on the retail title (1652 vs 1657 frames).** **Tested** - NVIDIA GeForce RTX 5080 16 GB (driver 617.14, 32-lane waves), AMD Ryzen 7 9800X3D, 64 GB, Windows 11 Pro 25H2 (26200.9974), rustc 1.100.0 `stable-x86_64-pc-windows-msvc`, DXC 1.8.2502.11 (SDK 10.0.26100.0). Exact head `74fe4c2b4935007dc6848176488d2d4508621145`, no local changes. - `cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4` (debug): **972 passed, 4 failed, 45 ignored**; the PR's own test `div_fixup_f16_instruction` passes. SKIPPED: `gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu` (no wave64), `gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu` (no wave64), `gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu` (no wave64), `gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu` (no wave64), `gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu` (no wave64), `gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu` (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))), `gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu` (f16 arithmetic, wave64: no wave64), `gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu` (f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))), `gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu` (f16 packed, wave64: no wave64), `gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu` (f32 arithmetic, wave64: no wave64), `gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu` (f32 compares, wave64: no wave64), `gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu` (f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))), `gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu` (f32 conversions, wave64: no wave64), `gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu` (f32 rounding, wave64: no wave64), `gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu` (f32 three-source, wave64: no wave64), `gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu` (f32 transcendentals, wave64: no wave64), `gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu` (f64, wave64: no wave64), `gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu` (integer arithmetic, wave64: no wave64), `gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu` (integer carries, wave64: no wave64), `gpu_geometry_wave32_prefix_count_over_a_mask` (no wave64), `gpu_wave32_program_in_wave64_hardware` (no wave64), `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - The 4 failures are `fuzz_validate_and_gpu_0`, `fuzz_validate_and_gpu_1`, `fuzz_validate_and_gpu_2`, `fuzz_validate_and_gpu_3` in `gpu::dxil::fuzz_tests`. They fail the same way on the base `689f2db` here (`0x8007000E` from `CreateComputePipelineState` on seeds 70, 545, 1019 and 1507, the NVIDIA refusal @⁠PHeitor1 reported on #1679), so this PR adds no failure. - `test_title_draws_with_a_root_signature_under_the_debug_layer` reports ok, but this machine has no D3D12 debug layer (`debug layer requested but unavailable … (0x887A002D)`), so it ran without the layer and is no evidence either way. **Regression run** (`scripts/smoke.ps1 -Seconds 60`, release, the retail title of #505 at its start screen; `XCL_PSO_PRELOAD=0` for both builds, because this machine's preload list holds the program of #1307) base (`689f2db`, this PR's merge base with `main`): ``` xcl-smoke v1 commit: 689f2db477c3c062cf162649781640ef8a977c18 gpu: NVIDIA GeForce RTX 5080 title: 16b5e5d4 seconds: 60 exit: 0x0 frames shown: 1657 (PresentX 1657) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14602 MB ``` this PR: ``` xcl-smoke v1 commit: 74fe4c2b4935007dc6848176488d2d4508621145 gpu: NVIDIA GeForce RTX 5080 title: 16b5e5d4 seconds: 60 exit: 0x0 frames shown: 1652 (PresentX 1652) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14607 MB ``` **Not tested:** the world load (the smoke runs stop at the start screen, so code that only runs later is not exercised there); AMD. *AI use: Claude Code (Claude Opus 5.5) built and ran the tests and smoke runs on my machine and wrote this report; I checked it.*
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 02:24 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 02:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/1915#issuecomment-7150688677) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
This discussion has been locked. Commenting is limited to contributors.
No description provided.