Repository navigation
fix(shader): quiet v_cvt_f32_f16 NaN results in IEEE mode - #22662
oneandonlydean merged 2 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — looks good
Nothing blocks this change; the inspected translation and regression test support the stated IEEE-mode NaN quieting behavior.
What I ran
Reviewed head 8983768a36451cdf008350cad4437711359b87e5 using the prepared review/diff.patch and the pinned repo_read.py reader. No test command was run. I read core/shader/recompiler/Translation/src/ConvertInstructions.cpp, core/libs/prx/libSceAgcDriver/tests/execution/F16ToF32Unpack.cpp, and the relevant quietNan32 implementation in core/shader/recompiler/Translation/src/TranslationContext/OperandAccess.cpp. Both changed files were included in the review folder; no changed files were excluded.
Results
| Check | Result | Note |
|---|---|---|
| Diff and changed code review | passed | Both changed files read |
| Tests in this review | not run | Hardware results are author-reported |
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not run the tests or independently verify the reported GPU, driver, operating system, hardware oracle, or CI results. The prepared review folder did not provide review/files.json; exclusion information is therefore not independently confirmed. No other repository files were needed for the reviewed behavior.
To get this to a good state
Nothing is required.
|
Ran the Tested set with the Khronos validation layer on Linux and an NVIDIA GPU, since CI runs the GPU tests only on lavapipe and the NVIDIA run in the Tested section is on Windows. Setup: Arch Linux (kernel 7.3.4), GCC 16.2.1, Release, NVIDIA GeForce RTX 4090 (vendor
Every device selected the RTX 4090; Negative control: with main's No new AI-assisted: yes (Claude Code) |
|
Head No new failures and no new validation messages on either GPU.
Layer runs used AI-assisted: yes |
|
Tested head Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7, Release,
Whole batch: the full This is one combined tree, not a run of this PR alone. AI-assisted: yes (Claude Code) |
|
GPU run on RDNA4 (gfx1201) with the AMD Windows driver and the validation layer: the fix is correct. Over all 65,536 halves, the recompiled What this run adds.
Code.
Evidence.
Negative control and mutation.
GPU. Head
Validation.
Host:
AI-assisted: yes |
|
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.
|
What
v_cvt_f32_f16did not quiet a signalling NaN source whenIEEE_MODEis set:TranslationContext::vCvtF32F16widened the half (flushF16InputValue(readF16AsF32(...))) and wrote it unchanged, so0x7c01became0x7f802000. RDNA2 hardware returns0x7fc02000: withIEEE_MODEset the widened NaN gets the f32 quiet bit, with it clear it is left as is.ieeeMode, a NaN result goes through the existingquietNan32(bit 22 set), as the other f32 translations that quiet NaNs do; withIEEE_MODEclear nothing changes. The SDWA form shares this translation.F16ToF32Unpack.cppalready converts all 65,536 halves withIEEE_MODEclear; it now also converts them withIEEE_MODEset and expectsHalfToFloatBits(half)with bit 22 set for every NaN half.RequestandDispatchtake anieeeflag (default false, so the existing passes and--verify-spirvare unchanged).Source of the semantics: measured on RDNA2 hardware (gfx1036, AMD Windows driver 32.0.21045.16010) with
tools/hw-oracle:v_cvt_f32_f16over all 65,536 halves, f16 denormals kept, f32 flushed, round to nearest even, once with IEEE 0 and once with IEEE 1. AgainstHalfToFloatBits: IEEE 0 differs on 0 halves; IEEE 1 differs exactly on the NaN halves, and matchesHalfToFloatBits | 0x00400000there, 0 differences. The same mismatch first showed in a differential run of the hardware oracle against AnyPS5'sagc_oracle_runneron both Vulkan devices (0x7c01,0x7d00,0xfdffdiffered with IEEE 1 only).Tested
Windows 11 Pro 10.0.26200,
ctest --test-dir build -R f16_to_f32_unpack -V(the execution test and its--verify-spirvvariant) withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_LOADER_DEBUG=layer, validation layer 1.4.363, once per GPU (ANYPS5_GPU):v_cvt_f32_f16 with IEEE_MODE of 0xd9a47c01 is 0x7f802000, expected 0x7fc02000VUID-VUID-main's test also passes with the fix on both GPUs (0
VUID-). Each log showsInsert instance layer "VK_LAYER_KHRONOS_validation"and none showswas not found but was requested by env var VK_INSTANCE_LAYERS. The fullagc_driversuite onmain(378945815f) on both GPUs is the baseline (its known failures are unrelated).pr_overlap.py --branch: no overlap with open pull requests.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