Shader recompiler: f16 denormal sources read as zero on Intel because the f16 unpack has no DenormPreserve 16 #2822
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 boykopovar/AnyPS5. Originally posted by Silverash-i8 on 2026-10-10T16:12:03Z.
On Intel's Windows driver, f16 denormal sources read as zero, because
GLSLstd450UnpackHalf2x16(EmitF16BitsToF32) flushes them unless the module declaresDenormPreserve 16. The recompiler only declares the 16-bit float controls in the native f32 to f16 path (EmitNativeF32ToF16BitsRte), not when it unpacks f16 to f32. This is theagc_driver_vopc_comparefailure listed in #2114.Setup: Windows 11 Home (26200), WinLibs GCC 15.2.0 r7, Release,
main57f96fd2. Intel Graphics in a Core Ultra 9 275HX (Arrow Lake, device 0x7d67, driver 32.0.101.8991), which reportsshaderDenormPreserveFloat16,shaderSignedZeroInfNanPreserveFloat16andshaderRoundingModeRTEFloat16, soNativeF16Rteis true there.What fails
#2114 describes compare 36 as a NaN case, but on this iGPU it isn't. I changed
Checklocally to log every mismatch instead of stopping at the first one. All 24 mismatches across the edge-case passes are the smallest f16 denormal0x0001(2^-24) against0x0000or0x8000, in every f16 compare that can tell them apart:!(a >= b)!(a < b || a > b)!(a > b)/!(a <= b)!(a <= b),!(a < b),a < b || a > bNo NaN pair mismatches. 2^-24 is a normal f32, so the f32 compare isn't what flushes it; it's the unpack. Shaders without a float mode keep f16 denormals (
FLOAT_MODE0xc0, bits 7:6), which is what the test expects.Fix
Silverash-i8/AnyPS5-fork:fix/f16-unpack-denorm-preserve, one commit7158e9e8onmain57f96fd2, 12 lines added and 7 removed in 3 files. The capability and execution mode block moves out ofEmitNativeF32ToF16BitsRteintoEmitNativeF16Modes, which emitsFloat16,RoundingModeRTE 16,DenormPreserve 16andSignedZeroInfNanPreserve 16once per module whenNativeF16Rteholds.EmitF16BitsToF32calls it too. Devices without those float controls are unchanged, and a float mode that flushes f16 denormals is still applied by the translation's explicit flushes.Results
agc_driver_vopc_compare,_f64and_table: pass 3/3 on the iGPU and on the RTX 5060 Laptop GPU (32.0.16.1742). With the same probe, 0 mismatches on both.--parallel 6, iGPU withAPS5_NO_PIPELINE_LTO=1to keep the #2777 race out): 709/709 on the RTX 5060. On the iGPUvopc_comparedrops out of the failures and nothing new related to this fails;mesh(#2815),f64_fma_subnormalsandfp16_overflow(#2114),lds_beyond_device_limit(#2805) andvop1_float_unary(#2114) fail as onmain.agc_driver_gated_dispatch_capturefailed in that parallel run, with0xc0000374(heap corruption). It also failed under parallel load on a branch without this change (there on its 10 s limit), and passes 10/10 run on its own here, so it isn't this change. The heap corruption under load is worth its own look though, and I'll dig into it separately.tools/check_conventions.pyandtools/check_skips.py --job windowspass. There's no new test:agc_driver_vopc_comparealready has the denormal pairs.The UHD 770 numbers in #2114 show the same compare 36 failure. It would be good to know if this fixes it there too, since I can only test Arrow Lake.
AI-assisted (Claude Code); every number above is from runs on this machine.
Imported from boykopovar/AnyPS5. Originally posted by ThatsLeo on 2026-10-10T20:29:34Z.
Results on Mesa ANV, carried over from #2861 as asked. Fedora 44, GCC 16.2.1, Release, Intel Arc (Meteor Lake, Core Ultra 7 155H), Mesa 26.2.3, which reports
shaderDenormPreserveFloat16,shaderRoundingModeRTEFloat16andshaderSignedZeroInfNanPreserveFloat16(lavapipe reports noshaderDenormPreserveFloat16). ANV fails the same way: every mismatch is0x0001against0x0000or0x8000.Each fix cherry-picked alone onto
main56fb1b3b, fullctest:vopc_compare(3 runs)main7158e9e8(this issue,DenormPreserve 16)58f596ee(#1463, integer decode)e59865e0(#2861, subnormals as fraction × 2^-24)The remaining failures are the same in every row:
agc_driver_mesh(#2815),agc_driver_f64_fma_subnormals(#2860),agc_driver_lds_beyond_device_limit(#2805) andagc_driver_vop1_float_unary(#1250) on Arc,agc_driver_f64_fma_subnormalson lavapipe. So on ANV all three fix the compare with no regression. The difference is where they apply:7158e9e8relies on the device preserving f16 denormals, while the integer decodes (#1463,e59865e0) do not depend on float controls, and #1463 also covers the AMD byte-selector case.e59865e0adds nothing over #1463, so I'm not proposing it further.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by Silverash-i8 on 2026-10-11T05:28:49Z.
#1463 is merged now, which fixes this. On Windows 11 with the Arrow Lake iGPU (driver 101.8991),
agc_driver_vopc_comparefailed on plainmainand passed with #1463 applied, along withhalf_expansionfrom #1505 and the other f16 tests (details on #1463). Closing; myfix/f16-unpack-denorm-preservebranch is superseded.Thanks @ThatsLeo for the Mesa ANV runs.
AI-assisted (Claude Code).