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

Manually merged
github merged 1 commit from gh-pr/118/head into gh-pr/118/base 2026-11-26 21:28:12 +00:00
Owner

@⁠Vonsek on GitHub · 2026-11-21 16:31 UTC · original
Vonsek:dxr-ray-flags → main · +223 −6 · 8 files · 1 commits · merged 2026-11-21 17:56 UTC

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.

**@⁠Vonsek** on GitHub · 2026-11-21 16:31 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/118) `Vonsek:dxr-ray-flags` → `main` · +223 −6 · 8 files · 1 commits · merged 2026-11-21 17:56 UTC ## 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:28:10 +00:00
github manually merged commit 17cf485dc5 into gh-pr/118/base 2026-11-26 21:28:12 +00:00
Author
Owner

@⁠rasptum on GitHub · 2026-11-21 16:49 UTC · original

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.

**@⁠rasptum** on GitHub · 2026-11-21 16:49 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/118#issuecomment-7065953014) 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._
Author
Owner

@⁠Vonsek on GitHub · 2026-11-21 17:04 UTC · original

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.

**@⁠Vonsek** on GitHub · 2026-11-21 17:04 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/118#issuecomment-7066189869) 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.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-21 17:16 UTC · original

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.

**@⁠R0Y00** on GitHub · 2026-11-21 17:16 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/118#issuecomment-7066344764) 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.