rdna2-hwprobe: colour export and blend probe; RDNA2 keeps shader Inf/NaN in fp16 and R11G11B10 targets #360

Closed
SchmashinPrunes wants to merge 1 commit from upstream-pr/360 into main
SchmashinPrunes commented 2026-11-24 13:35:29 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by SchmashinPrunes on 2026-11-24T13:35:29Z.


This answers the blendclamp OPEN item in docs/BLOCKERS.md, "shader Inf/NaN mapping unverified": "check the CB/export NaN and Inf behaviour ... on an RDNA2 card with tools/rdna2-hwprobe".

Library / area: tools/rdna2-hwprobe (no runtime code), docs/BLOCKERS.md

Exports changed (exports.txt rows): none

Source of the behaviour:

  • Results recorded on RDNA2 hardware: the gfx1036 iGPU of a Ryzen 5 9600X, Mesa 25.2.8 RADV on Linux, through a Vulkan program written from scratch.
  • That is RDNA2, not the console's gfx1013.
  • No game or console files, and no third-party code.

What the probe does

  • One row of 340 pixels. Each fragment writes four f32 bit patterns from a storage buffer.
  • Values: 34 sources against 10 destinations each, including ±Inf, quiet and signalling NaNs with payloads, 65504, 65520, 1e5, ±FLT_MAX, the R11/R10 maxima, denormals and ±0.
  • Targets: RGBA16F, B10G11R11_UFLOAT, RGBA32F and R16F.
  • Blend states: off, ONE/ZERO ADD, ONE/ONE ADD, MIN and MAX. A first unblended pass writes the destination values.
  • Two runs were bit-identical.

RADV's ISA dump shows that RGBA16F and R11G11B10 are exported with v_cvt_pkrtz_f16_f32 + exp mrt0 ... compr, and RGBA32F with a 32-bit export. So this covers the packed fp16 export plus the colour unit. A title shader that exports 32-bit floats to an fp16 target is not covered.

What RDNA2 does

RGBA16F R11G11B10
shader +Inf, unblended or ONE/ZERO 0x7c00 (Inf) 0x7c0, 0x7c0, 0x3e0 (Inf)
any NaN 0xfe00 0x7e0, 0x7e0, 0x3f0
finite overflow (65520, 1e5, FLT_MAX) 0x7bff 0x7bf, 0x7bf, 0x3df
ADD: Inf + finite / NaN + anything Inf / NaN Inf / NaN
ADD: 40000 + 40000 / 65504 + −1 0x7bff / 0x7bfe 0x7bf / –
MIN, MAX with a NaN on either side the other operand the other operand
  • Blended finite sums are rounded toward zero and saturate.
  • The exported fp16 source takes part even when it is negative and the target is unsigned: 39936 + (−1) stores 0x78d in R11G11B10.
  • MIN/MAX return +0 for −0.

For blendclamp: the console keeps shader-written Inf and NaN in these targets, both unblended and through additive blending. So the eager passes and TOMBOX_BLEND_CLAMP=ps (Inf → max, NaN → +max) are less exact than no clamp for Inf/NaN. Only finite overflow saturates, which matches the WARP/NVIDIA measurement already in BLOCKERS.

Other drivers, same machine: NVK on an RTX 4060 Ti matches RDNA2 for Inf and for MIN/MAX NaN handling. But its blended finite sums round to nearest and overflow to Inf (40000 + 40000 = 0x7c00). It also keeps or rewrites NaN payloads, keeps −0, and flushes fp32 denormals when blending is on. That is Mesa's NVIDIA driver, not the Windows driver measured in BLOCKERS, but it is another case of finite overflow depending on the vendor.

Change

  • tools/rdna2-hwprobe/, all new:
    • cb_probe.cpp, the Vulkan program: it takes a device-name substring and runs on any Vulkan 1.3 driver;
    • cb_probe.vert and cb_probe.frag;
    • cb_probe.py, with three modes:
      • gen writes the inputs;
      • show prints every stored value;
      • check compares a recording with the gfx1036 rules above, prints each difference and exits non-zero.
  • README.txt: a section with the build and run commands and the results.
  • docs/BLOCKERS.md: the blendclamp OPEN line is replaced by the measurement. The R32G32B32A32 line is left as it is, since #320 handles it.

Tests

On the gfx1036 machine, following the README:

  • cb_probe RADV cb.in 340 cb.out twice gave identical output.
  • python3 cb_probe.py check cb.out printed "0 results differ from the gfx1036 rules".
  • The same check on the NVK recording lists the three finite-overflow cases.

pr_gate.py --base origin/main --head HEAD: 6 files checked, 0 problems. There's no Rust change, so the cargo tests are not affected.

  • cargo test unaffected (no crate changes)
  • No game or console files and no binaries included
  • No fake success

🤖 Generated with Claude Code

<!-- greyfinch-sync:omonkeyz/xbox-emulator:issue:6582999189 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/360). Originally posted by [SchmashinPrunes](https://github.com/SchmashinPrunes) on 2026-11-24T13:35:29Z. --- This answers the blendclamp OPEN item in docs/BLOCKERS.md, "shader Inf/NaN mapping unverified": "check the CB/export NaN and Inf behaviour ... on an RDNA2 card with tools/rdna2-hwprobe". **Library / area:** `tools/rdna2-hwprobe` (no runtime code), `docs/BLOCKERS.md` **Exports changed (exports.txt rows):** none **Source of the behaviour:** - Results recorded on RDNA2 hardware: the gfx1036 iGPU of a Ryzen 5 9600X, Mesa 25.2.8 RADV on Linux, through a Vulkan program written from scratch. - That is RDNA2, not the console's gfx1013. - No game or console files, and no third-party code. ### What the probe does - One row of 340 pixels. Each fragment writes four f32 bit patterns from a storage buffer. - Values: 34 sources against 10 destinations each, including ±Inf, quiet and signalling NaNs with payloads, 65504, 65520, 1e5, ±FLT_MAX, the R11/R10 maxima, denormals and ±0. - Targets: RGBA16F, B10G11R11_UFLOAT, RGBA32F and R16F. - Blend states: off, ONE/ZERO ADD, ONE/ONE ADD, MIN and MAX. A first unblended pass writes the destination values. - Two runs were bit-identical. RADV's ISA dump shows that RGBA16F and R11G11B10 are exported with `v_cvt_pkrtz_f16_f32` + `exp mrt0 ... compr`, and RGBA32F with a 32-bit export. So this covers the packed fp16 export plus the colour unit. A title shader that exports 32-bit floats to an fp16 target is not covered. ### What RDNA2 does | | RGBA16F | R11G11B10 | |---|---|---| | shader +Inf, unblended or ONE/ZERO | `0x7c00` (Inf) | `0x7c0, 0x7c0, 0x3e0` (Inf) | | any NaN | `0xfe00` | `0x7e0, 0x7e0, 0x3f0` | | finite overflow (65520, 1e5, FLT_MAX) | `0x7bff` | `0x7bf, 0x7bf, 0x3df` | | ADD: Inf + finite / NaN + anything | Inf / NaN | Inf / NaN | | ADD: 40000 + 40000 / 65504 + −1 | `0x7bff` / `0x7bfe` | `0x7bf` / – | | MIN, MAX with a NaN on either side | the other operand | the other operand | - Blended finite sums are rounded toward zero and saturate. - The exported fp16 source takes part even when it is negative and the target is unsigned: 39936 + (−1) stores `0x78d` in R11G11B10. - MIN/MAX return +0 for −0. **For blendclamp:** the console keeps shader-written Inf and NaN in these targets, both unblended and through additive blending. So the eager passes and `TOMBOX_BLEND_CLAMP=ps` (Inf → max, NaN → +max) are less exact than no clamp for Inf/NaN. Only finite overflow saturates, which matches the WARP/NVIDIA measurement already in BLOCKERS. **Other drivers, same machine:** NVK on an RTX 4060 Ti matches RDNA2 for Inf and for MIN/MAX NaN handling. But its blended finite sums round to nearest and overflow to Inf (40000 + 40000 = `0x7c00`). It also keeps or rewrites NaN payloads, keeps −0, and flushes fp32 denormals when blending is on. That is Mesa's NVIDIA driver, not the Windows driver measured in BLOCKERS, but it is another case of finite overflow depending on the vendor. ### Change - `tools/rdna2-hwprobe/`, all new: - `cb_probe.cpp`, the Vulkan program: it takes a device-name substring and runs on any Vulkan 1.3 driver; - `cb_probe.vert` and `cb_probe.frag`; - `cb_probe.py`, with three modes: - `gen` writes the inputs; - `show` prints every stored value; - `check` compares a recording with the gfx1036 rules above, prints each difference and exits non-zero. - `README.txt`: a section with the build and run commands and the results. - `docs/BLOCKERS.md`: the blendclamp OPEN line is replaced by the measurement. The R32G32B32A32 line is left as it is, since #320 handles it. ### Tests On the gfx1036 machine, following the README: - `cb_probe RADV cb.in 340 cb.out` twice gave identical output. - `python3 cb_probe.py check cb.out` printed "0 results differ from the gfx1036 rules". - The same check on the NVK recording lists the three finite-overflow cases. `pr_gate.py --base origin/main --head HEAD`: 6 files checked, 0 problems. There's no Rust change, so the cargo tests are not affected. - [x] `cargo test` unaffected (no crate changes) - [x] No game or console files and no binaries included - [x] No fake success 🤖 Generated with [Claude Code](https://claude.com/claude-code)
omonkeyz commented 2026-11-25 13:50:44 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by omonkeyz on 2026-11-25T13:50:44Z.


Applied on main in dfd120b (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7164373734 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/360#issuecomment-7164373734). Originally posted by [omonkeyz](https://github.com/omonkeyz) on 2026-11-25T13:50:44Z. --- Applied on main in dfd120b (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

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
omonkeyz/xbox-emulator!360
No description provided.