fix(shader): round v_cvt_pk_u8_f32 in the FLOAT_MODE f32 round mode #6011

Merged
zmeizy merged 1 commit from upstream-pr/6011 into main 2026-10-23 14:13:42 +00:00
zmeizy commented 2026-10-14 19:15:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by zmeizy on 2026-10-14T19:15:01Z.


What

v_cvt_pk_u8_f32 always rounded its source to nearest even. On RDNA2 it rounds in the f32 round mode of FLOAT_MODE (bits 1:0) before it clamps to 0..255: to nearest with ties to even, toward +infinity, toward -infinity, or toward zero. It also flushes a denormal source when f32 denormals are flushed. So with a directed f32 round mode the recompiler wrote wrong bytes for every non-integer source in range. For example, 0.125 gives 1 toward +infinity, and 254.875 gives 254 toward zero.

vCvtPkU8F32 now picks FPRoundEven32, FPCeil32, FPFloor32 or FPTrunc32 from the shader's f32 round mode, and flushes its source by the f32 denormal flush the instruction already declares in f32DenormalFlushFor. With round to nearest even nothing changes. The denormal flush only matters toward +infinity: 2^-149 gives 0 with f32 denormal mode 0 and 1 with mode 3.

Out of scope, and unchanged:

  • f32 denormal modes 1 and 2 still throw.
  • A directed round mode set at run time with s_round_mode or s_setreg still throws: RoundingMode.cpp keeps the instruction as one that doesn't model run-time rounding.

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):

  • Rows: 2,133 sources: k/8 for k = -16 to 2,099; 0.49999997, 0.50000006, -0.49999997, 255.49998, 255.5 and 255.50002; ±1e10; ±2^-149, ±0x007fffff and 2^-126; ±infinity; quiet and signaling NaNs.
  • Instruction: v_cvt_pk_u8_f32 v10, v4, 0, 0.
  • Float modes: ieee 0 and 1, each with denorm32 0 and 3 and round32 0 to 3 (16 modes); dx10_clamp 1, denorm16 3, round16 0, fp16_overflow 0.
  • Model: the source flushed by the denormal field, rounded in the round mode, then clamped to 0..255, with NaN giving 0. It matches all 2,133 rows in all 16 modes. Ties to away instead of to even misses 128 rows in each round-to-nearest mode.
  • The same rule also matches byte 1 with a non-zero destination and 58 more sources in all 32 combinations of denormal and round mode at IEEE 0 and 1. In f32 denormal modes 1 and 2 those results equal modes 3 and 0.

A new entry in docs/dev/debt/shader.md records it.

Tested

Ubuntu 24.04 (WSL2), GCC 13.3, lavapipe, on main 73efd940.

  • agc_driver_vcvt_pk_u8_f32_round_mode (new) pins 38 measured sources (ties, fractions near 0 and 255, out-of-range values, denormals, infinities and NaNs). It checks every round mode with f32 denormals flushed and kept, at IEEE 0 and 1.
    • On main it fails: round mode 1 of 0.125 gives 0 instead of 1.
    • With the change it passes in 0.1 s.
  • The harness on all 2,133 measured rows:
    • On main, round to nearest matched and the directed modes missed 893 to 897 rows each.
    • With the change, 0 mismatches in all 16 modes.
  • agc_driver_f32_pack_rounding, agc_driver_float16_misc, agc_driver_vop3_legacy_source_modifiers, agc_driver_f32_denormal_flush and agc_driver_integer_to_f32_rounding pass.
  • Measurement data attached:
    • anyps5-gpu-probes-v3-gfx1030.json.gz: probes pk_u8_rounding and pack_f32_denormal_modes.
    • anyps5-gpu-probes-v2-gfx1030.json.gz: probe unary_f32_denormal_modes, output v23.

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 25.2.8, LLVM 20.1.2) on Ubuntu 24.04 under WSL2; semantics measured on AMD Radeon RX 6800 (gfx1030, Windows driver 32.0.21045.5002)
  • AI-assisted: yes

🤖 Generated with Claude Code
anyps5-gpu-probes-v2-gfx1030.json.gz
anyps5-gpu-probes-v3-gfx1030.json.gz

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4863178421 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6011). Originally posted by [zmeizy](https://github.com/zmeizy) on 2026-10-14T19:15:01Z. --- ### What `v_cvt_pk_u8_f32` always rounded its source to nearest even. On RDNA2 it rounds in the f32 round mode of `FLOAT_MODE` (bits 1:0) before it clamps to 0..255: to nearest with ties to even, toward +infinity, toward -infinity, or toward zero. It also flushes a denormal source when f32 denormals are flushed. So with a directed f32 round mode the recompiler wrote wrong bytes for every non-integer source in range. For example, 0.125 gives 1 toward +infinity, and 254.875 gives 254 toward zero. `vCvtPkU8F32` now picks `FPRoundEven32`, `FPCeil32`, `FPFloor32` or `FPTrunc32` from the shader's f32 round mode, and flushes its source by the f32 denormal flush the instruction already declares in `f32DenormalFlushFor`. With round to nearest even nothing changes. The denormal flush only matters toward +infinity: 2^-149 gives 0 with f32 denormal mode 0 and 1 with mode 3. Out of scope, and unchanged: - f32 denormal modes 1 and 2 still throw. - A directed round mode set at run time with `s_round_mode` or `s_setreg` still throws: `RoundingMode.cpp` keeps the instruction as one that doesn't model run-time rounding. 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`): - Rows: 2,133 sources: k/8 for k = -16 to 2,099; 0.49999997, 0.50000006, -0.49999997, 255.49998, 255.5 and 255.50002; ±1e10; ±2^-149, ±0x007fffff and 2^-126; ±infinity; quiet and signaling NaNs. - Instruction: `v_cvt_pk_u8_f32 v10, v4, 0, 0`. - Float modes: ieee 0 and 1, each with denorm32 0 and 3 and round32 0 to 3 (16 modes); dx10_clamp 1, denorm16 3, round16 0, fp16_overflow 0. - Model: the source flushed by the denormal field, rounded in the round mode, then clamped to 0..255, with NaN giving 0. It matches all 2,133 rows in all 16 modes. Ties to away instead of to even misses 128 rows in each round-to-nearest mode. - The same rule also matches byte 1 with a non-zero destination and 58 more sources in all 32 combinations of denormal and round mode at IEEE 0 and 1. In f32 denormal modes 1 and 2 those results equal modes 3 and 0. A new entry in `docs/dev/debt/shader.md` records it. ### Tested Ubuntu 24.04 (WSL2), GCC 13.3, lavapipe, on `main` `73efd940`. - `agc_driver_vcvt_pk_u8_f32_round_mode` (new) pins 38 measured sources (ties, fractions near 0 and 255, out-of-range values, denormals, infinities and NaNs). It checks every round mode with f32 denormals flushed and kept, at IEEE 0 and 1. - On `main` it fails: round mode 1 of 0.125 gives 0 instead of 1. - With the change it passes in 0.1 s. - The harness on all 2,133 measured rows: - On `main`, round to nearest matched and the directed modes missed 893 to 897 rows each. - With the change, 0 mismatches in all 16 modes. - `agc_driver_f32_pack_rounding`, `agc_driver_float16_misc`, `agc_driver_vop3_legacy_source_modifiers`, `agc_driver_f32_denormal_flush` and `agc_driver_integer_to_f32_rounding` pass. - Measurement data attached: - `anyps5-gpu-probes-v3-gfx1030.json.gz`: probes `pk_u8_rounding` and `pack_f32_denormal_modes`. - `anyps5-gpu-probes-v2-gfx1030.json.gz`: probe `unary_f32_denormal_modes`, output v23. ### 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 25.2.8, LLVM 20.1.2) on Ubuntu 24.04 under WSL2; semantics measured on AMD Radeon RX 6800 (gfx1030, Windows driver 32.0.21045.5002) - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code) [anyps5-gpu-probes-v2-gfx1030.json.gz](https://github.com/user-attachments/files/33453387/anyps5-gpu-probes-v2-gfx1030.json.gz) [anyps5-gpu-probes-v3-gfx1030.json.gz](https://github.com/user-attachments/files/33453388/anyps5-gpu-probes-v3-gfx1030.json.gz)
jotitadev commented 2026-10-14 20:33:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-14T20:33:25Z.

Review: COMMENTED


Run on an Apple GPU, a device without f32 denormal support (shaderDenormPreserveFloat32 = false).

GPUs tested: Apple M2 Max, MoltenVK 1.4.2 (Vulkan 1.4.357), macOS 27.2, x86-64 under Rosetta; also MoltenVK main with SPIRV-Cross #2704 (keeps the sign of -0)

Method: macos-port at b7eb6b6b (mugurc/AnyPS5) + ImportWatched + this PR's diff (merge-base..head, without docs/), not main, because main does not run the GPU tests on macOS yet. Release, LunarG Vulkan SDK 1.4.363.0, x86-64 under Rosetta. Suite: ctest -R "^agc" -E "agc_display_buffer_dcc|agc_driver_flip|agc_driver_lds_atomics64" -j1 --timeout 30; without the PR it has 13 known macOS failures with MoltenVK 1.4.2 and 7 with the #2704 build (#1). Head ab42b22db; the diff applies cleanly.

  • agc_driver_vcvt_pk_u8_f32_round_mode fails on both drivers. With the Require turned into a print locally, there are 4 mismatches, the same on both drivers: round mode 1 (toward +infinity) with f32 denormals kept, sources 0x00000001 and 0x007fffff, at IEEE 0 and 1. These give 0 where the rows expect 1, because the device flushes the denormal source before the ceil.
  • Every other row passes, including all round modes with f32 denormals flushed.
  • Only the test file on the unchanged branch: it fails with the original error, round mode 1, f32 denormals flushed, IEEE=0 of 0x3e000000 is 0x00000000, expected 0x00000001.
  • Suite: the new test is the only added failure. No other test changes, on either driver.

Skipping the two kept-denormal sources on devices without f32 DenormPreserve would let the test pass there.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5524290090 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6011#pullrequestreview-5524290090). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-14T20:33:25Z. **Review:** COMMENTED --- Run on an Apple GPU, a device without f32 denormal support (`shaderDenormPreserveFloat32 = false`). GPUs tested: Apple M2 Max, MoltenVK 1.4.2 (Vulkan 1.4.357), macOS 27.2, x86-64 under Rosetta; also MoltenVK main with SPIRV-Cross #2704 (keeps the sign of -0) Method: `macos-port` at `b7eb6b6b` (mugurc/AnyPS5) + ImportWatched + this PR's diff (merge-base..head, without `docs/`), not `main`, because `main` does not run the GPU tests on macOS yet. Release, LunarG Vulkan SDK 1.4.363.0, x86-64 under Rosetta. Suite: `ctest -R "^agc" -E "agc_display_buffer_dcc|agc_driver_flip|agc_driver_lds_atomics64" -j1 --timeout 30`; without the PR it has 13 known macOS failures with MoltenVK 1.4.2 and 7 with the #2704 build (#1). Head `ab42b22db`; the diff applies cleanly. - `agc_driver_vcvt_pk_u8_f32_round_mode` fails on both drivers. With the `Require` turned into a print locally, there are 4 mismatches, the same on both drivers: round mode 1 (toward +infinity) with f32 denormals kept, sources `0x00000001` and `0x007fffff`, at IEEE 0 and 1. These give 0 where the rows expect 1, because the device flushes the denormal source before the ceil. - Every other row passes, including all round modes with f32 denormals flushed. - Only the test file on the unchanged branch: it fails with the original error, `round mode 1, f32 denormals flushed, IEEE=0 of 0x3e000000 is 0x00000000, expected 0x00000001`. - Suite: the new test is the only added failure. No other test changes, on either driver. Skipping the two kept-denormal sources on devices without f32 DenormPreserve would let the test pass there. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Dextroid17 commented 2026-10-15 01:02:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-15T01:02:55Z.


Ran this on PR head ab42b22db (merge base 73efd9407, 290 commits behind main ab9a47684). This confirms jotitadev's MoltenVK result above on a second driver.

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).

  • agc_driver_vcvt_pk_u8_f32_round_mode_tests on the PR: 3 of 3 failed, each first at:
    "AGC graphics: v_cvt_pk_u8_f32 round mode 1, f32 denormals kept, IEEE=0 of 0x00000001 is 0x00000000, expected 0x00000001"
    All flushed-denormal cases ran first and passed in each run. My log shows only the first kept mismatch, since the test stops there.
  • Mutation check: kept the PR's test, put back the merge-base Translation/src/ConvertInstructions.cpp, rebuilt, ran 3 times: 3 of 3 failed, first in the flushed half: "AGC graphics: v_cvt_pk_u8_f32 round mode 1, f32 denormals flushed, IEEE=0 of 0x3e000000 is 0x00000000, expected 0x00000001".

lavapipe reports shaderDenormPreserveFloat32 = false and shaderDenormFlushToZeroFloat32 = false. On main I find denormal-preserve handling only for f16 and f64 (VulkanDevice.cpp lines 1212-1213, 1222 and 1410), and no f32 DenormPreserve execution mode emitted, by reading. So the kept-denormal result depends on the device, which fits this failure, though I have not proven that lavapipe flushes this input. The test could skip the kept cases when the device reports no f32 denormal preservation, or the translation could produce the kept result without relying on the device. I have not tried either.

Not checked: NVIDIA, AMD, Windows, or any title.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6181961641 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6011#issuecomment-6181961641). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-15T01:02:55Z. --- Ran this on PR head ab42b22db (merge base 73efd9407, 290 commits behind main ab9a47684). This confirms jotitadev's MoltenVK result above on a second driver. 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). - agc_driver_vcvt_pk_u8_f32_round_mode_tests on the PR: 3 of 3 failed, each first at: "AGC graphics: v_cvt_pk_u8_f32 round mode 1, f32 denormals kept, IEEE=0 of 0x00000001 is 0x00000000, expected 0x00000001" All flushed-denormal cases ran first and passed in each run. My log shows only the first kept mismatch, since the test stops there. - Mutation check: kept the PR's test, put back the merge-base Translation/src/ConvertInstructions.cpp, rebuilt, ran 3 times: 3 of 3 failed, first in the flushed half: "AGC graphics: v_cvt_pk_u8_f32 round mode 1, f32 denormals flushed, IEEE=0 of 0x3e000000 is 0x00000000, expected 0x00000001". lavapipe reports shaderDenormPreserveFloat32 = false and shaderDenormFlushToZeroFloat32 = false. On main I find denormal-preserve handling only for f16 and f64 (VulkanDevice.cpp lines 1212-1213, 1222 and 1410), and no f32 DenormPreserve execution mode emitted, by reading. So the kept-denormal result depends on the device, which fits this failure, though I have not proven that lavapipe flushes this input. The test could skip the kept cases when the device reports no f32 denormal preservation, or the translation could produce the kept result without relying on the device. I have not tried either. Not checked: NVIDIA, AMD, Windows, or any title. AI-assisted: yes
adriadam10 commented 2026-10-16 21:13:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T21:13:24Z.

Review: CHANGES_REQUESTED


Measured on the hardware oracle (gfx1035, RDNA2): v_cvt_pk_u8_f32 v10, v4, 0, 0 over 2,137 sources (the test's 38 plus k/8 for k = -16 to 2,099, values next to 0.5 and 255.5, ±1e10, denormals, infinities, NaNs) at IEEE 0/1 × f32 denormal mode 0/3 × f32 round mode 0-3. The flush → round → clamp model in the description and every row of the test match it, 0 mismatches.

One thing to fix before merging:

  • ConvertInstructions.cpp:213-220: with f32 denormals kept, round mode 1 of a positive denormal relies on the driver keeping the denormal through FPCeil32 and the <= 0 compare. The recompiler only requests DenormPreserve for f16 and f64, so Vulkan lets the driver flush a 32-bit denormal there. This is the failure @jotitadev (MoltenVK) and @Dextroid17 (lavapipe, Mesa 26.2.4) reported above, and it also fails on RADV here (Radeon 660M, Mesa 26.2.4): round mode 1, f32 denormals kept, IEEE=0 of 0x00000001 is 0x00000000, expected 0x00000001. CI's lavapipe (Mesa 25.2.8) keeps the denormal and passes, so a green CI won't show it.
    Skipping those rows on such devices would leave the translation wrong on them, RADV included. Please decide this case on the bits instead: with round mode 1 and f32 denormals kept, a source whose bits are in 0x00000001..0x007fffff gives 1. Every other denormal case (modes 0, 2 and 3, and negative denormals in mode 1) already gives 0 whatever the driver does with the input, so the test's rows can stay as they are.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5553760323 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6011#pullrequestreview-5553760323). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-16T21:13:24Z. **Review:** CHANGES_REQUESTED --- Measured on the hardware oracle (gfx1035, RDNA2): `v_cvt_pk_u8_f32 v10, v4, 0, 0` over 2,137 sources (the test's 38 plus k/8 for k = -16 to 2,099, values next to 0.5 and 255.5, ±1e10, denormals, infinities, NaNs) at IEEE 0/1 × f32 denormal mode 0/3 × f32 round mode 0-3. The flush → round → clamp model in the description and every row of the test match it, 0 mismatches. One thing to fix before merging: - `ConvertInstructions.cpp:213-220`: with f32 denormals kept, round mode 1 of a positive denormal relies on the driver keeping the denormal through `FPCeil32` and the `<= 0` compare. The recompiler only requests `DenormPreserve` for f16 and f64, so Vulkan lets the driver flush a 32-bit denormal there. This is the failure @jotitadev (MoltenVK) and @Dextroid17 (lavapipe, Mesa 26.2.4) reported above, and it also fails on RADV here (Radeon 660M, Mesa 26.2.4): `round mode 1, f32 denormals kept, IEEE=0 of 0x00000001 is 0x00000000, expected 0x00000001`. CI's lavapipe (Mesa 25.2.8) keeps the denormal and passes, so a green CI won't show it. Skipping those rows on such devices would leave the translation wrong on them, RADV included. Please decide this case on the bits instead: with round mode 1 and f32 denormals kept, a source whose bits are in `0x00000001..0x007fffff` gives 1. Every other denormal case (modes 0, 2 and 3, and negative denormals in mode 1) already gives 0 whatever the driver does with the input, so the test's rows can stay as they are.
Dextroid17 commented 2026-10-21 17:10:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-21T17:10:24Z.


Re-ran on head 059d3f2a1 (rebased onto cecb540a6). Setup differs from my 10-15 run: Release build, -DANYPS5_AGC_EXECUTION_TESTS=VCvtPkU8F32RoundMode, -DANYPS5_ENABLE_SPIRV_TOOLS=OFF (CI uses ON), shader cache neither cleared nor disabled, lavapipe via VK_ICD_FILENAMES (Mesa 26.2.4 llvmpipe, LLVM 23.1.1, 256 bits). agc_driver_vcvt_pk_u8_f32_round_mode passes 3 of 3 ctest runs, and a direct run of the binary prints v_cvt_pk_u8_f32 round mode tests passed.

The failure I measured on 10-15 on this driver ("round mode 1, f32 denormals kept, IEEE=0 of 0x00000001 is 0x00000000, expected 0x00000001") no longer reproduces. By reading, the select at ConvertInstructions.cpp:230-233 keys on the source bits (0x00000001..0x007fffff gives 1), so the result no longer depends on the driver preserving the denormal through FPCeil32. I did not run RADV or MoltenVK, so the open change request and the 10-14 MoltenVK result are not answered by this run.

Not checked: RADV, MoltenVK, NVIDIA, Windows, any title. All CI build jobs are skipped on this head. My APPROVED review above went up with an empty body before this run; it stands for this lavapipe result only.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6321919717 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6011#issuecomment-6321919717). Originally posted by [Dextroid17](https://github.com/Dextroid17) on 2026-10-21T17:10:24Z. --- Re-ran on head 059d3f2a1 (rebased onto cecb540a6). Setup differs from my 10-15 run: Release build, `-DANYPS5_AGC_EXECUTION_TESTS=VCvtPkU8F32RoundMode`, `-DANYPS5_ENABLE_SPIRV_TOOLS=OFF` (CI uses ON), shader cache neither cleared nor disabled, lavapipe via `VK_ICD_FILENAMES` (Mesa 26.2.4 llvmpipe, LLVM 23.1.1, 256 bits). `agc_driver_vcvt_pk_u8_f32_round_mode` passes 3 of 3 ctest runs, and a direct run of the binary prints `v_cvt_pk_u8_f32 round mode tests passed`. The failure I measured on 10-15 on this driver ("round mode 1, f32 denormals kept, IEEE=0 of 0x00000001 is 0x00000000, expected 0x00000001") no longer reproduces. By reading, the select at `ConvertInstructions.cpp:230-233` keys on the source bits (`0x00000001..0x007fffff` gives 1), so the result no longer depends on the driver preserving the denormal through `FPCeil32`. I did not run RADV or MoltenVK, so the open change request and the 10-14 MoltenVK result are not answered by this run. Not checked: RADV, MoltenVK, NVIDIA, Windows, any title. All CI build jobs are skipped on this head. My APPROVED review above went up with an empty body before this run; it stands for this lavapipe result only. AI-assisted: yes
zmeizy commented 2026-10-21 17:17:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by zmeizy on 2026-10-21T17:17:11Z.


Thanks, done in 059d3f2a1 (also rebased onto main cecb540a).

With round mode 1 and f32 denormals kept, a source whose bits are in 0x00000001..0x007fffff now gives 1 on the bits, so the result no longer depends on whether the driver keeps the denormal through FPCeil32 and the <= 0 compare. Every other denormal case already gives 0 whatever the driver does, so the test's rows are unchanged. The debt entry says so and is now under 1,000 characters.

Re-checked on Ubuntu 24.04 (WSL2), GCC 13.3, lavapipe (Mesa 25.2.8):

All 2,133 measured sources match in all 16 modes (IEEE 0/1 × f32 denormal mode 0/3 × f32 round mode 0–3).
agc_driver_vcvt_pk_u8_f32_round_mode fails on main and passes with the change.
It and agc_driver_f32_pack_rounding, agc_driver_float16_misc, agc_driver_vop3_legacy_source_modifiers, agc_driver_f32_denormal_flush and agc_driver_integer_to_f32_rounding pass with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1.
No validation messages beyond main's (VUID-VkDeviceCreateInfo-pNext-pNext only).
lavapipe 25.2.8 keeps f32 denormals, so it can't show the old failure. A run on RADV or MoltenVK would confirm the new path.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6322063876 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6011#issuecomment-6322063876). Originally posted by [zmeizy](https://github.com/zmeizy) on 2026-10-21T17:17:11Z. --- Thanks, done in 059d3f2a1 (also rebased onto main cecb540a). With round mode 1 and f32 denormals kept, a source whose bits are in 0x00000001..0x007fffff now gives 1 on the bits, so the result no longer depends on whether the driver keeps the denormal through FPCeil32 and the <= 0 compare. Every other denormal case already gives 0 whatever the driver does, so the test's rows are unchanged. The debt entry says so and is now under 1,000 characters. Re-checked on Ubuntu 24.04 (WSL2), GCC 13.3, lavapipe (Mesa 25.2.8): All 2,133 measured sources match in all 16 modes (IEEE 0/1 × f32 denormal mode 0/3 × f32 round mode 0–3). agc_driver_vcvt_pk_u8_f32_round_mode fails on main and passes with the change. It and agc_driver_f32_pack_rounding, agc_driver_float16_misc, agc_driver_vop3_legacy_source_modifiers, agc_driver_f32_denormal_flush and agc_driver_integer_to_f32_rounding pass with VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1. No validation messages beyond main's (VUID-VkDeviceCreateInfo-pNext-pNext only). lavapipe 25.2.8 keeps f32 denormals, so it can't show the old failure. A run on RADV or MoltenVK would confirm the new path.
jotitadev commented 2026-10-22 08:26:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T08:26:09Z.

Review: COMMENTED


MoltenVK run of 059d3f2a1, for the new path. MoltenVK flushes the denormal through FPCeil32 here, so it takes the case the bit select was added for: it fails without the select and passes with it. This head also clears the 4 denormal mismatches I reported on ab42b22db.

Machine: Apple M2 Max, macOS 27.2, x86_64 under Rosetta 2. Release, BUILD_TESTING=ON. The device reports shaderDenormPreserveFloat32 = false.
Drivers: MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), and MoltenVK main + SPIRV-Cross #2704.
Base/method: PR #8658 feat/macos-port @ ee0a438415 (current main plus the macOS port), not main, which does not build on macOS. This PR's diff (git diff merge-base..059d3f2a1 -- . ':!docs') applied on top, clean. Full rebuild before each run.

  • With the PR: agc_driver_vcvt_pk_u8_f32_round_mode passes 3 of 3 on both drivers.
  • Head with only the new if (roundMode == 1u && (f32DenormalFlush & 1u) == 0u) select removed (the ab42b22db behavior): fails 3 of 3 on both drivers with v_cvt_pk_u8_f32 round mode 1, f32 denormals kept, IEEE=0 of 0x00000001 is 0x00000000, expected 0x00000001. This is the same failure as on RADV and the old lavapipe, so the bit select is what makes the result independent of the driver on Apple too.
  • Full ^agc suite with the PR: -j1 --timeout 30, 857 tests. MoltenVK 1.4.2 matches the base exactly (17 failures). MoltenVK main + #2704 has the base's 16 plus agc_driver_cross_workgroup_flag, which also fails intermittently on the base without this PR (a workgroup did not see another workgroup's flag store). No timeouts.

GPUs tested: Apple M2 Max (MoltenVK 1.4.2; MoltenVK main + SPIRV-Cross #2704)

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5611299484 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6011#pullrequestreview-5611299484). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-22T08:26:09Z. **Review:** COMMENTED --- <!-- head: 059d3f2a1 --> MoltenVK run of 059d3f2a1, for the new path. MoltenVK flushes the denormal through `FPCeil32` here, so it takes the case the bit select was added for: it fails without the select and passes with it. This head also clears the 4 denormal mismatches I reported on ab42b22db. **Machine:** Apple M2 Max, macOS 27.2, x86_64 under Rosetta 2. Release, `BUILD_TESTING=ON`. The device reports `shaderDenormPreserveFloat32 = false`. **Drivers:** MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), and MoltenVK main + SPIRV-Cross #2704. **Base/method:** PR #8658 `feat/macos-port` @ `ee0a438415` (current `main` plus the macOS port), not `main`, which does not build on macOS. This PR's diff (`git diff merge-base..059d3f2a1 -- . ':!docs'`) applied on top, clean. Full rebuild before each run. - **With the PR:** `agc_driver_vcvt_pk_u8_f32_round_mode` passes 3 of 3 on both drivers. - **Head with only the new `if (roundMode == 1u && (f32DenormalFlush & 1u) == 0u)` select removed** (the ab42b22db behavior): fails 3 of 3 on both drivers with `v_cvt_pk_u8_f32 round mode 1, f32 denormals kept, IEEE=0 of 0x00000001 is 0x00000000, expected 0x00000001`. This is the same failure as on RADV and the old lavapipe, so the bit select is what makes the result independent of the driver on Apple too. - **Full `^agc` suite with the PR:** `-j1 --timeout 30`, 857 tests. MoltenVK 1.4.2 matches the base exactly (17 failures). MoltenVK main + #2704 has the base's 16 plus `agc_driver_cross_workgroup_flag`, which also fails intermittently on the base without this PR (`a workgroup did not see another workgroup's flag store`). No timeouts. GPUs tested: Apple M2 Max (MoltenVK 1.4.2; MoltenVK main + SPIRV-Cross #2704) Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
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!6011
No description provided.