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

Closed
github-bot wants to merge 1 commit from gh-pr/360/head into gh-pr/360/base
Owner

@⁠SchmashinPrunes on GitHub · 2026-11-24 13:35 UTC · original
SchmashinPrunes:rdna2-cb-infnan → main · +375 −1 · 6 files · 1 commits · closed without merging

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

**@⁠SchmashinPrunes** on GitHub · 2026-11-24 13:35 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/360) `SchmashinPrunes:rdna2-cb-infnan` → `main` · +375 −1 · 6 files · 1 commits · closed without merging 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)
cb_probe (Vulkan 1.3, any driver) writes 34 f32 source patterns over 10
destination values into RGBA16F, R11G11B10, RGBA32F and R16F targets with
blending off, ONE/ZERO, ONE/ONE ADD, MIN and MAX, and reads back the stored
bits. cb_probe.py writes the inputs, prints the results and checks them
against the rules measured on gfx1036 (Mesa 25.2.8 RADV).

BLOCKERS: the blendclamp OPEN item on shader Inf/NaN is answered. RDNA2
keeps +Inf and NaN unblended and through additive blending, rounds blended
finite sums toward zero with saturation, and ignores NaN in MIN/MAX. NVK on
an RTX 4060 Ti, on the same machine, overflows blended finite sums to Inf.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:20:09 +00:00
github-bot closed this pull request 2026-11-26 06:20:09 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-25 13:50 UTC · original

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

**@⁠omonkeyz** on GitHub · 2026-11-25 13:50 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/360#issuecomment-7164373734) 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

This discussion has been locked. Commenting is limited to contributors.
No description provided.