feat(shader): follow IEEE_MODE in f32 min, max, min3, max3 and med3 #1826

Merged
adriadam10 merged 2 commits from upstream-pr/1826 into main 2026-10-08 21:34:00 +00:00
adriadam10 commented 2026-10-08 20:39:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T20:39:39Z.


What

Step 3 of #981, IEEE_MODE family: v_min_f32, v_max_f32, v_min3_f32, v_max3_f32 and v_med3_f32 follow the shader's IEEE_MODE (carried by #1816).

Measured on RDNA2 (gfx1035) with the hardware oracle over every (a, b, c) combination of ±0, ±1, ±inf, positive/negative denormals, quiet NaNs with and without payload, and signaling NaNs with and without payload (14³ = 2,744 rows × 5 ops), in four modes: IEEE 0/1 × f32 denormals flushed/kept.

mode rule vs main
IEEE=0 a NaN operand is ignored (the other operand wins); for ±0, min returns -0 and max +0 0 mismatches (denormals kept)
IEEE=1 if an operand is a signaling NaN, the result is that NaN quieted, checking the first operand first; otherwise as IEEE=0. min3/max3 are two nested pairs; med3 is min3 when any operand is NaN, else the IEEE=0 median 0 mismatches with this PR, 981-1,050 per op on main

The existing agc_driver_f32_min_max_nan table matches the hardware at IEEE=0 (128/128). With IEEE=1, 53 of its 128 rows differ. The test now also runs every row with IEEE_MODE=1 against a table captured on the oracle (the same with f32 denormals flushed and kept).

  • TranslateOptions::ieeeMode, from request.context.floatMode, set on each TranslationContext.
  • ieeeMinMaxF32 for the five ops when ieeeMode: per pair, it selects the quieted signaling NaN (bits | 0x400000) before the existing FPMin32/FPMax32, so the emitter and the f16/packed variants that share those IR ops are unchanged. IEEE=0 and unknown modes keep the previous lowering. IEEE=1 with an output modifier throws (the hardware ignores omod at IEEE=1, not measured here).
  • TechnicalDebt: the float mode line now says which ops read IEEE_MODE and what still follows a single mode. That includes f32 denormals flushed before the compare under FLOAT_MODE 0xc0, which these measurements also show but which belongs to the FLOAT_MODE family.

Tested

Linux (CachyOS). agc_driver_f32_min_max_nan passes on RADV (gfx1035) and CI's lavapipe with IEEE 0 and 1. Negative check: dropping the first-operand signaling-NaN select fails at IEEE mode: row 80 v_min_f32 ... is 0x00000000, expected 0x7fc00001. Full ctest: 488/488.

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 in TechnicalDebt
  • 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: #1816
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4792526159 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1826). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-08T20:39:39Z. --- ### What Step 3 of #981, IEEE_MODE family: `v_min_f32`, `v_max_f32`, `v_min3_f32`, `v_max3_f32` and `v_med3_f32` follow the shader's `IEEE_MODE` (carried by #1816). Measured on RDNA2 (gfx1035) with the [hardware oracle](docs/dev/HW_ORACLE.md) over every (a, b, c) combination of ±0, ±1, ±inf, positive/negative denormals, quiet NaNs with and without payload, and signaling NaNs with and without payload (14³ = 2,744 rows × 5 ops), in four modes: IEEE 0/1 × f32 denormals flushed/kept. | mode | rule | vs `main` | |---|---|---| | IEEE=0 | a NaN operand is ignored (the other operand wins); for ±0, min returns -0 and max +0 | 0 mismatches (denormals kept) | | IEEE=1 | if an operand is a signaling NaN, the result is that NaN quieted, checking the first operand first; otherwise as IEEE=0. min3/max3 are two nested pairs; med3 is min3 when any operand is NaN, else the IEEE=0 median | 0 mismatches with this PR, 981-1,050 per op on `main` | The existing `agc_driver_f32_min_max_nan` table matches the hardware at IEEE=0 (128/128). With IEEE=1, 53 of its 128 rows differ. The test now also runs every row with `IEEE_MODE=1` against a table captured on the oracle (the same with f32 denormals flushed and kept). - `TranslateOptions::ieeeMode`, from `request.context.floatMode`, set on each `TranslationContext`. - `ieeeMinMaxF32` for the five ops when `ieeeMode`: per pair, it selects the quieted signaling NaN (`bits | 0x400000`) before the existing `FPMin32`/`FPMax32`, so the emitter and the f16/packed variants that share those IR ops are unchanged. IEEE=0 and unknown modes keep the previous lowering. IEEE=1 with an output modifier throws (the hardware ignores omod at IEEE=1, not measured here). - TechnicalDebt: the float mode line now says which ops read IEEE_MODE and what still follows a single mode. That includes f32 denormals flushed before the compare under `FLOAT_MODE` 0xc0, which these measurements also show but which belongs to the FLOAT_MODE family. ### Tested Linux (CachyOS). `agc_driver_f32_min_max_nan` passes on RADV (gfx1035) and CI's lavapipe with IEEE 0 and 1. Negative check: dropping the first-operand signaling-NaN select fails at `IEEE mode: row 80 v_min_f32 ... is 0x00000000, expected 0x7fc00001`. Full ctest: 488/488. ### Checklist - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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: #1816 - [x] AI-assisted: yes
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!1826
No description provided.