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

Merged
danielradosa merged 4 commits from upstream-pr/130 into main 2026-11-21 17:38:57 +00:00
danielradosa commented 2026-11-21 16:46:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by danielradosa on 2026-11-21T16:46:23Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6531622563 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/130). Originally posted by [danielradosa](https://github.com/danielradosa) on 2026-11-21T16:46:23Z. --- ## 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._
upstream-sync closed this pull request 2026-11-24 06:41:27 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:47:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T16:46:33Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7065909325 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/130#issuecomment-7065909325). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T16:46:33Z. --- <!-- 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>
denn0x commented 2026-11-24 06:47:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by denn0x on 2026-11-21T17:33:52Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7066576607 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/130#issuecomment-7066576607). Originally posted by [denn0x](https://github.com/denn0x) on 2026-11-21T17:33:52Z. --- 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._
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
R0Y00/Xbox2Windows!129
No description provided.