Accept round-toward-zero RGB9E5 stores on the native RCAS path #130

Manually merged
github merged 4 commits from gh-pr/130/head into gh-pr/130/base 2026-11-26 21:29:03 +00:00
Owner

@⁠danielradosa on GitHub · 2026-11-21 16:46 UTC · original
danielradosa:rcas-native-toward-zero → main · +25 −8 · 2 files · 4 commits · merged 2026-11-21 17:38 UTC

Change

The native RCAS check accepted a stored RGB9E5 word only if it matched nearest-even or round-to-nearest. The integrated AMD Radeon(TM) Graphics of a Ryzen 5 7600 (RDNA 2, vendor 1002, device 164e, driver 32.0.21045.29003) reports typed UAV stores for RGB9E5. That makes it the first physical adapter I know of to take the native path here: the RTX 4060 in the same PC, and the RTX 4060 Laptop in the docs, take the packed path, and before this the native path had only run on WARP. Its stores round the mantissas toward zero, so ffx_provider_loop_hardware failed on the first input where the rules differ:

RCAS texel=1 field=4 expected=08120000 actual=001ffe01

Texel 1 is (1, 511.5, 7.25) × 2⁻²⁴. Nearest-even gives exponent 1 and mantissas (0, 256, 4). The adapter stored exponent 0 and (1, 511, 7), which is the round-toward-zero encoding.

The D3D11.3 functional spec does not require nearest-even here. Section 19.3.2.2 (FLOAT -> RGBE) says conversion "should be done with nearest even. Round to nearest is allowed", and notes that hardware does not perform this conversion. Section 3.2.2 says "Round-to-zero must be used during conversion to another float format." The native check now also accepts a round-toward-zero word and reports how many texels needed each alternative (native_half_up, native_toward_zero). A store that mixes the two alternatives fails. The packed path still requires nearest-even. Refs #1, where I reported the failure.

Verification

A one-off local dump of all 1,024 stored words, classified against the three encoders (not part of this PR):

Adapter, path matches all three nearest-even and round-toward-zero only round-toward-zero only nearest-even only, or nearest-even and round-to-nearest
AMD Radeon, native (format 67) 482 225 317 0
RTX 4060, packed (format 42) 482 225 0 317

On both adapters, the SRV loads decode every stored word exactly.

Windows 11 build 26300.9974, MSVC 19.51.36256, debug layer enabled. The integrated GPU was selected with XBOX2WINDOWS_ADAPTER from #116. Each line below is ffx_provider_loop_hardware (or _warp):

Build AMD Radeon (native) RTX 4060 (packed) WARP (native, then forced packed)
main at fd1ff2a fails at texel 1 as above passes passes
this branch passes, native_toward_zero=317; the forced packed context passes with 0 passes, 0 and 0 passes, 0 and 0
ctest --preset dev --no-tests=error -R '^ffx_provider_loop_(hardware|warp)$' -V

Full suite on this branch, default adapter: 75 passed, 2 skipped (bvh_wave64_*), 0 failed. All 22 _hardware tests on the Radeon: 21 passed; dxr_update_hardware fails with the 1-ULP distance that #112 addresses.

Evidence and follow-up

Open question: the Xbox Series X GPU is also RDNA 2. If its native RGB9E5 stores also round toward zero, the packed fallback, which rounds to nearest-even in the shared HLSL helpers, can differ from the console by one mantissa step and in its exponent choice. Nothing here measures the console, so this stays a hypothesis.

AI-assisted.

**@⁠danielradosa** on GitHub · 2026-11-21 16:46 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/130) `danielradosa:rcas-native-toward-zero` → `main` · +25 −8 · 2 files · 4 commits · merged 2026-11-21 17:38 UTC ## Change The native RCAS check accepted a stored RGB9E5 word only if it matched nearest-even or round-to-nearest. The integrated AMD Radeon(TM) Graphics of a Ryzen 5 7600 (RDNA 2, vendor `1002`, device `164e`, driver `32.0.21045.29003`) reports typed UAV stores for RGB9E5. That makes it the first physical adapter I know of to take the native path here: the RTX 4060 in the same PC, and the RTX 4060 Laptop in the docs, take the packed path, and before this the native path had only run on WARP. Its stores round the mantissas toward zero, so `ffx_provider_loop_hardware` failed on the first input where the rules differ: ```text RCAS texel=1 field=4 expected=08120000 actual=001ffe01 ``` Texel 1 is (1, 511.5, 7.25) × 2⁻²⁴. Nearest-even gives exponent 1 and mantissas (0, 256, 4). The adapter stored exponent 0 and (1, 511, 7), which is the round-toward-zero encoding. The D3D11.3 functional spec does not require nearest-even here. Section 19.3.2.2 (FLOAT -> RGBE) says conversion "should be done with nearest even. Round to nearest is allowed", and notes that hardware does not perform this conversion. Section 3.2.2 says "Round-to-zero must be used during conversion to another float format." The native check now also accepts a round-toward-zero word and reports how many texels needed each alternative (`native_half_up`, `native_toward_zero`). A store that mixes the two alternatives fails. The packed path still requires nearest-even. Refs #1, where I reported the failure. ## Verification A one-off local dump of all 1,024 stored words, classified against the three encoders (not part of this PR): | Adapter, path | matches all three | nearest-even and round-toward-zero only | round-toward-zero only | nearest-even only, or nearest-even and round-to-nearest | |---|---|---|---|---| | AMD Radeon, native (format 67) | 482 | 225 | **317** | 0 | | RTX 4060, packed (format 42) | 482 | 225 | 0 | 317 | On both adapters, the SRV loads decode every stored word exactly. Windows 11 build 26300.9974, MSVC 19.51.36256, debug layer enabled. The integrated GPU was selected with `XBOX2WINDOWS_ADAPTER` from #116. Each line below is `ffx_provider_loop_hardware` (or `_warp`): | Build | AMD Radeon (native) | RTX 4060 (packed) | WARP (native, then forced packed) | |---|---|---|---| | `main` at fd1ff2a | fails at texel 1 as above | passes | passes | | this branch | passes, `native_toward_zero=317`; the forced packed context passes with 0 | passes, 0 and 0 | passes, 0 and 0 | ```powershell ctest --preset dev --no-tests=error -R '^ffx_provider_loop_(hardware|warp)$' -V ``` Full suite on this branch, default adapter: 75 passed, 2 skipped (`bvh_wave64_*`), 0 failed. All 22 `_hardware` tests on the Radeon: 21 passed; `dxr_update_hardware` fails with the 1-ULP distance that #112 addresses. ## Evidence and follow-up Open question: the Xbox Series X GPU is also RDNA 2. If its native RGB9E5 stores also round toward zero, the packed fallback, which rounds to nearest-even in the shared HLSL helpers, can differ from the console by one mantissa step and in its exponent choice. Nothing here measures the console, so this stays a hypothesis. _AI-assisted._
The native check accepted nearest-even or round-to-nearest words from a
typed RGB9E5 UAV store. The integrated AMD Radeon of a Ryzen 5 7600 (RDNA
2, driver 32.0.21045.29003) is the first physical adapter here that takes
the native path, and its stores round the mantissas toward zero: 317 of
the 1,024 inputs differ from nearest-even, all 1,024 match a
round-toward-zero encoding, and the SRV loads decode them exactly.

D3D11.3 section 19.3.2.2 recommends nearest-even for FLOAT -> RGBE and
allows round-to-nearest, noting that hardware does not perform the
conversion; section 3.2.2 makes round-to-zero the rule for conversion to
another float format. The native check now accepts round-toward-zero as
well, reports how many texels needed each alternative, and fails if one
store mixes them. The packed path still requires nearest-even.

Refs #1
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:29:01 +00:00
github manually merged commit 62cfefffd9 into gh-pr/130/base 2026-11-26 21:29:03 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-21 16:46 UTC · original · edited 2026-11-21 16:48 UTC

Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T16:48:48.839497Z 67b7f08 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-21 16:46 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/130#issuecomment-7065909325) · edited 2026-11-21 16:48 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"67b7f08d2050325044623522db6cd22533cbf53b","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-21T16:48:48.839497Z">2026-11-21T16:48:48.839497Z</relative-time> | `67b7f08` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠denn0x on GitHub · 2026-11-21 17:33 UTC · original

RDNA 4 data point for the native RCAS path. On the RX 9070 XT, ffx_provider_loop_hardware takes format 67 and rounds toward zero on the same 317 texels. I ran #125 and #130 on the same input, which is the comparison asked for on #125.

  • AMD Radeon RX 9070 XT (RDNA 4; vendor 1002, device 7550), driver 32.0.32015.7029, D3D12 debug layer enabled
  • Windows 11 build 26200, MSVC 19.50.35720, Windows SDK 10.0.26100.0 with its DXC
  • PR head commits as fetched, not merged with current main
ctest --preset dev --no-tests=error -R '^(dxr_update|ffx_provider_loop)_(hardware|warp)$' -V
Build ffx_provider_loop_hardware ffx_provider_loop_warp
main at 245b207 fails: RCAS texel=1 field=4 expected=08120000 actual=001ffe01 passes, native_half_up=0 mismatches=0 for formats 67 and 42
#130 head 737dec0 passes: format 67 native_half_up=0 native_toward_zero=317 mismatches=0; format 42 native_toward_zero=0 mismatches=0 passes, 0 alternative-rounded texels
#125 head 23bbb2d passes: format 67 native_trunc=317 mismatches=0; format 42 native_trunc=0 mismatches=0 passes, 0 alternative-rounded texels

Every run reports debug_errors=0 debug_warnings=0. Both PRs fix the failure here and count the same 317 texels. The Ryzen 5 7600 iGPU in #130 (RDNA 2, driver 32.0.21045.29003) gave the same first mismatch and the same 317. That makes two AMD architectures on two driver branches that store round-toward-zero on this path. The console is still unmeasured.

AI-assisted (Claude Code); run locally on the configuration above.

**@⁠denn0x** on GitHub · 2026-11-21 17:33 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/130#issuecomment-7066576607) RDNA 4 data point for the native RCAS path. On the RX 9070 XT, `ffx_provider_loop_hardware` takes format 67 and rounds toward zero on the same 317 texels. I ran #125 and #130 on the same input, which is the comparison asked for on #125. - AMD Radeon RX 9070 XT (RDNA 4; vendor 1002, device 7550), driver 32.0.32015.7029, D3D12 debug layer enabled - Windows 11 build 26200, MSVC 19.50.35720, Windows SDK 10.0.26100.0 with its DXC - PR head commits as fetched, not merged with current `main` ```powershell ctest --preset dev --no-tests=error -R '^(dxr_update|ffx_provider_loop)_(hardware|warp)$' -V ``` | Build | `ffx_provider_loop_hardware` | `ffx_provider_loop_warp` | |---|---|---| | `main` at 245b207 | fails: `RCAS texel=1 field=4 expected=08120000 actual=001ffe01` | passes, `native_half_up=0 mismatches=0` for formats 67 and 42 | | #130 head 737dec0 | passes: format 67 `native_half_up=0 native_toward_zero=317 mismatches=0`; format 42 `native_toward_zero=0 mismatches=0` | passes, 0 alternative-rounded texels | | #125 head 23bbb2d | passes: format 67 `native_trunc=317 mismatches=0`; format 42 `native_trunc=0 mismatches=0` | passes, 0 alternative-rounded texels | Every run reports `debug_errors=0 debug_warnings=0`. Both PRs fix the failure here and count the same 317 texels. The Ryzen 5 7600 iGPU in #130 (RDNA 2, driver 32.0.21045.29003) gave the same first mismatch and the same 317. That makes two AMD architectures on two driver branches that store round-toward-zero on this path. The console is still unmeasured. _AI-assisted (Claude Code); run locally on the configuration above._
This discussion has been locked. Commenting is limited to contributors.
No description provided.