shader: make the pixel_aot f32 denormal mode explicit and accept NaN by class #357
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/363"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by abilliontokens on 2026-11-21T23:21:49Z.
Change
Refs #312 (owner-approved f32 slice). Makes the pixel_aot draw harness's floating-point contract explicit, in one reviewable behavior:
Explicit f32 denormal mode.
F32_DENORM_MODE = "preserve"records the assumption the CPU references already make (plain Python floats keep binary32 subnormals; the ScarlettSPI_SHADER_PGM_RSRC1.FLOAT_MODEis unmeasured). Every DXC invocation now goes through onecompile_shader()helper that passes the matching-denormflag. DXC accepts-denormonly at shader model 6.2+, so the harness target moves fromps_6_0tops_6_2(the minimum that allows the flag; below the SM 6.5 cap of the oldest in-box WARP the repo targets). f16/f64 modes are not established here, per the approval.Non-folding mode control.
check_denorm_mode_drawexportsv_min_f32/v_max_f32on the least subnormal0x00000001plus av_mul_f32by 1.0 through a new uncompressed f32 export (exp mrt0 v12, v13, v14, v15 done vm; the compressedexport16path quantizes to binary16 and cannot carry f32 subnormals). The program is drawn under both-denorm preserveand-denorm ftzwith mode-matched references: min/max keep0x00000001under preserve and export zero under ftz; the multiply-by-1.0 channel folds to a move and must export identical raw bits in both modes. Negative control: the preserve build must mismatch the ftz reference.NaN-class readback.
check_nan_class_drawadds NaN-producingv_add_f32rows (0x7FC00000,0x7F800001,0xFFC00003). A case-file trailer (one flags byte + 64 per-texel mask bytes) marks channels that expect NaN: the renderer accepts any NaN sign/payload there, logsnan_class … expected=%08x actual=%08xraw words even on pass, and keeps every unmasked channel strict bitwise. Comparison-predicate fixtures are untouched and stay strict. Negative controls fail on every backend: a finite export on a masked channel, and a NaN export on a strict finite channel.Lossless integer readback. Trailer flag bit 0 selects a
R32G32B32A32_UINTrender target;lower(..., integer_export=True)returnsuint4(asuint(...)).check_integer_readback_drawround-tripsv_mov_b32copies of0x7FC00001,0xFFC00003,0x00000001,0x80000000bit-for-bit, bypassing float-RT payload normalization. Negative control: one corrupted expected word must fail.Translator rejects malformed uncompressed exports (duplicate registers, compressed form under
integer_export, instructions after the export); the compressed path's HLSL is byte-identical to before. No-trailer case files keep the original 1280-byte format and behavior, including--check-pixel.One recorded vendor exception. The RTX 5060 Ti (driver 32.0.16.2124) refuses PSO creation for the curve program under
-denorm preserve(E_OUTOFMEMORY); WARP and the RX 9060 XT accept it. A compile-variant probe on that adapter isolated the trigger:ps_6_0no flag,ps_6_2no flag,-denorm ftzand-denorm anyall create the PSO;-denorm preservefails atps_6_2andps_6_5. A surface probe of all 14 fixture programs under preserve found curve the only failure. The curve fixture therefore records its mode explicitly asany(the approval's "record unknown/any as such"); its expected rows contain no binary32 subnormals, so the mode cannot change their exported bits — the harness asserts this mode independence on every expected word (flush_ftz(word) == word) rather than arguing it. Every other fixture, including the preserve/ftz mode control, runs under the recorded modes on all three backends.No overlap with #288: no
v_mad_f32/v_mac_f32lowering is added or changed; existing instruction-specific rules (widen16, explicitisnanpredicates) are retained.Verification
Environment: Windows 11 Pro build 26200.9711, MSVC 14.44.35207 (VS 2022 Build Tools 17.14), Windows SDK 10.0.26100.0 (its DXC), CMake 4.4.3 / Ninja 1.13.2, Python 3.12.10. Adapters: AMD RX 9060 XT (driver 32.0.32029.2010), NVIDIA RTX 5060 Ti (driver 32.0.16.2124), in-box WARP 10.0.26100.9711. Debug layer unavailable on this machine (Graphics Tools not installed); runs report
debug_layer=unavailable.Result at this branch (rebased onto current
main; isolated worktree configured with thedevpreset, ctest run via--test-diron that build, same filters):pixel_aot_hardware(default adapter, RTX 5060 Ti)pixel_aot_warp(WARP 10.0.26100.9711)pixel_aot_hardwarewithXBOX2WINDOWS_ADAPTER='RX 9060 XT'pixel_aot_hardwarewithXBOX2WINDOWS_ADAPTER='RTX 5060 Ti'tests/form_coverage_check.pyAll draws report
pixels=4096 channels=16384 max_absolute_error=0; the NaN-class rows lognan_classraw words and pass by class; nopixel_mismatchon any passing draw. Capability skips: none in this group. Debug layer unavailable (debug_layer=unavailable), so no debug diagnostics are claimed.Full suite at the final branch head:
ctest --test-dir <build> --no-tests=error— 146/146 passed, with three capability skips reported separately (bvh_wave64_hardware: NVIDIA native lane range 32..32;bvh_wave64_warp: WARP lane range 4..4;wave_shuffle_warp: WARP native width 4 is self-inverse). The seven pure-Python checks (form_coverage,bcpack,dxcontainer_part_offsets,layout_chunks,resource_ranges,script_state,intake/paths) all pass.One earlier full-suite run during development hit two intermittent failures outside this change's surface:
cpu_aot_exe_entry(the known #281 hang, 15 s timeout) anddxr_facing_warp(a transient all-zero WARP ray result). Both passed on isolated rerun and in the subsequent clean full-suite runs; this change touches neither fixture.Every new behavior has a negative control that fails without it (listed above). The pre-change baseline at
b860dd5passedpixel_aot_warpandpixel_aot_hardwareon both adapters on this machine.Evidence and follow-up
docs/experiments.mdrecords the preserve assumption, theps_6_2/-denormcontract, the case-trailer format, the NaN-class limits and the lossless integer path; the standalone repro command matches the harness flags.FLOAT_MODEremain unmeasured; #312 stays the tracking issue for those.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-22T01:56:13Z.
Ampere data point for the
-denorm preservePSO refusal recorded in this PR (curve fixture, RTX 5060 Ti, driver 32.0.16.2124).Environment
vendor=10de device=2484), driver 32.0.16.2101; in-box WARP 10.0.26100.9818dxcompiler 1.9.2602.17), MSVC 14.44.35207 (VS 2022 Build Tools), CMake 3.31.6 / Ninja (VS-bundled), Python 3.12.10e045e19(this PR),devpresetdebug_layer=unavailable), so no debug-layer diagnostics are claimed1. The PR as-is
pixel_aot_hardwarepixel_aot_warpThat includes the preserve/ftz mode control (
check_denorm_mode_draw) under both modes on the RTX 3070.2. Curve compile-variant probe (same variants as in the PR body)
A small script imports
tests/pixel_aot_check.py, translatescurve()(andshaping()as a control), compiles it withdxc -Gis [flags] -T <target> -E mainand draws it withoffscreen_check <backend> --check-pixel-casefor both gains (0.75, 1.125) against the harness's owncurve_case/shaping_casereferences. I confirmed in the-Fclisting that each build carries the expected"fp32-denorm-mode"function attribute (preserve/ftz/any).-denorm any-denorm ftz-denorm preserve-denorm preserve-denorm preserveEvery draw: return code 0,
pixels=4096 channels=16384 max_absolute_error=0.Conclusion (scoped)
On the RTX 3070 with driver 32.0.16.2101, the curve program under
-denorm preserveis accepted at PSO creation and matches the reference bit-for-bit, so theE_OUTOFMEMORYrefusal does not reproduce on this Ampere adapter / driver combination. From one machine I can't tell whether the difference comes from the architecture (Blackwell vs Ampere) or from the driver build (32.0.16.2124 vs 32.0.16.2101), so I'd read it as "not universal on NVIDIA" rather than as a cause. That seems consistent with keeping the exception recorded as a per-fixtureanywith the asserted mode independence, rather than as a general NVIDIA rule. A run of the same probe on an Ampere card with 32.0.16.2124, or on the RTX 5060 Ti with an older driver, would separate driver from architecture.The probe script is short and needs only the build outputs of this branch; happy to attach it if that helps.
AI-assisted: run and prepared with the support of Roan System; reviewed before posting.
Imported from R0Y00/Xbox2Windows. Originally posted by abilliontokens on 2026-11-22T02:26:09Z.
Thanks @roansystemlabs — that's a genuinely useful data point: it confirms the curve-program
-denorm preservePSO refusal is not universal on NVIDIA, which supports reading the recorded exception as per-adapter/per-driver rather than as a general NVIDIA rule.On the requested separating runs: this machine's drivers can't be downgraded or swapped, so neither an Ampere card on 32.0.16.2124 nor the RTX 5060 Ti on an older driver is obtainable here — that's a limitation of our setup, not an objection. The resolution doesn't depend on which trigger it is: per the #312 owner approval ("record unknown/any as such"), the curve fixture records mode
anywith a machine-checked assertion that its expected rows are subnormal-free, so it's correct either way, and the RTX 5060 Ti / 32.0.16.2124 refusal stays recorded as measured on that exact combination.If anyone else has an Ampere card on 32.0.16.2124 (or can swap drivers), please run the same probe and add the separating data point.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-22T03:44:23Z.
The current GitHub merge is textually clean, but I inspected the combined tree and found six DXC invocations still targeting
ps_6_0without an explicit f32 mode. They are incheck_class_draw,check_mad_draw,check_int_predicate_draws(twice),check_half_draw, andcheck_affine_lod_drawintests/pixel_aot_check.py. Please reconcile this branch with current main and route those calls through the mode-aware compiler helper, including the affine function’s local variable also namedcompile_shader. Keep the per-instruction FTZ behavior and any justified per-draw override. Please rerun the combined^pixel_aot_tests and record per-backend timings against the current timeout. Fixing #363 first will let the export-mask stack inherit the same contract.