Recompiler: add the legacy FMA zero product in direct DXIL #2309

Closed
github-bot wants to merge 1 commit from gh-pr/2309/head into gh-pr/2309/base
Owner

@⁠philip-roy-jones on GitHub · 2026-11-25 13:32 UTC · original
philip-roy-jones:xcl-pool-1-960f13fceb34 → main · +65 −4 · 4 files · 1 commits · closed without merging

Part of #679. Direct DXIL returned the addend unchanged when either legacy FMA factor was zero. A negative-zero addend needs to become positive zero unless the shader rounds toward negative infinity. #670 covers the HLSL emitter. Direct DXIL claim in #1269

What is in it

  • The two direct DXIL lowering paths use an integer comparison to recognize the negative-zero addend. A GPU test exercises both instructions with signed zeros, finite values, infinities and NaN in the default mode and all four run-time rounding modes.

Tested

  • Main 568e7db and head c33d6964588f00b9992159732f5bff40fc2f3f8d. Radeon RX 580, driver 31.0.21925.1001, native wave64, Ryzen 7 7700X, Windows 11 Pro 26200, MSVC Rust 1.100.0, DXC 1.8.2502.11. Debug workspace tests and release shader measurements and smoke runs.
  • xcl-gpu run cargo test -p xcl --lib gpu_direct_legacy_fma_zero_product -- --nocapture failed before the fix with 0x80000000 instead of 0x00000000. On head it reported 1 passed, 0 failed, 0 ignored with 0 skipped. The direct-rounding module reported 7 passed, 0 failed, 0 ignored with 0 skipped.
  • Release probe, 80 output words per revision. Main had 32 wrong and head had 0. Median CPU translation time in milliseconds, main → head, was 0.3496 → 0.2085 for the default-mode kernel and 0.5244 → 0.3235 with a run-time MODE write. Each used 5 warm-ups and 101 uncached kernel::translate calls. Validation and GPU readback followed timing.
  • cargo build --workspace, cargo build --release -p xcl and xcl-gpu run cargo test --workspace --no-fail-fast -- --test-threads=4. The harness includes reported skips in the passed column.
Run Passed Failed Ignored Reported SKIPPED Filtered
RX 580, main 1,045 109 46 63 0
RX 580, head 1,045 110 46 63 0
WARP, head 1,154 1 46 173 0
WARP, head with CI filter 1,154 0 46 173 1

All 109 parent failures recurred by name. In the full head suite the new test also received DXGI_ERROR_DEVICE_REMOVED at pipeline creation after the device was suspended. It passed on a fresh device. WARP's single failure was test_title_runs_and_game_folder_is_untouched, the test excluded by the CI filter. It passed on the RX 580.

RX 580 tests reporting SKIPPED on head (63)

D3D12 device unavailable after a driver error (2)

shaders::pipeline_cap_tests::stale_blob_cannot_bypass_the_offline_pipeline_cap
shaders::tests::pso_measurement_compiles_an_exact_synthetic_record

no GPU (13)

gpu::recomp::heap_window_tests::gpu_raw_window_view_reaches_its_top
gpu::texture::tests::gpu_console_textures_upload_every_mip_and_slice
gpu::texture::tests::gpu_large_mixed_upload_keeps_tight_staging_and_exact_pixels
gpu::texture::tests::gpu_upload_batches_reuse_the_queues_upload_buffer
hle::d3d12x::alloc_pool::tests::a_recording_outlives_the_reset_of_the_titles_allocator
hle::d3d12x::bind::tests::execute_indirect_reads_the_arguments_written_before_it
hle::d3d12x::device_x::tests::gpu_depth_buffer_created_for_unordered_access_is_placed
hle::d3d12x::late_release::tests::a_held_resource_goes_when_the_queue_is_past_its_batch
hle::d3d12x::list_x::tests::a_new_list_takes_no_copy_scratch_of_an_earlier_one
hle::d3d12x::list_x::tests::an_internal_wait_is_listed_until_its_fence_reaches_the_value
hle::d3d12x::list_x::tests::copy_scratch_budget_counts_resources_until_gpu_completion
hle::d3d12x::real::console_format_query_tests::gpu_placed_console_depth_target_with_clear_value
hle::d3d12x::shader_cache_session::tests::rejected_create_shader_cache_session_falls_back_to_working_in_memory_session

no GPU / DXC / mesh shaders (1)

gpu::dxil::geometry_tests::gpu_geometry_direct_records

no GPU with 32-lane waves (24)

gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu
gpu::recomp::lower::tests::a_compute_program_agrees_with_the_hlsl_path_on_the_gpu
gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu
gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu
gpu::recomp::lower::tests::the_lowering_agrees_with_the_hlsl_path_on_the_gpu
gpu::recomp::lower::tests::the_split_form_agrees_with_the_wave64_lowering_on_the_gpu
gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu
gpu::recomp::lower_dxil::tests::a_branch_on_a_mixed_mask_matches_the_hlsl_path_on_the_gpu
gpu::recomp::lower_dxil::tests::a_bridged_instruction_may_write_to_the_entry_block
gpu::recomp::lower_dxil::tests::a_bridged_v_cmpx_keeps_the_lanes_outside_exec_out
gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu
gpu::recomp::lower_dxil::tests::a_per_lane_compute_program_runs_on_the_gpu
gpu::recomp::lower_dxil::tests::a_per_lane_program_with_four_memory_windows_runs_on_the_gpu
gpu::recomp::lower_dxil::tests::coalesced_foreign_runs_agree_on_the_gpu
gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu
gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu
gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu
gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu
gpu::recomp::lower_dxil::tests::gpu_frexp_exp_f32_denorm_per_lane
gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu
gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu
gpu::recomp::lower_dxil::tests::native_wave_branches_on_the_gpu
gpu::recomp::lower_dxil::tests::per_lane_kernels_run_on_the_gpu
gpu::recomp::lower_dxil::tests::the_runtime_path_takes_the_split_form

no heap windows (1)

heap_window_out_of_memory_falls_back_to_the_switch_form

no mesh shaders (5)

gpu::dxil::graphics::tests::emitted_ms_primitive_attribute_reaches_the_pixel_shader
gpu::dxil::graphics::tests::emitted_ms_ps_draw_a_triangle
gpu::recomp::tests::gpu_geometry_mode_es_gs_strip
gpu::recomp::tests::gpu_geometry_mode_es_gs_strip_with_branches
gpu::recomp::tests::gpu_mesh_mode_two_passes

no wave32 (16)

gpu::dxil::core_tests::s_setreg_b32_mode_bit3_does_not_underflow
gpu::dxil::ops_tests::approximate_float_unary_ops_are_within_tolerance
gpu::dxil::ops_tests::derivatives_in_compute_run
gpu::dxil::ops_tests::doubles_match_cpu
gpu::dxil::ops_tests::exact_float_unary_ops_match_cpu
gpu::dxil::ops_tests::float_binary_tertiary_and_half_conversions_match_cpu
gpu::dxil::ops_tests::groupshared_barrier_and_atomics_run
gpu::dxil::ops_tests::half_precision_overloads_run
gpu::dxil::ops_tests::int64_bit_ops_match_cpu
gpu::dxil::ops_tests::integer_ops_match_cpu
gpu::dxil::ops_tests::raw_and_structured_buffer_atomics_run
gpu::dxil::ops_tests::texture_ops_run
gpu::dxil::ops_tests::typed_buffer_ops_run
gpu::dxil::ops_tests::uaddc_and_usubb_match_cpu
gpu::dxil::ops_tests::uav_array_3d_stores_loads_and_texture_atomics_run
gpu::dxil::ops_tests::wave_ops_match_cpu

no wave32 / wave64 (1)

gpu::dxil::tests::blocks_are_written_in_reverse_post_order

Regression run

The same 60-second offline title run used the in-place release executable on each clean revision. Both started from identical copies of 737 main-built DXIL cache files and fresh title data roots, with XCL_DIRECT_DXIL=1, XCL_ASYNC_PSO=0, XCL_PSO_PRELOAD=0, XCL_TRANSLATED_CACHE=0 and XCL_PSO_DISK_CACHE=0.

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: Radeon RX 580 Series
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1651 (PresentX 1651)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 30639 MB
xcl-smoke v1
commit: c33d6964588f00b9992159732f5bff40fc2f3f8d
gpu: Radeon RX 580 Series
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1575 (PresentX 1575)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 27566 MB

Not tested

Console hardware, NVIDIA and Intel GPUs, optional game-data fixtures, or world loading. The retail smoke did not measure which instructions executed or the title's shader compile time.

AI use

Codex with gpt-6.2-astra, max reasoning, wrote the fix, GPU test and description, ran verification, and reviewed the full diff on Philip's behalf.

**@⁠philip-roy-jones** on GitHub · 2026-11-25 13:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/2309) `philip-roy-jones:xcl-pool-1-960f13fceb34` → `main` · +65 −4 · 4 files · 1 commits · closed without merging Part of #679. Direct DXIL returned the addend unchanged when either legacy FMA factor was zero. A negative-zero addend needs to become positive zero unless the shader rounds toward negative infinity. #670 covers the HLSL emitter. [Direct DXIL claim in #1269](https://git.gtahub.st/github/xcl-dev--xcl/issues/1269) **What is in it** - The two direct DXIL lowering paths use an integer comparison to recognize the negative-zero addend. A GPU test exercises both instructions with signed zeros, finite values, infinities and NaN in the default mode and all four run-time rounding modes. **Tested** - Main `568e7db` and head `c33d6964588f00b9992159732f5bff40fc2f3f8d`. Radeon RX 580, driver 31.0.21925.1001, native wave64, Ryzen 7 7700X, Windows 11 Pro 26200, MSVC Rust 1.100.0, DXC 1.8.2502.11. Debug workspace tests and release shader measurements and smoke runs. - `xcl-gpu run cargo test -p xcl --lib gpu_direct_legacy_fma_zero_product -- --nocapture` failed before the fix with `0x80000000` instead of `0x00000000`. On head it reported 1 passed, 0 failed, 0 ignored with 0 skipped. The direct-rounding module reported 7 passed, 0 failed, 0 ignored with 0 skipped. - Release probe, 80 output words per revision. Main had 32 wrong and head had 0. Median CPU translation time in milliseconds, main → head, was 0.3496 → 0.2085 for the default-mode kernel and 0.5244 → 0.3235 with a run-time MODE write. Each used 5 warm-ups and 101 uncached `kernel::translate` calls. Validation and GPU readback followed timing. - `cargo build --workspace`, `cargo build --release -p xcl` and `xcl-gpu run cargo test --workspace --no-fail-fast -- --test-threads=4`. The harness includes reported skips in the passed column. | Run | Passed | Failed | Ignored | Reported SKIPPED | Filtered | | --- | ---: | ---: | ---: | ---: | ---: | | RX 580, main | 1,045 | 109 | 46 | 63 | 0 | | RX 580, head | 1,045 | 110 | 46 | 63 | 0 | | WARP, head | 1,154 | 1 | 46 | 173 | 0 | | WARP, head with CI filter | 1,154 | 0 | 46 | 173 | 1 | All 109 parent failures recurred by name. In the full head suite the new test also received `DXGI_ERROR_DEVICE_REMOVED` at pipeline creation after the device was suspended. It passed on a fresh device. WARP's single failure was `test_title_runs_and_game_folder_is_untouched`, the test excluded by the CI filter. It passed on the RX 580. <details> <summary>RX 580 tests reporting SKIPPED on head (63)</summary> **D3D12 device unavailable after a driver error** (2) ~~~text shaders::pipeline_cap_tests::stale_blob_cannot_bypass_the_offline_pipeline_cap shaders::tests::pso_measurement_compiles_an_exact_synthetic_record ~~~ **no GPU** (13) ~~~text gpu::recomp::heap_window_tests::gpu_raw_window_view_reaches_its_top gpu::texture::tests::gpu_console_textures_upload_every_mip_and_slice gpu::texture::tests::gpu_large_mixed_upload_keeps_tight_staging_and_exact_pixels gpu::texture::tests::gpu_upload_batches_reuse_the_queues_upload_buffer hle::d3d12x::alloc_pool::tests::a_recording_outlives_the_reset_of_the_titles_allocator hle::d3d12x::bind::tests::execute_indirect_reads_the_arguments_written_before_it hle::d3d12x::device_x::tests::gpu_depth_buffer_created_for_unordered_access_is_placed hle::d3d12x::late_release::tests::a_held_resource_goes_when_the_queue_is_past_its_batch hle::d3d12x::list_x::tests::a_new_list_takes_no_copy_scratch_of_an_earlier_one hle::d3d12x::list_x::tests::an_internal_wait_is_listed_until_its_fence_reaches_the_value hle::d3d12x::list_x::tests::copy_scratch_budget_counts_resources_until_gpu_completion hle::d3d12x::real::console_format_query_tests::gpu_placed_console_depth_target_with_clear_value hle::d3d12x::shader_cache_session::tests::rejected_create_shader_cache_session_falls_back_to_working_in_memory_session ~~~ **no GPU / DXC / mesh shaders** (1) ~~~text gpu::dxil::geometry_tests::gpu_geometry_direct_records ~~~ **no GPU with 32-lane waves** (24) ~~~text gpu::recomp::lower::tests::a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu gpu::recomp::lower::tests::a_compute_program_agrees_with_the_hlsl_path_on_the_gpu gpu::recomp::lower::tests::coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu gpu::recomp::lower::tests::cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu gpu::recomp::lower::tests::the_lowering_agrees_with_the_hlsl_path_on_the_gpu gpu::recomp::lower::tests::the_split_form_agrees_with_the_wave64_lowering_on_the_gpu gpu::recomp::lower::tests::the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu gpu::recomp::lower_dxil::tests::a_branch_on_a_mixed_mask_matches_the_hlsl_path_on_the_gpu gpu::recomp::lower_dxil::tests::a_bridged_instruction_may_write_to_the_entry_block gpu::recomp::lower_dxil::tests::a_bridged_v_cmpx_keeps_the_lanes_outside_exec_out gpu::recomp::lower_dxil::tests::a_per_lane_2d_or_3d_group_runs_on_the_gpu gpu::recomp::lower_dxil::tests::a_per_lane_compute_program_runs_on_the_gpu gpu::recomp::lower_dxil::tests::a_per_lane_program_with_four_memory_windows_runs_on_the_gpu gpu::recomp::lower_dxil::tests::coalesced_foreign_runs_agree_on_the_gpu gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu gpu::recomp::lower_dxil::tests::gpu_frexp_exp_f32_denorm_per_lane gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu gpu::recomp::lower_dxil::tests::native_wave_branches_on_the_gpu gpu::recomp::lower_dxil::tests::per_lane_kernels_run_on_the_gpu gpu::recomp::lower_dxil::tests::the_runtime_path_takes_the_split_form ~~~ **no heap windows** (1) ~~~text heap_window_out_of_memory_falls_back_to_the_switch_form ~~~ **no mesh shaders** (5) ~~~text gpu::dxil::graphics::tests::emitted_ms_primitive_attribute_reaches_the_pixel_shader gpu::dxil::graphics::tests::emitted_ms_ps_draw_a_triangle gpu::recomp::tests::gpu_geometry_mode_es_gs_strip gpu::recomp::tests::gpu_geometry_mode_es_gs_strip_with_branches gpu::recomp::tests::gpu_mesh_mode_two_passes ~~~ **no wave32** (16) ~~~text gpu::dxil::core_tests::s_setreg_b32_mode_bit3_does_not_underflow gpu::dxil::ops_tests::approximate_float_unary_ops_are_within_tolerance gpu::dxil::ops_tests::derivatives_in_compute_run gpu::dxil::ops_tests::doubles_match_cpu gpu::dxil::ops_tests::exact_float_unary_ops_match_cpu gpu::dxil::ops_tests::float_binary_tertiary_and_half_conversions_match_cpu gpu::dxil::ops_tests::groupshared_barrier_and_atomics_run gpu::dxil::ops_tests::half_precision_overloads_run gpu::dxil::ops_tests::int64_bit_ops_match_cpu gpu::dxil::ops_tests::integer_ops_match_cpu gpu::dxil::ops_tests::raw_and_structured_buffer_atomics_run gpu::dxil::ops_tests::texture_ops_run gpu::dxil::ops_tests::typed_buffer_ops_run gpu::dxil::ops_tests::uaddc_and_usubb_match_cpu gpu::dxil::ops_tests::uav_array_3d_stores_loads_and_texture_atomics_run gpu::dxil::ops_tests::wave_ops_match_cpu ~~~ **no wave32 / wave64** (1) ~~~text gpu::dxil::tests::blocks_are_written_in_reverse_post_order ~~~ </details> **Regression run** The same 60-second offline title run used the in-place release executable on each clean revision. Both started from identical copies of 737 main-built DXIL cache files and fresh title data roots, with `XCL_DIRECT_DXIL=1`, `XCL_ASYNC_PSO=0`, `XCL_PSO_PRELOAD=0`, `XCL_TRANSLATED_CACHE=0` and `XCL_PSO_DISK_CACHE=0`. ``` xcl-smoke v1 commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb gpu: Radeon RX 580 Series title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1651 (PresentX 1651) presents per 2 s (last 3): 60 60 61 device removals: 0 crashes: 0 peak commit: 30639 MB ``` ``` xcl-smoke v1 commit: c33d6964588f00b9992159732f5bff40fc2f3f8d gpu: Radeon RX 580 Series title: 3c290c16 seconds: 60 exit: 0x0 frames shown: 1575 (PresentX 1575) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 27566 MB ``` **Not tested** Console hardware, NVIDIA and Intel GPUs, optional game-data fixtures, or world loading. The retail smoke did not measure which instructions executed or the title's shader compile time. **AI use** Codex with gpt-6.2-astra, max reasoning, wrote the fix, GPU test and description, ran verification, and reviewed the full diff on Philip's behalf.
A zero multiplicand makes the legacy product positive zero, including with infinity or NaN. Returning the raw addend kept its negative zero sign in three of the four rounding modes. Check the addend bits and preserve negative zero only when rounding down.

Part of #679.

Assisted-by: Codex (gpt-6.2-astra, max reasoning)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:26:39 +00:00
github-bot closed this pull request 2026-11-26 05:26:39 +00:00
Author
Owner

@⁠SlopTart on GitHub · 2026-11-25 14:36 UTC · original

Wine/vkd3d-proton lane: verified, clean.

Tested: head c33d6964, merged onto current origin/main (auto-merge, no conflicts), 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 (--release --locked, --test-threads=2): 143 passed / 3 failed / 1 ignored. The pass delta vs plain origin/main on this rig is exactly +1, the new GPU test from this PR, and it passes: both direct DXIL FMA paths with signed zeros, infinities, NaN and all four run-time rounding modes come out right on RDNA3 under Wine.
  • The 3 failures are the rig's known baseline, unrelated to this change: fuzz seed 1003 of #2115, gpu_nonfused_mad_and_mac_prevent_fma_contraction, gpu_depth_buffer_created_for_unordered_access_is_placed.

Not tested: NVIDIA lane on this PR specifically; 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.

**@⁠SlopTart** on GitHub · 2026-11-25 14:36 UTC · [original](https://github.com/xcl-dev/xcl/pull/2309#issuecomment-7165528815) **Wine/vkd3d-proton lane: verified, clean.** **Tested**: head `c33d6964`, merged onto current `origin/main` (auto-merge, no conflicts), 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 (`--release --locked`, `--test-threads=2`): 143 passed / 3 failed / 1 ignored. The pass delta vs plain `origin/main` on this rig is exactly +1, the new GPU test from this PR, and it passes: both direct DXIL FMA paths with signed zeros, infinities, NaN and all four run-time rounding modes come out right on RDNA3 under Wine. - The 3 failures are the rig's known baseline, unrelated to this change: fuzz seed 1003 of #2115, `gpu_nonfused_mad_and_mac_prevent_fma_contraction`, `gpu_depth_buffer_created_for_unordered_access_is_placed`. **Not tested**: NVIDIA lane on this PR specifically; 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.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.