fix(shader): apply the f32 output modifier and denormal flush to v_cvt_f32_f64 #5159

Closed
nikowolf123 wants to merge 1 commit from upstream-pr/5159 into main
nikowolf123 commented 2026-10-13 13:12:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-13T13:12:30Z.


What

v_cvt_f32_f64 writes an f32 result, but the recompiler treated that result like an f64 result in two places.

  • Output modifier. float64Operation checked the VOP3 mul:2, mul:4 and div:2 against the f16/f64 denormal field and then cleared it. In the titles' float mode (IEEE=0, FLOAT_MODE 0xc0, which is also how shaders without a known mode are translated) the modifier was silently dropped. With f16/f64 denormals flushed (for example 0x00) the translation threw. The hardware applies the modifier in both modes. Example: v_cvt_f32_f64_e64 v22, v[4:5] mul:2 of 1.0 gives 0x40000000 on gfx1036 in the titles' mode, and main gave 0x3f800000.
  • Denormal flush. f32DenormalFlushFor had no case for v_cvt_f32_f64, so a result below 2^-126 was whatever the host returned. In the f32 flush modes, 2^-130 must give +0. On lavapipe main gave 0x00080000.

Sources:

  • Hardware: the float-mode audit in #981, measured on RDNA2 (gfx1036) with tools/hw-oracle. The data is in gist SleglJan/30456e5687240f0b639a78e5477f2f91 (revision 1d26d816), audit.json, F64Rounding column 12 (v_cvt_f32_f64_e64 v22, v[4:5] mul:2). In all 28 finite rows the modifier is applied in the titles' mode (IEEE=0, f32 denormals flushed, f16/f64 kept). It is also applied with f16/f64 denormals flushed. It is ignored with IEEE=1 or with f32 denormals kept. The ±inf and NaN rows are the same in every mode. I checked all 28 cells against the model this change implements (round, flush, then raise the exponent by one) and found no mismatch.
  • ISA: "RDNA 2" Instruction Set Architecture Reference Guide, 30 November 2020 (https://gpuopen.com/download/rdna2-shader-instruction-set-architecture.pdf, sha256 22aec03f2706dba2e148ffde1f3a25d5cdd42c71a96f95240aeb48d995d44795).
    • Section 6.2.2 Instruction Outputs (page 44): VOP3 instructions with a floating-point result can apply OMOD. It is ignored when output denormals are enabled or when IEEE=1. When output denormals are disabled, the modifier is applied, denormals are flushed to zero, and -0 becomes +0.
    • Section 6.4, Table 24 (page 47): FP_DENORM bits [5:4] are the single-precision mode and bits [7:6] the double/half-precision mode. Mode 0 flushes input and output denormals, mode 1 flushes output only, and mode 2 flushes input only.
    • Chapter 12 note (page 101): rounding and denormal modes apply to all floating-point operations unless the instruction description says otherwise.
    • Section 12.8, VOP1 opcode 15 (page 139): V_CVT_F32_F64, "D.f = (float)S0.d", and denormals are supported.
  • LLVM at llvm/llvm-project@eb589df73f:
    • llvm/lib/Target/AMDGPU/VOP1Instructions.td:281-282 defines V_CVT_F32_F64 with VOP_F32_F64, which has an f32 destination (SIInstrInfo.td:3137). SIInstrInfo.td:2903 (HasOMod = !if(IsVOP3P, 0, DstVT.isFP)) gives it an omod operand.
    • SIFoldOperands.cpp:2491-2509: isOMod treats a V_MUL_F32 by 2, 4 or 0.5 as an output modifier only when f32 output denormals are PreserveSign.
    • SIFoldOperands.cpp:2625-2687: tryFoldOMod folds that multiply into the instruction that defines its operand when that instruction has an unset omod.
    • SIFoldOperands.cpp:3181-3185 and 3236-3239: it does not fold with IEEE mode on.
    • So an nsz fptrunc followed by a multiply by 2.0 compiles to v_cvt_f32_f64 ... mul:2 under the f32 flush mode, whatever the f64 mode.
    • llvm/lib/Target/AMDGPU/SIISelLowering.cpp:16312-16324: isCanonicalized lists ISD::FP_ROUND under "These will flush denorms if required."
    • llvm/test/CodeGen/AMDGPU/fcanonicalize-elimination.ll:237-251 (test_fold_canonicalize_fpround_value_f32_f64, RUN lines 1-4 include -denormal-fp-math-f32=preserve-sign) expects no v_mul/v_max canonicalize after v_cvt_f32_f64_e32.
  • Mesa ACO at mesa/mesa@9b9e14ed5c:
    • src/amd/compiler/aco_optimizer.cpp:3905-3980 (apply_output_mul, called for v_mul_f32 at 3995-4001) takes the denormal mode from the result type: denorm32 for an f32 result (3913). It folds only under fp_denorm_flush and when signed zeros need not be preserved (3954-3956), and only into a parent with output modifiers (3960).
    • aco_opcodes.py:1040 defines ("v_cvt_f32_f64", dst(F32), ...). F32 has mods=True (aco_opcodes.py:260), which aco_opcodes_cpp.py:81 turns into output_modifiers.
    • aco_optimizer.cpp:1658-1717 (gather_canonicalized) marks every float VALU result, this one included, as canonicalized. Lines 2198-2204 then turn a canonicalize of such a value into a plain move, so with denorm32 at flush ACO relies on the conversion having flushed its result.

What changed:

  • Float64Instructions.cpp, float64Operation: the f32 result (only ConvertF32F64 has one) is written with its modifiers. writeOperand then applies the existing f32 result rule: applyF32ResultModifiers, with outputModifierApplies reading FLOAT_MODE bits 5:4 and IEEE. The f16/f64 refusal stays only where the f32 rule ignores the modifier but the f16/f64 rule would apply it. That is f32 output denormals kept with f16/f64 flushed at IEEE=0, for example 0x30. Nobody has measured that mode, so translating it still throws. U32 and U64 results are unchanged.
  • VectorInstructions.cpp, f32DenormalFlushFor: VCvtF32F64 joins the group that flushes inputs and result (flush = 3u). The source is read with readF64, so only the result flush takes effect. As for every instruction in that group, f32 denormal modes 1 and 2 now throw, because they are not measured. Before, mode 1 was translated without the output flush the ISA describes for it, and mode 2, which keeps output denormals, needed no flush and was translated.
  • docs/dev/debt/shader.md: the f32 denormals entry and the output modifier entry now say which parts are measured, which come from the sources, and which are not measured. The unmeasured parts are scaling before rounding near the f32 denormal and overflow boundaries, mul:4 and div:2, mode 0x30, and tininess detection just below 2^-126.

F64Rounding.cpp: column 12 (cvt f32, the mul:2 instruction above) runs with no float mode, that is, in the titles' mode. Its 28 finite cells held the value without the modifier, which is what the hardware returns with IEEE=1 or with f32 denormals kept. They now hold the measured titles'-mode value from audit.json, which is the old value times 2. Row: old → new:

  • 0: 0xa1800000 → 0xa2000000
  • 1: 0x21800000 → 0x22000000
  • 2: 0xa5800000 → 0xa6000000
  • 4: 0x3f800000 → 0x40000000
  • 7: 0xc0200000 → 0xc0a00000
  • 9: 0x4a9cacfe → 0x4b1cacfe
  • 10: 0x450f38e2 → 0x458f38e2
  • 11: 0x417e2531 → 0x41fe2531
  • 12: 0x480cf3a9 → 0x488cf3a9
  • 13: 0x4eb62ef4 → 0x4f362ef4
  • 14: 0x4c227ac2 → 0x4ca27ac2
  • 15: 0x44814e1b → 0x45014e1b
  • 16: 0x4e4a1909 → 0x4eca1909
  • 17: 0x45eb2805 → 0x466b2805
  • 18: 0x4885bb86 → 0x4905bb86
  • 19: 0x47cd2b7e → 0x484d2b7e
  • 20: 0x4caccfb7 → 0x4d2ccfb7
  • 21: 0x431fe791 → 0x439fe791
  • 22: 0x49659a78 → 0x49e59a78
  • 23: 0x42ed8c91 → 0x436d8c91
  • 24: 0x4bb5b045 → 0x4c35b045
  • 25: 0x43d8a625 → 0x4458a625
  • 26: 0x4a3e728b → 0x4abe728b
  • 27: 0x40cc56c1 → 0x414c56c1
  • 28: 0x49d6f838 → 0x4a56f838
  • 29: 0x4d6d26b7 → 0x4ded26b7
  • 30: 0x4603200c → 0x4683200c
  • 31: 0x468e9335 → 0x470e9335

Rows 3, 5, 6 and 8 (±inf, NaN) do not change, as measured.

New test VCvtF32F64ResultModes.cpp (agc_driver_vcvt_f32_f64_result_modes): 32 f64 sources over 64 lanes, run in wave32 and wave64. Each source is converted plain and with mul:2, mul:4 and div:2.

  • With no float mode, and with 0xc0 and 0x00 at IEEE=0, the results are flushed and scaled.
  • With 0xc0 at IEEE=1, the results are flushed and the modifier is ignored.
  • With 0xf0 at IEEE=0 and IEEE=1, the modifier is ignored. Denormal results are not checked in these runs, because the host decides them.
  • 0x30 must be refused with "output modifier", and 0xd0 and 0xe0 with "f32 denormal mode".

What each row rests on:

  • mul:2 of finite values, ±inf and NaN matches the #981 measurement. 1.0, -2.5, -2^-60 and 0x4153959f_c5f99476 are rows of the measured kernel.
  • mul:4 and div:2 of normal values are exact multiplications by 4 and 0.5 (section 6.2.2).
  • -0.0 with a modifier gives +0 (section 6.2.2).
  • The flush rows (2^-130, 1.5 * 2^-129, 2^-149, -1.25 * 2^-140, the smallest f64 denormals) have both the converted and the scaled value below 2^-126. The overflow rows (FLT_MAX, 2^127, 1e300) and 2^-126 div:2 give the same result whether scaling comes before or after rounding. So none of these rows depends on the unmeasured order.

No title is known to use this encoding.

Tested

Linux (WSL2 Ubuntu), GCC, Release, configured like CI (-DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON). Tests ran on lavapipe (llvmpipe, LLVM 21.1.8) with VK_ICD_FILENAMES=<lvp_icd>.json ANYPS5_REQUIRE_VULKAN=1 GALLIUM_OVERRIDE_CPU_CAPS=avx.

  • With only the non-test change reverted, both tests fail:
    • agc_driver_vcvt_f32_f64_result_modes: "wave32 no float mode lane 0 v_cvt_f32_f64 mul:2 is 0x3f800000, expected 0x40000000"
    • agc_driver_f64_rounding: "lane 0 cvt f32 is 0xa1800000, expected 0xa2000000"
  • With the change, both pass, each in under 0.3 s.
  • Each of these negative checks fails the new test:
    • VCvtF32F64 removed from f32DenormalFlushFor: "lane 24 v_cvt_f32_f64 is 0x00080000, expected 0x00000000"
    • The omod clearing restored: lane 0 mul:2
    • The 0x30 refusal removed: "FLOAT_MODE 0x00000030 was not refused"
  • ctest -j4 -R 'agc_shader|agc_driver|shader|recompiler': 384 tests, none fail, 36 skip on lavapipe. Unmodified main in the same tree runs 383 tests with none failing and the same 36 skipped. The only per-test difference is the new test.
  • Full ctest -j4: 1050 tests, none fail, 43 skip (the 36 above and 7 video out tests). In the run on unmodified main (1049 tests), guest_video_out_wqhd_detection failed and guest_video_out_output_mode and guest_video_out_resolution_status were skipped. All three pass when rerun on main's recompiler and with this change, so there is no per-test regression.
  • tools/check_conventions.py --base origin/main (main's checker) and git diff --check: clean.

This was not measured on AMD hardware for this PR. Only the #981 data above was. A gfx103x reviewer can check every row of the new test with the oracle, from the repository root:

cat > body.s <<'EOF'
  v_cvt_f32_f64 v10, v[4:5]
  v_cvt_f32_f64_e64 v11, v[4:5] mul:2
  v_cvt_f32_f64_e64 v12, v[4:5] mul:4
  v_cvt_f32_f64_e64 v13, v[4:5] div:2
EOF
python3 -c "import re;s=open('core/libs/prx/libSceAgcDriver/tests/execution/VCvtF32F64ResultModes.cpp').read();t=s[s.index('Sources[32]'):s.index('};',s.index('Sources[32]'))];[print(f'0x{int(v,16)&0xffffffff:08x} 0x{int(v,16)>>32:08x} 0 0') for v in re.findall(r'0x([0-9a-f]{16})ull',t)]" > rows.txt
for mode in "0 0 3" "0 0 0" "1 0 3" "0 3 3" "1 3 3" "0 3 0"; do
  set -- $mode
  python3 tools/hw-oracle/hw_oracle.py body.s rows.txt --outs 4 --ieee $1 --dx10-clamp 1 \
    --denorm32 $2 --denorm16 $3 --round32 0 --round16 0 --fp16-overflow 0
done

What each mode should print:

  • The first two (0xc0 and 0x00 at IEEE=0): the test's Expected rows.
  • The third (0xc0 at IEEE=1): the first column of Expected in all four outputs.
  • The two 0xf0 modes: Kept.
  • The last (0x30): this is the unmeasured mode that throws.

These extra rows settle the unmeasured items in the debt entries:

printf '%s\n' '0xe0000000 0x380fffff 0 0' '0xf0000000 0x380fffff 0 0' '0x00000000 0x38080000 0 0' \
  '0x00000000 0x37f80000 0 0' '0x00000000 0xb8100000 0 0' '0xf0000000 0x47efffff 0 0' > edges.txt

Run edges.txt with the same loop. The rows are, in order:

  • two sources just below 2^-126 that round to 2^-126 (tininess)
  • mul:2 of 1.5 * 2^-127 and mul:4 of 1.5 * 2^-128 (scaling before or after the flush)
  • the sign of -2^-126 div:2
  • div:2 of a value that rounds to infinity

Native Windows 11, WinLibs GCC 15.2.0, NVIDIA GeForce RTX 5080 (driver 616.92), on this branch rebased onto main 0f2683cb7 (d176ede7e): agc_driver_vcvt_f32_f64_result_modes and agc_driver_f64_rounding pass 3 of 3 runs, and ctest -R 'agc_shader|agc_driver|shader|recompiler' passes 383 of 383.

Rebased onto main fdefd7660. The only conflict was docs/dev/debt/shader.md, where main added the patch-constants entry above the output-modifier entry this PR edits; both are kept. The code change is unchanged. WSL2 Ubuntu 26.04, lavapipe (Mesa 26.0.8), CI configuration: agc_driver_vcvt_f32_f64_result_modes and agc_driver_f64_rounding pass, and ctest -R 'agc_shader|agc_driver|shader|recompiler' passes 390 of 390.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: lavapipe (Mesa 26.0.8, llvmpipe) on WSL2 Ubuntu 26.04; NVIDIA GeForce RTX 5080, driver 616.92, Windows 11
  • AI-assisted: yes. Written with Claude Code; I reviewed every line and ran the tests above.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4843765835 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5159). Originally posted by [nikowolf123](https://github.com/nikowolf123) on 2026-10-13T13:12:30Z. --- ### What `v_cvt_f32_f64` writes an f32 result, but the recompiler treated that result like an f64 result in two places. - Output modifier. `float64Operation` checked the VOP3 `mul:2`, `mul:4` and `div:2` against the f16/f64 denormal field and then cleared it. In the titles' float mode (IEEE=0, `FLOAT_MODE` 0xc0, which is also how shaders without a known mode are translated) the modifier was silently dropped. With f16/f64 denormals flushed (for example 0x00) the translation threw. The hardware applies the modifier in both modes. Example: `v_cvt_f32_f64_e64 v22, v[4:5] mul:2` of 1.0 gives 0x40000000 on gfx1036 in the titles' mode, and `main` gave 0x3f800000. - Denormal flush. `f32DenormalFlushFor` had no case for `v_cvt_f32_f64`, so a result below 2^-126 was whatever the host returned. In the f32 flush modes, 2^-130 must give +0. On lavapipe `main` gave 0x00080000. Sources: - Hardware: the float-mode audit in #981, measured on RDNA2 (gfx1036) with `tools/hw-oracle`. The data is in gist SleglJan/30456e5687240f0b639a78e5477f2f91 (revision 1d26d816), `audit.json`, F64Rounding column 12 (`v_cvt_f32_f64_e64 v22, v[4:5] mul:2`). In all 28 finite rows the modifier is applied in the titles' mode (IEEE=0, f32 denormals flushed, f16/f64 kept). It is also applied with f16/f64 denormals flushed. It is ignored with IEEE=1 or with f32 denormals kept. The ±inf and NaN rows are the same in every mode. I checked all 28 cells against the model this change implements (round, flush, then raise the exponent by one) and found no mismatch. - ISA: "RDNA 2" Instruction Set Architecture Reference Guide, 30 November 2020 (https://gpuopen.com/download/rdna2-shader-instruction-set-architecture.pdf, sha256 22aec03f2706dba2e148ffde1f3a25d5cdd42c71a96f95240aeb48d995d44795). - Section 6.2.2 Instruction Outputs (page 44): VOP3 instructions with a floating-point result can apply OMOD. It is ignored when output denormals are enabled or when IEEE=1. When output denormals are disabled, the modifier is applied, denormals are flushed to zero, and -0 becomes +0. - Section 6.4, Table 24 (page 47): `FP_DENORM` bits [5:4] are the single-precision mode and bits [7:6] the double/half-precision mode. Mode 0 flushes input and output denormals, mode 1 flushes output only, and mode 2 flushes input only. - Chapter 12 note (page 101): rounding and denormal modes apply to all floating-point operations unless the instruction description says otherwise. - Section 12.8, VOP1 opcode 15 (page 139): `V_CVT_F32_F64`, "D.f = (float)S0.d", and denormals are supported. - LLVM at llvm/llvm-project@eb589df73f71996c41f0ef0c5aba8d2688044b4e: - `llvm/lib/Target/AMDGPU/VOP1Instructions.td:281-282` defines `V_CVT_F32_F64` with `VOP_F32_F64`, which has an f32 destination (`SIInstrInfo.td:3137`). `SIInstrInfo.td:2903` (`HasOMod = !if(IsVOP3P, 0, DstVT.isFP)`) gives it an omod operand. - `SIFoldOperands.cpp:2491-2509`: `isOMod` treats a `V_MUL_F32` by 2, 4 or 0.5 as an output modifier only when f32 output denormals are `PreserveSign`. - `SIFoldOperands.cpp:2625-2687`: `tryFoldOMod` folds that multiply into the instruction that defines its operand when that instruction has an unset omod. - `SIFoldOperands.cpp:3181-3185` and `3236-3239`: it does not fold with IEEE mode on. - So an nsz `fptrunc` followed by a multiply by 2.0 compiles to `v_cvt_f32_f64 ... mul:2` under the f32 flush mode, whatever the f64 mode. - `llvm/lib/Target/AMDGPU/SIISelLowering.cpp:16312-16324`: `isCanonicalized` lists `ISD::FP_ROUND` under "These will flush denorms if required." - `llvm/test/CodeGen/AMDGPU/fcanonicalize-elimination.ll:237-251` (`test_fold_canonicalize_fpround_value_f32_f64`, RUN lines 1-4 include `-denormal-fp-math-f32=preserve-sign`) expects no `v_mul`/`v_max` canonicalize after `v_cvt_f32_f64_e32`. - Mesa ACO at mesa/mesa@9b9e14ed5c99a282d0b2d35cad90591dbbc0d4ae: - `src/amd/compiler/aco_optimizer.cpp:3905-3980` (`apply_output_mul`, called for `v_mul_f32` at 3995-4001) takes the denormal mode from the result type: `denorm32` for an f32 result (3913). It folds only under `fp_denorm_flush` and when signed zeros need not be preserved (3954-3956), and only into a parent with output modifiers (3960). - `aco_opcodes.py:1040` defines `("v_cvt_f32_f64", dst(F32), ...)`. `F32` has `mods=True` (`aco_opcodes.py:260`), which `aco_opcodes_cpp.py:81` turns into `output_modifiers`. - `aco_optimizer.cpp:1658-1717` (`gather_canonicalized`) marks every float VALU result, this one included, as canonicalized. Lines 2198-2204 then turn a canonicalize of such a value into a plain move, so with `denorm32` at flush ACO relies on the conversion having flushed its result. What changed: - `Float64Instructions.cpp`, `float64Operation`: the f32 result (only `ConvertF32F64` has one) is written with its modifiers. `writeOperand` then applies the existing f32 result rule: `applyF32ResultModifiers`, with `outputModifierApplies` reading `FLOAT_MODE` bits 5:4 and IEEE. The f16/f64 refusal stays only where the f32 rule ignores the modifier but the f16/f64 rule would apply it. That is f32 output denormals kept with f16/f64 flushed at IEEE=0, for example 0x30. Nobody has measured that mode, so translating it still throws. U32 and U64 results are unchanged. - `VectorInstructions.cpp`, `f32DenormalFlushFor`: `VCvtF32F64` joins the group that flushes inputs and result (`flush = 3u`). The source is read with `readF64`, so only the result flush takes effect. As for every instruction in that group, f32 denormal modes 1 and 2 now throw, because they are not measured. Before, mode 1 was translated without the output flush the ISA describes for it, and mode 2, which keeps output denormals, needed no flush and was translated. - `docs/dev/debt/shader.md`: the f32 denormals entry and the output modifier entry now say which parts are measured, which come from the sources, and which are not measured. The unmeasured parts are scaling before rounding near the f32 denormal and overflow boundaries, `mul:4` and `div:2`, mode 0x30, and tininess detection just below 2^-126. `F64Rounding.cpp`: column 12 (`cvt f32`, the `mul:2` instruction above) runs with no float mode, that is, in the titles' mode. Its 28 finite cells held the value without the modifier, which is what the hardware returns with IEEE=1 or with f32 denormals kept. They now hold the measured titles'-mode value from `audit.json`, which is the old value times 2. Row: old → new: - 0: 0xa1800000 → 0xa2000000 - 1: 0x21800000 → 0x22000000 - 2: 0xa5800000 → 0xa6000000 - 4: 0x3f800000 → 0x40000000 - 7: 0xc0200000 → 0xc0a00000 - 9: 0x4a9cacfe → 0x4b1cacfe - 10: 0x450f38e2 → 0x458f38e2 - 11: 0x417e2531 → 0x41fe2531 - 12: 0x480cf3a9 → 0x488cf3a9 - 13: 0x4eb62ef4 → 0x4f362ef4 - 14: 0x4c227ac2 → 0x4ca27ac2 - 15: 0x44814e1b → 0x45014e1b - 16: 0x4e4a1909 → 0x4eca1909 - 17: 0x45eb2805 → 0x466b2805 - 18: 0x4885bb86 → 0x4905bb86 - 19: 0x47cd2b7e → 0x484d2b7e - 20: 0x4caccfb7 → 0x4d2ccfb7 - 21: 0x431fe791 → 0x439fe791 - 22: 0x49659a78 → 0x49e59a78 - 23: 0x42ed8c91 → 0x436d8c91 - 24: 0x4bb5b045 → 0x4c35b045 - 25: 0x43d8a625 → 0x4458a625 - 26: 0x4a3e728b → 0x4abe728b - 27: 0x40cc56c1 → 0x414c56c1 - 28: 0x49d6f838 → 0x4a56f838 - 29: 0x4d6d26b7 → 0x4ded26b7 - 30: 0x4603200c → 0x4683200c - 31: 0x468e9335 → 0x470e9335 Rows 3, 5, 6 and 8 (±inf, NaN) do not change, as measured. New test `VCvtF32F64ResultModes.cpp` (`agc_driver_vcvt_f32_f64_result_modes`): 32 f64 sources over 64 lanes, run in wave32 and wave64. Each source is converted plain and with `mul:2`, `mul:4` and `div:2`. - With no float mode, and with 0xc0 and 0x00 at IEEE=0, the results are flushed and scaled. - With 0xc0 at IEEE=1, the results are flushed and the modifier is ignored. - With 0xf0 at IEEE=0 and IEEE=1, the modifier is ignored. Denormal results are not checked in these runs, because the host decides them. - 0x30 must be refused with "output modifier", and 0xd0 and 0xe0 with "f32 denormal mode". What each row rests on: - `mul:2` of finite values, ±inf and NaN matches the #981 measurement. 1.0, -2.5, -2^-60 and 0x4153959f_c5f99476 are rows of the measured kernel. - `mul:4` and `div:2` of normal values are exact multiplications by 4 and 0.5 (section 6.2.2). - -0.0 with a modifier gives +0 (section 6.2.2). - The flush rows (2^-130, 1.5 * 2^-129, 2^-149, -1.25 * 2^-140, the smallest f64 denormals) have both the converted and the scaled value below 2^-126. The overflow rows (FLT_MAX, 2^127, 1e300) and 2^-126 `div:2` give the same result whether scaling comes before or after rounding. So none of these rows depends on the unmeasured order. No title is known to use this encoding. ### Tested Linux (WSL2 Ubuntu), GCC, Release, configured like CI (`-DBUILD_TESTING=ON -DANYPS5_ENABLE_SPIRV_TOOLS=ON`). Tests ran on lavapipe (llvmpipe, LLVM 21.1.8) with `VK_ICD_FILENAMES=<lvp_icd>.json ANYPS5_REQUIRE_VULKAN=1 GALLIUM_OVERRIDE_CPU_CAPS=avx`. - With only the non-test change reverted, both tests fail: - `agc_driver_vcvt_f32_f64_result_modes`: "wave32 no float mode lane 0 v_cvt_f32_f64 mul:2 is 0x3f800000, expected 0x40000000" - `agc_driver_f64_rounding`: "lane 0 cvt f32 is 0xa1800000, expected 0xa2000000" - With the change, both pass, each in under 0.3 s. - Each of these negative checks fails the new test: - `VCvtF32F64` removed from `f32DenormalFlushFor`: "lane 24 v_cvt_f32_f64 is 0x00080000, expected 0x00000000" - The omod clearing restored: lane 0 `mul:2` - The 0x30 refusal removed: "FLOAT_MODE 0x00000030 was not refused" - `ctest -j4 -R 'agc_shader|agc_driver|shader|recompiler'`: 384 tests, none fail, 36 skip on lavapipe. Unmodified `main` in the same tree runs 383 tests with none failing and the same 36 skipped. The only per-test difference is the new test. - Full `ctest -j4`: 1050 tests, none fail, 43 skip (the 36 above and 7 video out tests). In the run on unmodified `main` (1049 tests), `guest_video_out_wqhd_detection` failed and `guest_video_out_output_mode` and `guest_video_out_resolution_status` were skipped. All three pass when rerun on `main`'s recompiler and with this change, so there is no per-test regression. - `tools/check_conventions.py --base origin/main` (main's checker) and `git diff --check`: clean. This was not measured on AMD hardware for this PR. Only the #981 data above was. A gfx103x reviewer can check every row of the new test with the oracle, from the repository root: ```sh cat > body.s <<'EOF' v_cvt_f32_f64 v10, v[4:5] v_cvt_f32_f64_e64 v11, v[4:5] mul:2 v_cvt_f32_f64_e64 v12, v[4:5] mul:4 v_cvt_f32_f64_e64 v13, v[4:5] div:2 EOF python3 -c "import re;s=open('core/libs/prx/libSceAgcDriver/tests/execution/VCvtF32F64ResultModes.cpp').read();t=s[s.index('Sources[32]'):s.index('};',s.index('Sources[32]'))];[print(f'0x{int(v,16)&0xffffffff:08x} 0x{int(v,16)>>32:08x} 0 0') for v in re.findall(r'0x([0-9a-f]{16})ull',t)]" > rows.txt for mode in "0 0 3" "0 0 0" "1 0 3" "0 3 3" "1 3 3" "0 3 0"; do set -- $mode python3 tools/hw-oracle/hw_oracle.py body.s rows.txt --outs 4 --ieee $1 --dx10-clamp 1 \ --denorm32 $2 --denorm16 $3 --round32 0 --round16 0 --fp16-overflow 0 done ``` What each mode should print: - The first two (0xc0 and 0x00 at IEEE=0): the test's `Expected` rows. - The third (0xc0 at IEEE=1): the first column of `Expected` in all four outputs. - The two 0xf0 modes: `Kept`. - The last (0x30): this is the unmeasured mode that throws. These extra rows settle the unmeasured items in the debt entries: ```sh printf '%s\n' '0xe0000000 0x380fffff 0 0' '0xf0000000 0x380fffff 0 0' '0x00000000 0x38080000 0 0' \ '0x00000000 0x37f80000 0 0' '0x00000000 0xb8100000 0 0' '0xf0000000 0x47efffff 0 0' > edges.txt ``` Run `edges.txt` with the same loop. The rows are, in order: - two sources just below 2^-126 that round to 2^-126 (tininess) - `mul:2` of 1.5 * 2^-127 and `mul:4` of 1.5 * 2^-128 (scaling before or after the flush) - the sign of -2^-126 `div:2` - `div:2` of a value that rounds to infinity Native Windows 11, WinLibs GCC 15.2.0, NVIDIA GeForce RTX 5080 (driver 616.92), on this branch rebased onto `main` 0f2683cb7 (d176ede7e): `agc_driver_vcvt_f32_f64_result_modes` and `agc_driver_f64_rounding` pass 3 of 3 runs, and `ctest -R 'agc_shader|agc_driver|shader|recompiler'` passes 383 of 383. Rebased onto `main` fdefd7660. The only conflict was `docs/dev/debt/shader.md`, where `main` added the patch-constants entry above the output-modifier entry this PR edits; both are kept. The code change is unchanged. WSL2 Ubuntu 26.04, lavapipe (Mesa 26.0.8), CI configuration: `agc_driver_vcvt_f32_f64_result_modes` and `agc_driver_f64_rounding` pass, and `ctest -R 'agc_shader|agc_driver|shader|recompiler'` passes 390 of 390. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: lavapipe (Mesa 26.0.8, llvmpipe) on WSL2 Ubuntu 26.04; NVIDIA GeForce RTX 5080, driver 616.92, Windows 11 - [x] AI-assisted: yes. Written with Claude Code; I reviewed every line and ran the tests above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-13 16:02:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T16:02:47Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#4201 docs/dev/debt/shader.md L90-91
#4222 docs/dev/debt/shader.md L90-91
#5234 docs/dev/debt/shader.md L90-91
#5402 docs/dev/debt/shader.md L90-91
#5457 docs/dev/debt/shader.md L90-91
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6149742718 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5159#issuecomment-6149742718). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T16:02:47Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #4201 | `docs/dev/debt/shader.md` [L90-91](https://github.com/boykopovar/AnyPS5/blob/0df6e295c52e7cd6afa394ed35513bd252045c74/docs/dev/debt/shader.md#L90-L91) | | | | #4222 | `docs/dev/debt/shader.md` [L90-91](https://github.com/boykopovar/AnyPS5/blob/0df6e295c52e7cd6afa394ed35513bd252045c74/docs/dev/debt/shader.md#L90-L91) | | | | #5234 | `docs/dev/debt/shader.md` [L90-91](https://github.com/boykopovar/AnyPS5/blob/0df6e295c52e7cd6afa394ed35513bd252045c74/docs/dev/debt/shader.md#L90-L91) | | | | #5402 | `docs/dev/debt/shader.md` [L90-91](https://github.com/boykopovar/AnyPS5/blob/0df6e295c52e7cd6afa394ed35513bd252045c74/docs/dev/debt/shader.md#L90-L91) | | | | #5457 | `docs/dev/debt/shader.md` [L90-91](https://github.com/boykopovar/AnyPS5/blob/0df6e295c52e7cd6afa394ed35513bd252045c74/docs/dev/debt/shader.md#L90-L91) | | |
oneandonlydean commented 2026-10-14 02:31:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:31:32Z.


Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159571163 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5159#issuecomment-6159571163). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T02:31:32Z. --- Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!5159
No description provided.