gpu: preserve precision in scaled DXR reference rays #206

Merged
Vonsek merged 1 commit from upstream-pr/209 into main 2026-11-21 18:42:40 +00:00
Vonsek commented 2026-11-21 18:26:04 +00:00 (Migrated from github.com)

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


Change

Compute the inverse instance scale in double precision when transforming a ray direction for the DXR CPU reference. For a triangle at world z = 1.5 and a ray starting at z = −0.5, the previous float division produced a distance slightly below 2. That caused the reference to accept a hit at its open upper endpoint.

Add a z-scaled instance to the existing facing fixture and check the clipped ray separately on the CPU. The regular DXR comparison exercises both primitives from both directions with three culling flag settings.

Verification

Windows x64 build 26200, MSVC 19.44.35230, Debug, based on 1a88110.

. ./tools/dev.ps1
cmake --preset dev
cmake --build --preset dev --target offscreen_check
ctest --preset dev --no-tests=error -R '^dxr_facing_' -V

With the new fixture and the previous direction transform both cases failed before the GPU trace, reporting Scaled CPU ray: expected miss at farT=2, instance=8 t=1.9999999403953568.

With double-precision direction division, the CPU rejected the clipped ray and reproduced the hand-derived distances and facing table for all 96 interior rays. Both CTests passed with zero skips:

Backend Driver DXR tier Interior rays Hits Front hits Culled Mismatches
NVIDIA GeForce RTX 5080 32.0.16.1692 1.2 96 72 36 24 0
Microsoft Basic Render Driver (WARP) 10.0.26100.9818 1.1 96 72 36 24 0

The existing twelve shared-edge and control rays also passed on each backend. The D3D12 debug layer was unavailable.

Evidence and follow-up

The fixture consists of original MIT-licensed C++ geometry and rays. The added instance scales world z by 1.5, so the unit z direction becomes 2/3 in object space. The CPU comparison checks exact hit distances of 2 and 3 for the interior probes. The GPU comparison uses the existing relative tolerance. Only the CPU receives the endpoint probe.

This contribution was AI-assisted.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated the DXR facing experiment in docs/experiments.md.
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6532723983 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/209). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T18:26:04Z. --- ## Change Compute the inverse instance scale in double precision when transforming a ray direction for the DXR CPU reference. For a triangle at world z = 1.5 and a ray starting at z = −0.5, the previous float division produced a distance slightly below 2. That caused the reference to accept a hit at its open upper endpoint. Add a z-scaled instance to the existing facing fixture and check the clipped ray separately on the CPU. The regular DXR comparison exercises both primitives from both directions with three culling flag settings. ## Verification Windows x64 build 26200, MSVC 19.44.35230, Debug, based on `1a88110`. ```powershell . ./tools/dev.ps1 cmake --preset dev cmake --build --preset dev --target offscreen_check ctest --preset dev --no-tests=error -R '^dxr_facing_' -V ``` With the new fixture and the previous direction transform both cases failed before the GPU trace, reporting `Scaled CPU ray: expected miss at farT=2, instance=8 t=1.9999999403953568`. With double-precision direction division, the CPU rejected the clipped ray and reproduced the hand-derived distances and facing table for all 96 interior rays. Both CTests passed with zero skips: | Backend | Driver | DXR tier | Interior rays | Hits | Front hits | Culled | Mismatches | |---|---|---:|---:|---:|---:|---:|---:| | NVIDIA GeForce RTX 5080 | 32.0.16.1692 | 1.2 | 96 | 72 | 36 | 24 | 0 | | Microsoft Basic Render Driver (WARP) | 10.0.26100.9818 | 1.1 | 96 | 72 | 36 | 24 | 0 | The existing twelve shared-edge and control rays also passed on each backend. The D3D12 debug layer was unavailable. ## Evidence and follow-up The fixture consists of original MIT-licensed C++ geometry and rays. The added instance scales world z by 1.5, so the unit z direction becomes 2/3 in object space. The CPU comparison checks exact hit distances of 2 and 3 for the interior probes. The GPU comparison uses the existing relative tolerance. Only the CPU receives the endpoint probe. This contribution was AI-assisted. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated the DXR facing experiment in `docs/experiments.md`. - [x] I did not include game files, dumps, distribution links or secrets.
upstream-sync closed this pull request 2026-11-24 06:41:49 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:47:49 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T18:26:14Z.


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-21T18:28:37.480624Z 760593e 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:7067253567 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/209#issuecomment-7067253567). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T18:26:14Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"760593ead6c834d6b441a8d17e2441cbc3c6fe27","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-21T18:28:37.480624Z">2026-11-21T18:28:37.480624Z</relative-time> | `760593e` | 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>
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!206
No description provided.