fix(shader): translate v_ldexp_f32 in f32 denormal modes 1 and 2 #6008
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6008"
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 zmeizy on 2026-10-14T19:12:05Z.
What
v_ldexp_f32threwf32 denormal mode N ... is not implementedin shaders whoseFLOAT_MODEf32 denormal field (bits 5:4) is 1 or 2. On RDNA2 it follows the field like the kept and flushed modes do:0x3fffffffscaled by 2^-127 gives +0.FLOAT_MODE, as mode 3 does.vLdexpF32now takes the subnormal-aware path of mode 3 for modes 1 and 2 too. Mode 1 selects the signed zero instead of the rounded subnormal result, and mode 2 treats a subnormal input as zero. Modes 0 and 3 are unchanged.Source of semantics: measured with the hardware oracle's kernel template on gfx1030 (AMD Radeon RX 6800, AMD Windows driver 32.0.21045.5002 through its HIP runtime
amdhip64_6.dll):v_ldexp_f32, andv_ldexp_f32 ... clamp.A new entry in
docs/dev/debt/shader.mdrecords it. The general "f32 denormals" entry is left unchanged because #5782 edits that line.Tested
Ubuntu 24.04 (WSL2), GCC 13.3, lavapipe, on
main73efd940.agc_driver_ldexp_f32_denormal_modes(new) pins 39 measured rows, with an expected value for each of the 16 combinations of mode (1, 2), round mode (0 to 3) and IEEE (0, 1). The rows cover denormal inputs with exponent 0, denormal to normal and back, the ties at 2^-150, the 0x3fffffff * 2^-127 case, overflow, the extreme exponents, zeros, infinities and a quiet NaN.mainit fails (mode 1 throws). With the change it passes in 0.1 s.clamp) match the recompiler output with the change. Before the change, modes 0 and 3 already matched and modes 1 and 2 threw.agc_driver_ldexp_f32_denormal,agc_driver_f32_denormal_flush,agc_driver_nan_quietingandagc_driver_vop3_pack_ldexppass.anyps5-gpu-probes-v2-gfx1030.json.gz(probeldexp_f32_denormal_modes).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
anyps5-gpu-probes-v2-gfx1030.json.gz
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-15T01:02:53Z.
Ran this on PR head
f11382faf(merge base73efd9407, 290 commits behind mainab9a47684).Setup: PR head checked out as-is (not rebased), default CMake build (CMAKE_BUILD_TYPE empty, unoptimized), Linux, ANYPS5_NO_SHADER_CACHE=1, GPU test run on lavapipe (Mesa 26.2.4 llvmpipe, LLVM 23.1.1).
So the test does reach modes 1 and 2. Without the change the recompiler refuses mode 1 outright, so this check does not show whether the asserted values would catch a wrong translation. The expected values come from the PR's RDNA2 measurements; llvmpipe does not confirm hardware behaviour.
Not checked: other GPUs, Windows, or any title.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:13:10Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/shader/recompiler/Translation/src/FloatInstructions.cppcore/shader/recompiler/Translation/src/FloatInstructions.cppdocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mddocs/dev/debt/shader.mdImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T20:58:44Z.
Measured
v_ldexp_f32(plain andclamp) on gfx1035 over 2679 value/exponent rows, including the test's 39, in all 32 modes: f32 denormal modes 0 to 3, IEEE 0 and 1, f32 round modes 0 to 3. The recompiler output with this change matches the hardware bit for bit in all 171,456 cells, the test's expected values match the hardware, and the test fails without the change. Merging.