Recompiler: direct DXIL asks for flushed f32 denormals #1707

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

@⁠MarcosMDev on GitHub · 2026-11-24 19:29 UTC · original
MarcosMDev:dxil-fp32-ftz → main · +24 −4 · 3 files · 1 commits · closed without merging

Part of #1269. The direct backend's entry function carries no fp32-denorm-mode, so the driver may flush or keep f32 denormals per operation. This asks for ftz.

Preventive: I found no wrong result on main itself. On an RTX 4060, a local pass that reads guarded values past their select (not part of this PR) gave wrong v_fmac_f32 + v_xor_b32 results in 65 of 2204 lanes without NaN, against a CPU simulation that flushes denormals. Without the pass, and on the HLSL path, 0. With this attribute, 0 of 1502 in a new random run. These lane counts were measured on c160d86, before #1693 and 0b64aa0, and not repeated. Other passes that remove guards may meet the same.

What is in it

  • gpu/dxil/module.rs: attribute group 5, on the defined (entry) function
  • gpu/dxil/kernel.rs: TRANSLATOR_VERSION 7 (the containers change; main has 6)
  • gpu/dxil/tests.rs: the disassembly has the attribute on the entry function (fails without the change)

Tested

  • RTX 4060 (32.0.16.2101), Ryzen 7 5700X, Windows 11 26200, Rust 1.100.0, DXC 1.9.2609, debug; smoke in release
  • cargo test --workspace -- --test-threads=4: 960 passed, 0 failed, 43 ignored; 23 SKIPPED lines: 18 no wave64, 3 per-lane programs refused (f16 / conversions), pso_measurement_compiles_an_exact_synthetic_record (driver cache cannot be disabled, no Developer Mode), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows)
  • XCL_DIRECT_DXIL=all cargo test -p xcl --lib gpu:: -- --test-threads=4: 441 passed, 0 failed, 19 ignored

Regression run

Both with XCL_DIRECT_DXIL=all, main first. main:

xcl-smoke v1
commit: c4d37bec1bb4286eb373aea963404a23f13401fa
gpu: NVIDIA GeForce RTX 4060
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1592 (PresentX 1592)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14626 MB

This PR:

xcl-smoke v1
commit: 21c653f32bd6797f0d51d2b3aa020ebffcab047a
gpu: NVIDIA GeForce RTX 4060
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1611 (PresentX 1611)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14635 MB

Not tested

  • AMD, Intel, native wave64. Results may change where a driver keeps denormals today.
  • Programs that ask for kept denormals: s_denorm_mode is ignored today, and FSSM float modes are not consulted here.
  • The smoke runs are a basic check: the one log I read (an earlier run of main c160d86) had 14 direct shaders (7 PS, 7 VS), no CS.
  • There is no permanent GPU test of denormal values; the test checks the attribute.

AI use

  • Claude Code, Claude Opus 5.5: wrote the change, the test and this description, and ran the tests and measurements.
**@⁠MarcosMDev** on GitHub · 2026-11-24 19:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/1707) `MarcosMDev:dxil-fp32-ftz` → `main` · +24 −4 · 3 files · 1 commits · closed without merging Part of #1269. The direct backend's entry function carries no `fp32-denorm-mode`, so the driver may flush or keep f32 denormals per operation. This asks for `ftz`. Preventive: I found no wrong result on `main` itself. On an RTX 4060, a local pass that reads guarded values past their `select` (not part of this PR) gave wrong `v_fmac_f32` + `v_xor_b32` results in 65 of 2204 lanes without NaN, against a CPU simulation that flushes denormals. Without the pass, and on the HLSL path, 0. With this attribute, 0 of 1502 in a new random run. These lane counts were measured on `c160d86`, before #1693 and `0b64aa0`, and not repeated. Other passes that remove guards may meet the same. **What is in it** - `gpu/dxil/module.rs`: attribute group 5, on the defined (entry) function - `gpu/dxil/kernel.rs`: `TRANSLATOR_VERSION` 7 (the containers change; `main` has 6) - `gpu/dxil/tests.rs`: the disassembly has the attribute on the entry function (fails without the change) **Tested** - RTX 4060 (32.0.16.2101), Ryzen 7 5700X, Windows 11 26200, Rust 1.100.0, DXC 1.9.2609, debug; smoke in release - `cargo test --workspace -- --test-threads=4`: 960 passed, 0 failed, 43 ignored; 23 SKIPPED lines: 18 no wave64, 3 per-lane programs refused (f16 / conversions), `pso_measurement_compiles_an_exact_synthetic_record` (driver cache cannot be disabled, no Developer Mode), `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows) - `XCL_DIRECT_DXIL=all cargo test -p xcl --lib gpu:: -- --test-threads=4`: 441 passed, 0 failed, 19 ignored **Regression run** Both with `XCL_DIRECT_DXIL=all`, main first. main: ``` xcl-smoke v1 commit: c4d37bec1bb4286eb373aea963404a23f13401fa gpu: NVIDIA GeForce RTX 4060 title: 6ca5cab7 seconds: 60 exit: 0x0 frames shown: 1592 (PresentX 1592) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14626 MB ``` This PR: ``` xcl-smoke v1 commit: 21c653f32bd6797f0d51d2b3aa020ebffcab047a gpu: NVIDIA GeForce RTX 4060 title: 6ca5cab7 seconds: 60 exit: 0x0 frames shown: 1611 (PresentX 1611) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14635 MB ``` **Not tested** - AMD, Intel, native wave64. Results may change where a driver keeps denormals today. - Programs that ask for kept denormals: `s_denorm_mode` is ignored today, and FSSM float modes are not consulted here. - The smoke runs are a basic check: the one log I read (an earlier run of `main` `c160d86`) had 14 direct shaders (7 PS, 7 VS), no CS. - There is no permanent GPU test of denormal values; the test checks the attribute. **AI use** - Claude Code, Claude Opus 5.5: wrote the change, the test and this description, and ran the tests and measurements.
The entry function carried no fp32-denorm-mode, which leaves f32 denormals to the driver. On an RTX 4060, removing guard selects (a local experiment) changed whether v_fmac_f32 results were flushed; with the attribute the results matched a CPU simulation and the HLSL path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:02:12 +00:00
github-bot closed this pull request 2026-11-26 05:02:12 +00:00
Author
Owner

@⁠nnonno91 on GitHub · 2026-11-24 20:11 UTC · original

Native Windows GPU test of 540d9659fbd88f63e60bad310db193c9d48ad323. The direct shader includes the FTZ attribute, and the tested arithmetic cases flush on both AMD and NVIDIA. The same cases already flushed on these drivers at the PR's parent.

Tested

  • Windows 11 25H2 build 26200.9974, Ryzen 7 9800X3D, AMD Radeon(TM) Graphics (32.0.21042.62, native wave64) and NVIDIA GeForce RTX 5090 (32.0.16.1742, split wave64), Rust 1.100.0 MSVC, Windows SDK DXC 1.8.2502.11, debug/test profiles. GPUs selected through XCL_ADAPTER.
  • Clean head, AMD: cargo build --workspace --locked passed. cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-output reported 864 passed, 0 failed, 42 ignored. One pass logged heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows. With XCL_DIRECT_DXIL=all, cargo test --locked -p xcl --lib gpu:: -- --test-threads=4 --show-output reported 370 passed, 0 failed, 19 ignored, no skips.
  • I ran an identical temporary synthetic probe on the head and parent 7ccf774cf0a3f4415ff1940aa2b4b554f08f6a32 on both GPUs. cargo test --locked -p xcl --test ftz_gpu_probe -- --exact denormal_arithmetic_and_raw_bits --test-threads=1 --nocapture reported 1 passed, 0 failed, 0 ignored per invocation, no skips. It emitted RDNA2 V_MUL_F32, V_ADD_F32, and a raw V_MOV_B32 and ran wave32 and the adapter's wave64 form.
  • DXIL validation passed for both translators. Disassembly showed fp32-denorm-mode="ftz" on the head's direct shader. The probe used signed subnormal inputs multiplied by 2^126, signed minimum normal inputs multiplied by 0.5, and two normal operands that cancel to a subnormal sum. Direct DXIL, HLSL default and HLSL -denorm ftz all produced signed zero in 288/288 arithmetic checks per GPU and mode, on both revisions. HLSL -denorm preserve returned the expected nonzero bits in 288/288. All raw bit copies and ordinary products matched their references. The temporary probe was removed from both worktrees.

Not tested

Retail frames, the separate guarded-value optimization mentioned in the description, or explicit RDNA2 denormal mode changes.

AI use

OpenAI Codex (GPT-6 family, exact variant unavailable) wrote the temporary probe, ran the tests, checked the logs, and wrote this report.

**@⁠nnonno91** on GitHub · 2026-11-24 20:11 UTC · [original](https://github.com/xcl-dev/xcl/pull/1707#issuecomment-7143157445) Native Windows GPU test of `540d9659fbd88f63e60bad310db193c9d48ad323`. The direct shader includes the FTZ attribute, and the tested arithmetic cases flush on both AMD and NVIDIA. The same cases already flushed on these drivers at the PR's parent. **Tested** - Windows 11 25H2 build 26200.9974, Ryzen 7 9800X3D, AMD Radeon(TM) Graphics (32.0.21042.62, native wave64) and NVIDIA GeForce RTX 5090 (32.0.16.1742, split wave64), Rust 1.100.0 MSVC, Windows SDK DXC 1.8.2502.11, debug/test profiles. GPUs selected through `XCL_ADAPTER`. - Clean head, AMD: `cargo build --workspace --locked` passed. `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --show-output` reported **864 passed, 0 failed, 42 ignored**. One pass logged `heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows`. With `XCL_DIRECT_DXIL=all`, `cargo test --locked -p xcl --lib gpu:: -- --test-threads=4 --show-output` reported **370 passed, 0 failed, 19 ignored**, no skips. - I ran an identical temporary synthetic probe on the head and parent `7ccf774cf0a3f4415ff1940aa2b4b554f08f6a32` on both GPUs. `cargo test --locked -p xcl --test ftz_gpu_probe -- --exact denormal_arithmetic_and_raw_bits --test-threads=1 --nocapture` reported **1 passed, 0 failed, 0 ignored** per invocation, no skips. It emitted RDNA2 `V_MUL_F32`, `V_ADD_F32`, and a raw `V_MOV_B32` and ran wave32 and the adapter's wave64 form. - DXIL validation passed for both translators. Disassembly showed `fp32-denorm-mode="ftz"` on the head's direct shader. The probe used signed subnormal inputs multiplied by 2^126, signed minimum normal inputs multiplied by 0.5, and two normal operands that cancel to a subnormal sum. Direct DXIL, HLSL default and HLSL `-denorm ftz` all produced signed zero in **288/288 arithmetic checks per GPU and mode**, on both revisions. HLSL `-denorm preserve` returned the expected nonzero bits in **288/288**. All raw bit copies and ordinary products matched their references. The temporary probe was removed from both worktrees. **Not tested** Retail frames, the separate guarded-value optimization mentioned in the description, or explicit RDNA2 denormal mode changes. **AI use** OpenAI Codex (GPT-6 family, exact variant unavailable) wrote the temporary probe, ran the tests, checked the logs, and wrote this report.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 22:09 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 22:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/1707#issuecomment-7145884093) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~23 ignored. Thanks!
Author
Owner

@⁠MarcosMDev on GitHub · 2026-11-25 15:24 UTC · original

Closing: this is preventive, I found no wrong result on main, and it now conflicts. The data is in the description and in #1269 for anyone removing guards.

**@⁠MarcosMDev** on GitHub · 2026-11-25 15:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/1707#issuecomment-7166789616) Closing: this is preventive, I found no wrong result on `main`, and it now conflicts. The data is in the description and in #1269 for anyone removing guards.

Pull request closed

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