Skip to content

Recompiler: direct DXIL asks for flushed f32 denormals - #1707

Open
MarcosMDev wants to merge 1 commit into
xcl-dev:mainfrom
MarcosMDev:dxil-fp32-ftz
Open

MarcosMDev wants to merge 1 commit into
xcl-dev:mainfrom
MarcosMDev:dxil-fp32-ftz

Conversation

@MarcosMDev

@MarcosMDev MarcosMDev commented Nov 24, 2026 •

Copy link
Copy Markdown

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.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
, xcl-dev#1709 and update README

Integrates four new rendering and direct-DXIL PRs on top of c160d86:
- xcl-dev#1679: Direct DXIL geometry mode, MSAA loads, and directed f32 rounding
- xcl-dev#1707: Direct DXIL entry function fp32-denorm-mode=ftz (bumped
  TRANSLATOR_VERSION to 6)
- xcl-dev#1709: pixel shader ordered sections via rasterizer ordered views (ROVs)
- xcl-dev#1705: recover poisoned report crash/write locks instead of dropping report

Verified under GE-Proton11-14 + vkd3d-proton ec20719452e916b:
- Release build (x86_64-pc-windows-msvc): ok (31.38s)
- Proton tests (gpu::dxil::tests::, gpu_ps_ordered_section_*,
  ordered_section_images_*, report::tests): 9 passed, 0 failed, 0 skipped.
@nnonno91

Copy link
Copy Markdown

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.

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 <noreply@anthropic.com>
@MarcosMDev
MarcosMDev marked this pull request as ready for review November 24, 2026 21:36
@ivall ivall added the goal:world-load Bears on the retail title getting past world loading label Nov 24, 2026
@DavidM1911

Copy link
Copy Markdown
Contributor

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

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

Thanks!

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

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants