Skip to content

shader: compile the log2 pixel fixtures with -denorm any - #851

Merged
R0Y00 merged 1 commit into
R0Y00:mainfrom
alvaroolt:shader/log2-denorm-any
Nov 23, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:mainfrom
alvaroolt:shader/log2-denorm-any

Conversation

@alvaroolt

Copy link
Copy Markdown
Contributor

Change

pixel_aot_e64_approx_hardware and pixel_aot_sdwa_unary_hardware fail on an NVIDIA GeForce RTX 5080 because the driver refuses CreateGraphicsPipelineState (E_OUTOFMEMORY) for any pixel shader that uses log2 under -denorm preserve (#828). As agreed in the issue, this switches the denormal mode per fixture, only for the approximate programs that contain log2.

  • tests/pixel_aot_check.py: log2_denorm_mode() returns any when the translated HLSL contains log2( and preserve (F32_DENORM_MODE) otherwise. Before returning any, it asserts that no value the fixture depends on is a binary32 subnormal: the inputs, the intermediate results (the unrounded exp, log and rcp results and their + 0.5, the rounded -A * |B| product and D * D square of the mac channels, the accumulator), the expected values and every wrong reference.
  • This applies to e64_approx and sdwa_unary_exp. sdwa_unary_root and sdwa_unary_exact keep preserve, and an assertion pins that only sdwa_unary_exp switches.
  • Every wrong-reference control is unchanged.
  • docs/experiments.md: the denormal-mode paragraph records the exception next to the existing curve one, with the measured adapters.

The minimal preserve reproduction stays in #828 for a later driver retest.

Fixes #828

This change was AI-assisted (Claude Code); I reviewed the diff and the test results.

Verification

Commit c0f4d9c (rebased on e97090a), dev preset, DXC 1.9.2602.17 (Windows SDK 10.0.26100).

Both modes on the same adapter and driver, one batch per program (10 cases each: 2 right references and 8 wrong references):

Adapter e64_approx, sdwa_unary_exp under preserve the same under any
NVIDIA GeForce RTX 5080 (10de:2c02), driver 32.0.16.2124, hardware every case status=error, Translated pixel pipeline failed (HRESULT 0x8007000e) 2 pass, 8 mismatch for each program
Microsoft Basic Render Driver (WARP), 10.0.26100.9818 2 pass, 8 mismatch for each program 2 pass, 8 mismatch for each program

On the RTX 5080 under the new code, sdwa_unary_root (2 pass, 8 mismatch) and sdwa_unary_exact (2 pass, 10 mismatch) still compile with preserve and pass.

Focused tests:

ctest --preset dev --no-tests=error -R '^pixel_aot_(e64_approx|sdwa_unary)_(hardware|warp)$' -V
  • Before (c3db335, the previous main): pixel_aot_e64_approx_hardware and pixel_aot_sdwa_unary_hardware fail with case=N status=error on every case; both _warp tests pass.
  • After: all four pass.
ctest --preset dev --no-tests=error -R '^pixel_aot_' -j 4

82 of 82 passed on c0f4d9c.

Negative control for the new assertion: log2_denorm_mode() with the least subnormal 0x00000001 among the values, and e64_approx with that value in place of C in a row, both raise AssertionError before any compile. A program without log2 returns preserve regardless of the values.

Other checks:

  • The 24 platform-independent Python checks from .github/workflows/windows.yml: all exit 0 on c0f4d9c.
  • tests/pixel_aot_check.py binary with LLVM 15 llvm-mc (gfx1013): exit 0 on c0f4d9c.
  • Full suite before the rebase (on c3db335): ctest --preset dev --no-tests=error -j 4 and ctest --preset release --no-tests=error -j 4 each give 415 passed, 0 failed of 422.
  • Capability skips, the same 7 in both presets, not counted as passes: bvh_wave64_hardware, bvh_wave64_warp, wave_shuffle_warp, spirv_minlod_hardware, spirv_minlod_levels_hardware, spirv_minlod_warp, spirv_minlod_levels_warp.

Environment: Windows 11 build 26300.9974, VS Build Tools 2026 18.12 (MSVC 14.52.37025), Windows SDK 10.0.26100. The debug layer is unavailable (Graphics Tools not installed).

Evidence and follow-up

No new fixture. The fixtures' inputs and references are unchanged; only the recorded denormal mode of two programs changes.

Assumption: with no binary32 subnormal among the inputs, intermediates and expected values, any and preserve produce the same exported bits for these programs. The assertions check that for every value the fixtures use; they do not measure the shader's internal precision.

Not established: whether older NVIDIA architectures or a later driver accept these pipelines under preserve, and what the console computes. The AMD Radeon integrated GPU that accepts preserve (#828) was not rerun with this change.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

An NVIDIA GeForce RTX 5080 (drivers 32.0.16.2101 and 32.0.16.2124) refuses
CreateGraphicsPipelineState with E_OUTOFMEMORY for any pixel shader that uses
log2 under -denorm preserve, so pixel_aot_e64_approx_hardware and
pixel_aot_sdwa_unary_hardware failed on every case. WARP and an AMD Radeon
integrated GPU accept the same pipelines.

Pick the mode per translated program: any when its HLSL contains log2,
preserve otherwise. Before choosing any, assert that no input, intermediate
result, expected value or wrong reference of the fixture is a binary32
subnormal, so the mode cannot change what it computes or exports. This applies
to e64_approx and sdwa_unary_exp; sdwa_unary_root and sdwa_unary_exact keep
preserve, which an assertion pins. All wrong-reference controls are kept.

Fixes R0Y00#828
@R0Y00
R0Y00 merged commit bd86337 into R0Y00:main Nov 23, 2026
5 checks passed
@alvaroolt
alvaroolt deleted the shader/log2-denorm-any branch November 23, 2026 13:27
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.

pixel_aot_e64_approx_hardware and pixel_aot_sdwa_unary_hardware: NVIDIA refuses PSO creation for log2 under -denorm preserve

2 participants