Compare DXR face culling with a CPU reference under mirrored instances #117

Merged
Vonsek merged 1 commit from upstream-pr/118 into main 2026-11-21 17:56:13 +00:00
Vonsek commented 2026-11-21 16:31:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T16:31:37Z.


Change

Adds dxr_facing_warp and dxr_facing_hardware, a differential check of triangle facing and face culling between a CPU reference and inline DXR queries. The existing DXR fixtures only trace with RAY_FLAG_NONE.

One two-triangle BLAS is instanced seven times: plain, TRIANGLE_FRONT_COUNTERCLOCKWISE, TRIANGLE_CULL_DISABLE, and mirrored on x, y or z with non-uniform scale. Each instance receives twelve rays covering both triangles, both directions along world z, and RAY_FLAG_NONE, RAY_FLAG_CULL_BACK_FACING_TRIANGLES and RAY_FLAG_CULL_FRONT_FACING_TRIANGLES. For each of the 84 rays the shader reports hit status, CommittedTriangleFrontFace, instance ID, primitive index and distance.

ray_query.hlsl and dxr_fixture::Ray gain a per-ray flags word. Existing callers pass zero, which keeps their trace and output unchanged.

Verification

ctest --preset dev --no-tests=error -R '^dxr_facing_' -V
ctest --preset dev --no-tests=error -R '^(dxr_(query|update|facing)|bvh_(differential|hits|packed))_(warp|hardware)$' -V

At 17cf485 (rebased on main with #99) on Windows 11 build 26200.9974, VS Build Tools 2022 17.14 (MSVC 14.44.35207), Windows SDK 10.0.26100 (DXC): the first command passed 2/2 and the second 12/12.

  • NVIDIA GeForce RTX 5080, driver 32.0.16.1692, dxr_tier=12: dxr_facing rays=84 hits=64 front_hits=32 culled=20 mismatches=0
  • WARP (Microsoft Basic Render Driver), dxr_tier=11: dxr_facing rays=84 hits=64 front_hits=32 culled=20 mismatches=0

Both report debug_layer=unavailable, so no debug-layer messages were checked.

On Linux the header-only reference compiled with g++ -std=c++17 -Wall -Wextra -pedantic and agreed with the hand-derived table on all 84 rays: 64 hits, 32 front facing, 20 culled.

Evidence and follow-up

The fixture is synthetic and original to this repository (MIT). Expected values come from tests/dxr_facing_reference.h, which moves each ray into object space, intersects every triangle in double precision and applies three rules from the DXR specification: clockwise from the ray origin in a left-handed frame is front facing, winding is evaluated in object space so a negative-determinant instance transform does not change facing, and both cull flags have no effect on a cull-disabled instance. The test first checks that reference against a hand-derived table of front and back letters. A world-space winding test would disagree on 48 of the 84 rays, all on the mirrored instances. Ray flags · Instance flags

Status, facing, instance and primitive must match exactly. Hit distances of 2 or 3 may differ by 1e-5 relative. Rays cross triangle interiors inside the distance interval, so edge and endpoint rules are out of scope. The custom BVH shader has no facing rule and is not part of this comparison. The test skips below DXR tier 1.1 or Shader Model 6.5. The D3D12 debug layer was not available on the test machine.

Reproduction details are in docs/experiments.md. Follow-up another contributor can pick up: add dxr-facing to the standalone GPU package runner, and run the test on AMD and Intel adapters.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6531458862 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/118). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T16:31:37Z. --- ## Change Adds `dxr_facing_warp` and `dxr_facing_hardware`, a differential check of triangle facing and face culling between a CPU reference and inline DXR queries. The existing DXR fixtures only trace with `RAY_FLAG_NONE`. One two-triangle BLAS is instanced seven times: plain, `TRIANGLE_FRONT_COUNTERCLOCKWISE`, `TRIANGLE_CULL_DISABLE`, and mirrored on x, y or z with non-uniform scale. Each instance receives twelve rays covering both triangles, both directions along world z, and `RAY_FLAG_NONE`, `RAY_FLAG_CULL_BACK_FACING_TRIANGLES` and `RAY_FLAG_CULL_FRONT_FACING_TRIANGLES`. For each of the 84 rays the shader reports hit status, `CommittedTriangleFrontFace`, instance ID, primitive index and distance. `ray_query.hlsl` and `dxr_fixture::Ray` gain a per-ray flags word. Existing callers pass zero, which keeps their trace and output unchanged. ## Verification ```powershell ctest --preset dev --no-tests=error -R '^dxr_facing_' -V ctest --preset dev --no-tests=error -R '^(dxr_(query|update|facing)|bvh_(differential|hits|packed))_(warp|hardware)$' -V ``` At 17cf485 (rebased on main with #99) on Windows 11 build 26200.9974, VS Build Tools 2022 17.14 (MSVC 14.44.35207), Windows SDK 10.0.26100 (DXC): the first command passed 2/2 and the second 12/12. - NVIDIA GeForce RTX 5080, driver 32.0.16.1692, `dxr_tier=12`: `dxr_facing rays=84 hits=64 front_hits=32 culled=20 mismatches=0` - WARP (Microsoft Basic Render Driver), `dxr_tier=11`: `dxr_facing rays=84 hits=64 front_hits=32 culled=20 mismatches=0` Both report `debug_layer=unavailable`, so no debug-layer messages were checked. On Linux the header-only reference compiled with `g++ -std=c++17 -Wall -Wextra -pedantic` and agreed with the hand-derived table on all 84 rays: 64 hits, 32 front facing, 20 culled. ## Evidence and follow-up The fixture is synthetic and original to this repository (MIT). Expected values come from `tests/dxr_facing_reference.h`, which moves each ray into object space, intersects every triangle in double precision and applies three rules from the DXR specification: clockwise from the ray origin in a left-handed frame is front facing, winding is evaluated in object space so a negative-determinant instance transform does not change facing, and both cull flags have no effect on a cull-disabled instance. The test first checks that reference against a hand-derived table of front and back letters. A world-space winding test would disagree on 48 of the 84 rays, all on the mirrored instances. [Ray flags](https://microsoft.github.io/DirectX-Specs/d3d/Raytracing.html#ray-flags) · [Instance flags](https://microsoft.github.io/DirectX-Specs/d3d/Raytracing.html#d3d12_raytracing_instance_flags) Status, facing, instance and primitive must match exactly. Hit distances of 2 or 3 may differ by 1e-5 relative. Rays cross triangle interiors inside the distance interval, so edge and endpoint rules are out of scope. The custom BVH shader has no facing rule and is not part of this comparison. The test skips below DXR tier 1.1 or Shader Model 6.5. The D3D12 debug layer was not available on the test machine. Reproduction details are in [docs/experiments.md](docs/experiments.md#face-culling-under-mirrored-instances). Follow-up another contributor can pick up: add `dxr-facing` to the standalone GPU package runner, and run the test on AMD and Intel adapters.
upstream-sync closed this pull request 2026-11-24 06:41:24 +00:00
rasptum commented 2026-11-24 06:47:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by rasptum on 2026-11-21T16:49:19Z.


Second Windows run at 909d9b5, on a different OS and GPU generation: Windows 10 22H2 (19045.6466), VS Build Tools 17.14 (MSVC 14.44.35207), SDK 10.0.26100, debug layer unavailable.

  • RTX 3060 (driver 32.0.15.9636, dxr_tier=12, SM 6.5): dxr_facing_hardware passed, dxr_facing rays=84 hits=64 front_hits=32 culled=20 mismatches=0, identical to the RTX 5080. dxr_query, dxr_update, bvh_hits, bvh_differential and bvh_packed hardware also passed.
  • Windows 10 WARP (10.0.19041.5794, dxr_tier=0, SM 6.2): dxr_facing_warp skipped, as did dxr_query_warp, dxr_update_warp and bvh_differential_warp. This exercises the below-tier-1.1 skip path, which your WARP (tier 1.1) could not reach.
  • bvh_hits_warp and bvh_packed_warp failed with E_INVALIDARG at pipeline creation. That is the Windows 10 WARP SM 6.2 issue fixed by #99, which this branch predates. It is not caused by this change.

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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7065953014 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/118#issuecomment-7065953014). Originally posted by [rasptum](https://github.com/rasptum) on 2026-11-21T16:49:19Z. --- Second Windows run at `909d9b5`, on a different OS and GPU generation: Windows 10 22H2 (19045.6466), VS Build Tools 17.14 (MSVC 14.44.35207), SDK 10.0.26100, debug layer unavailable. - **RTX 3060** (driver 32.0.15.9636, `dxr_tier=12`, SM 6.5): `dxr_facing_hardware` passed, `dxr_facing rays=84 hits=64 front_hits=32 culled=20 mismatches=0`, identical to the RTX 5080. `dxr_query`, `dxr_update`, `bvh_hits`, `bvh_differential` and `bvh_packed` hardware also passed. - **Windows 10 WARP** (10.0.19041.5794, `dxr_tier=0`, SM 6.2): `dxr_facing_warp` **skipped**, as did `dxr_query_warp`, `dxr_update_warp` and `bvh_differential_warp`. This exercises the below-tier-1.1 skip path, which your WARP (tier 1.1) could not reach. - `bvh_hits_warp` and `bvh_packed_warp` failed with `E_INVALIDARG` at pipeline creation. That is the Windows 10 WARP SM 6.2 issue fixed by #99, which this branch predates. It is not caused by this change. _AI-assisted (Claude Code); run locally on the configuration above._
Vonsek commented 2026-11-24 06:47:39 +00:00 (Migrated from github.com)

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


Thanks for the second run, and for covering the below-tier-1.1 skip path. I rebased the branch onto current main (now 17cf485), so it includes #99; on Windows 10 WARP, bvh_hits_warp and bvh_packed_warp should now skip at SM 6.2 instead of failing at pipeline creation. No change to the commit itself.

Re-run at 17cf485 on Windows 11 26200.9974 (RTX 5080, driver 32.0.16.1692, and WARP tier 1.1): the 12-test DXR/BVH regex passed 12/12, with dxr_facing rays=84 hits=64 front_hits=32 culled=20 mismatches=0 on both backends.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7066189869 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/118#issuecomment-7066189869). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T17:04:30Z. --- Thanks for the second run, and for covering the below-tier-1.1 skip path. I rebased the branch onto current main (now 17cf485), so it includes #99; on Windows 10 WARP, `bvh_hits_warp` and `bvh_packed_warp` should now skip at SM 6.2 instead of failing at pipeline creation. No change to the commit itself. Re-run at 17cf485 on Windows 11 26200.9974 (RTX 5080, driver 32.0.16.1692, and WARP tier 1.1): the 12-test DXR/BVH regex passed 12/12, with `dxr_facing rays=84 hits=64 front_hits=32 culled=20 mismatches=0` on both backends.
R0Y00 commented 2026-11-24 06:47:39 +00:00 (Migrated from github.com)

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


I am taking #116 first in the shared offscreen harness. Please sync after it lands and retain both the hardware/WARP facing comparisons and the capability skip.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7066344764 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/118#issuecomment-7066344764). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-21T17:16:08Z. --- I am taking #116 first in the shared offscreen harness. Please sync after it lands and retain both the hardware/WARP facing comparisons and the capability skip.
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!117
No description provided.