Allow round-to-zero mantissa truncation in check_rcas_views #124

Closed
Holastor wants to merge 1 commit from upstream-pr/125 into main
Holastor commented 2026-11-21 16:39:30 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-21T16:39:30Z.


Summary

Direct3D permits round-to-zero (truncation) when quantizing floating-point values into
DXGI_FORMAT_R9G9B9E5_SHAREDEXP textures. On AMD RDNA 2 hardware, native UAV stores to format 67 truncate
fractional mantissa steps on ties rather than rounding up and carrying into the next exponent field.

Specifically, at texel 1 (inputs[1]), AMD hardware stores 0x001ffe01 (mantissas 1, 511, 7 with exponent 0)
rather than carrying into exponent 1 (0x08120000).

This change introduces RoundMode::Truncate alongside RoundMode::NearestEven and RoundMode::NearestHalfUp in
tests/ffx_rcas_views.cpp, allowing hardware stores adhering to Direct3D truncation rules to pass verification.

Test Matrix

  • Hardware: AMD Radeon RX 6600M (Vendor 0x1002, Device 0x73ff, Driver 32.0.21045.11001)
  • Suite: CTest full suite (70 passed, 1 skipped: bvh_wave64_warp, 0 failed)
  • Direct verification: offscreen_check.exe hardware --ffx-provider-loop passes with native_trunc=317,
    mismatches=0, debug_errors=0.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6531539626 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/125). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-21T16:39:30Z. --- ## Summary Direct3D permits round-to-zero (truncation) when quantizing floating-point values into `DXGI_FORMAT_R9G9B9E5_SHAREDEXP` textures. On AMD RDNA 2 hardware, native UAV stores to format 67 truncate fractional mantissa steps on ties rather than rounding up and carrying into the next exponent field. Specifically, at texel 1 (`inputs[1]`), AMD hardware stores `0x001ffe01` (mantissas 1, 511, 7 with exponent 0) rather than carrying into exponent 1 (`0x08120000`). This change introduces `RoundMode::Truncate` alongside `RoundMode::NearestEven` and `RoundMode::NearestHalfUp` in `tests/ffx_rcas_views.cpp`, allowing hardware stores adhering to Direct3D truncation rules to pass verification. ## Test Matrix - **Hardware**: AMD Radeon RX 6600M (Vendor `0x1002`, Device `0x73ff`, Driver `32.0.21045.11001`) - **Suite**: CTest full suite (70 passed, 1 skipped: `bvh_wave64_warp`, 0 failed) - **Direct verification**: `offscreen_check.exe hardware --ffx-provider-loop` passes with `native_trunc=317`, `mismatches=0`, `debug_errors=0`.
upstream-sync closed this pull request 2026-11-24 06:41:26 +00:00
R0Y00 commented 2026-11-24 06:47:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T17:16:30Z.


Thanks for the RX 6600M measurements. #130 covers the same native RGB9E5 rounding path. Please compare the two references on your original input and report whether #130 reproduces the result before we consolidate them.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7066349962 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/125#issuecomment-7066349962). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T17:16:30Z. --- Thanks for the RX 6600M measurements. #130 covers the same native RGB9E5 rounding path. Please compare the two references on your original input and report whether #130 reproduces the result before we consolidate them.
Holastor commented 2026-11-24 06:47:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Holastor on 2026-11-21T17:43:07Z.


@R0Y00 I verified the reference from #130 against the same inputs on the discrete AMD Radeon RX 6600M (vendor 1002,
device 73ff, driver 32.0.21045.11001).

The results are identical:

  • Exactly 317 of the 1,024 texels require round-toward-zero mantissa conversion (native_toward_zero=317,
    native_half_up=0, mismatches=0).
  • The mixed-mode check in #130 passes (native_half_up && native_toward_zero is not triggered).
  • 0 debug errors and 0 debug warnings.

Both reference formulas evaluate to std::floor(scaled) on the non-negative clamped inputs. The implementation
in #130 with the extra mixed-mode check and documentation in docs/experiments.md is clean and comprehensive.
Happy to consolidate in favor of #130!

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7066692153 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/125#issuecomment-7066692153). Originally posted by [Holastor](https://github.com/Holastor) on 2026-11-21T17:43:07Z. --- @R0Y00 I verified the reference from #130 against the same inputs on the discrete AMD Radeon RX 6600M (vendor `1002`, device `73ff`, driver `32.0.21045.11001`). The results are identical: - Exactly **317 of the 1,024 texels** require round-toward-zero mantissa conversion (`native_toward_zero=317`, `native_half_up=0`, `mismatches=0`). - The mixed-mode check in #130 passes (`native_half_up && native_toward_zero` is not triggered). - 0 debug errors and 0 debug warnings. Both reference formulas evaluate to `std::floor(scaled)` on the non-negative clamped inputs. The implementation in #130 with the extra mixed-mode check and documentation in `docs/experiments.md` is clean and comprehensive. Happy to consolidate in favor of #130!
R0Y00 commented 2026-11-24 06:47:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-21T18:08:04Z.


Closing as a duplicate of merged #130. Thank you for rerunning the original inputs on the RX 6600M. Your report confirms 317 of 1,024 texels used round-toward-zero, with zero mismatches and a clean debug layer.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7067026617 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/125#issuecomment-7067026617). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T18:08:04Z. --- Closing as a duplicate of merged #130. Thank you for rerunning the original inputs on the RX 6600M. Your report confirms 317 of 1,024 texels used round-toward-zero, with zero mismatches and a clean debug layer.

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
R0Y00/Xbox2Windows!124
No description provided.