Compare DXR opacity and non-opaque candidate handling with a CPU reference #216
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!216
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/216/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Vonsek on GitHub · 2026-11-21 18:30 UTC · original
Vonsek:dxr-opacity-candidates→main· +437 −14 · 9 files · 5 commits · merged 2026-11-22 07:36 UTCChange
Adds
dxr_opacity_warpanddxr_opacity_hardware, a differential check of triangle opacity, opacity culling and first-hit search between a CPU reference and inline DXR queries. Every existing DXR fixture builds one geometry withD3D12_RAYTRACING_GEOMETRY_FLAG_OPAQUEand traces withRayQuery<RAY_FLAG_FORCE_OPAQUE>, so no non-opaque candidate has reached a shader so far, andRAY_FLAG_CULL_OPAQUE/CULL_NON_OPAQUEcannot be combined with that template flag.A BLAS holds four single-triangle geometries stacked along z at depths 1 to 4; geometries 1 and 3 are opaque. Three instances use no flags,
D3D12_RAYTRACING_INSTANCE_FLAG_FORCE_OPAQUEandD3D12_RAYTRACING_INSTANCE_FLAG_FORCE_NON_OPAQUE. Each receives 42 rays: both directions along z, seven ray flag sets (NONE,FORCE_OPAQUE,FORCE_NON_OPAQUE,CULL_OPAQUE,CULL_NON_OPAQUE,ACCEPT_FIRST_HIT_AND_END_SEARCHalone and withFORCE_NON_OPAQUE) and three accept masks. The newtests/ray_candidates.hlsldeclaresRayQuery<RAY_FLAG_NONE>, commits a non-opaque candidate when its geometry index is in the ray's accept mask (a fixture convention in bits 16-19 of the flags word), and reports per ray: committed status, instance ID, geometry and primitive index, distance, the set of presented candidate geometries, whether any candidate was presented after a commit, and whether any candidate was not a non-opaque triangle inside the ray extents and in front of the current committed hit.dxr_fixture::tracegains an optional per-triangle geometry flags list. When given, each triangle becomes its own geometry andray_candidates.hlsltraces the rays. Existing callers pass nothing and keep one opaque geometry andray_query.hlsl.Verification
ctest --preset dev --no-tests=error -R '^dxr_opacity_' -Vatf069a47on Windows 11 build 26200.9974, VS Build Tools 2022 17.14 (MSVC 14.44.35207), Windows SDK 10.0.26100 (DXC 1.9.2602.17), D3D12 debug layer unavailable: 2/2 passed.dxr_tier=12:dxr_opacity rays=126 hits=94 shader_commits=42 misses=32 first_hit_rays=36 mismatches=0dxr_tier=11:dxr_opacity rays=126 hits=94 shader_commits=42 misses=32 first_hit_rays=36 mismatches=0 warp_after_commit=11 committed_t_plus_tmin=0mismatches=11, first lineray=15 flags=0x4 expected hit=1 instance=1 geometry=1 distance=2 committable=0xa candidates required=0x0 allowed=0x5 actual word0=0x503 instance=1 geometry=1 primitive=0 distance=2. The second (relaxing only automatic opaque commits) gave WARPmismatches=10 after_shader_commit=10 after_opaque_commit=2 warp_after_commit=1, withafter_shader_commiton rays 19, 20, 61, 62, 100, 101, 103 and 104 and both kinds on rays 16 and 17. In every one of these rays the final committed hit matched the reference; all 11 are the first-hit case described under Evidence. The RTX 5080 gavemismatches=0in all four runs. An independent run by @denn0x atf069a47on an RX 9070 XT (RDNA 4, driver 32.0.32015.7029) with the D3D12 debug layer enabled reportedmismatches=0 committed_t_plus_tmin=43anddebug_errors=0 debug_warnings=0on hardware, and the same WARP result as above.ctest --preset dev --no-tests=error -R '^dxr_(query|update|facing|opacity)_(warp|hardware)$' -Vpassed 8/8 on both backends (dxr_facing rays=84 hits=64 front_hits=32 culled=20 mismatches=0). The fullctest --preset dev --no-tests=errorpassed 123/123, withbvh_wave64_hardware,bvh_wave64_warpandwave_shuffle_warpskipped.check_dxr_opacitywas also linked against a stand-in trace that follows the specification's traversal with a random visit order per ray; it passed with 200 different orders. Fault controls all failed the check: ignoring instance flags (34-40 mismatches), letting instance flags override ray flags (18), not ending a first-hit search at a shader commit (12-16), dropping presented candidates (64-65), and treating every triangle as opaque as the existingRAY_FLAG_FORCE_OPAQUEquery does (73).mismatches=22and the WARP path passes withwarp_after_commit=22, while every other injected fault (ignored instance flags, swapped precedence, dropped candidates, all-opaque, unaccepted commits) still fails on the WARP path.Evidence and follow-up
The fixture is synthetic and original to this repository (MIT). Expected values come from
tests/dxr_opacity_reference.h, which intersects every triangle in double precision and applies the specification's opacity order: rayFORCE_OPAQUE/FORCE_NON_OPAQUEoverride instanceFORCE_OPAQUE/FORCE_NON_OPAQUE, which override the geometry flag;CULL_OPAQUE/CULL_NON_OPAQUEthen remove primitives by the resulting opacity. Ignoring instance flags alone would change the closest hit on 26 of the 126 rays. Ray flags · Instance flags · TraceRayInline control flowWithout the first-hit flag the result must equal the closest committable hit exactly. With it, the query may end on any committable hit, but no candidate may be presented after a commit. Each non-opaque triangle in front of the closest hit, and each committed one, must have been presented, and nothing else may be. Hit distances of 1 to 4 may differ by 1e-5 relative. Candidate counts and visit order are implementation-defined and are not compared. Rays cross triangle interiors well inside the distance interval, so edge and endpoint rules stay out of scope. The test skips below DXR tier 1.1 or Shader Model 6.5.
Committed distance on RDNA 4. The specification defines both
CommittedRayT()andCandidateTriangleRayT()as the parametric distance from the ray origin. On an RX 9070 XT, every hit committed by the shader withCommitNonOpaqueTriangleHit()reportedCommittedRayT()equal to the candidate's distance plus the ray's TMin; automatic opaque commits were correct. The shader recordsCandidateTriangleRayTat each shader commit, and a shader-committed hit with the right instance, geometry, primitive and candidate distance whose committed distance is exactly that distance plus TMin (0.25 for every ray) is counted ascommitted_t_plus_tmininstead of failing. Any other distance error still fails. A candidate at exactly the committed distance is allowed (t <= limit), because an implementation may present the committed triangle or an equal-distance one again; candidates behind the committed hit or outside the ray extents are still flagged.Known WARP deviation. WARP 10.0.26100.9818 does not end a first-hit search at a committed hit, automatic or shader (specification: Ray flags,
RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH; TraceRayInline control flow, note 6). It keeps presenting nearer non-opaque candidates, but its final committed hit stays valid. The RTX 5080 follows the rule. On WARP only, the test counts such a ray aswarp_after_commitand does not fail on it, provided the final hit is committable and every other check on that ray passes. Hardware stays fully strict.Reproduction details are in docs/experiments.md. Follow-up: add
dxr-opacityto the standalone GPU package runner, and extend the fixture to procedural primitives withCommitProceduralPrimitiveHit.@chatgpt-codex-connector[bot] on GitHub · 2026-11-21 18:52 UTC · original · edited 2026-11-21 18:58 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
9a73480ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-21 18:58 UTC · original
For a closest-hit query that accepts a non-opaque triangle, DXR can present the same primitive more than once, including at the current committed distance. For example, presenting geometry 0 twice at distance 1 for ray 1 leaves the final hit and candidate masks valid, but the second visit has
t == q.CommittedRayT(), so this strict comparison setsanomalyand makescheck_dxr_opacityfail on a valid traversal. Allow equality at the committed upper bound, or explicitly handle repeated candidates; placing different geometries at unique depths does not prevent duplicate visits to the same primitive.Useful? React with 👍 / 👎.
@denn0x on GitHub · 2026-11-21 19:06 UTC · original
Independent run at
9a73480on RDNA 4.dxr_opacity_hardwarefails, and every mismatch is a hit the shader committed. In each one,CommittedRayT()is the true distance plus the ray'sTMin.Environment: Windows 11 build 26200, MSVC 19.50.35720, Windows SDK 10.0.26100.0, DXC 1.8.2502, D3D12 debug layer enabled on both backends.
First mismatch:
Measured on the unmodified head:
committed_hitonly.TMin= 0.25.-R '^dxr_(query|update|facing|opacity)_(warp|hardware)$'gives 7/8. The only failure isdxr_opacity_hardware;dxr_query,dxr_updateanddxr_facingpass on both backends.Local probes. These are diagnostic edits only, reverted, and not proposed changes:
TMin= 0.125 indxr_opacity_reference.h: still 43 mismatches, each now off by exactly +0.125.TMin= 0: classifying all 126 rays, the hardware matches the reference on every category. All 51 automatic opaque commits are exact in all three runs.CandidateTriangleRayT()at the commit instead ofCommittedRayT()(TMin= 0.25): all 43 shader-committed rays then have the exact distance. The candidate distance is correct; only the committed distance read back afterCommitNonOpaqueTriangleHit()is offset.Hypothesis, not established: this looks like a driver-side difference in how the committed T of a shader-committed triangle is stored or returned (t + TMin), similar to an origin-relative versus TMin-relative mix-up. I did not test whether the driver also uses the offset value to bound later candidates. The fixture's 1.0 spacing between triangles is much larger than 0.25, so it cannot show that.
I'm not suggesting any relaxation of the strict hardware check; how to treat this is your call. I can rerun any revision on this GPU.
AI-assisted (Claude Code).
@denn0x on GitHub · 2026-11-21 19:43 UTC · original
Rerun at
f069a47on the same machine: RX 9070 XT (driver 32.0.32015.7029) and WARP 10.0.26100.9818, Windows 11 build 26200, DXC 1.8.2502, debug layer enabled on both.committed_t_plus_tmin=43. That is the same 43 shader-committed rays as before, now reported rather than failed, and in each one the recorded candidate distance is exact.warp_after_commit=11as before.dxr_query,dxr_updateanddxr_facingpass on both backends (dxr_facing rays=96 hits=72 front_hits=36 culled=24 mismatches=0).On the
t <= limitchange: at9a73480, with the strictt < limit, this GPU reported nocandidate_out_of_rangeon any ray. So RDNA 4 does not need the equality allowance in this fixture.AI-assisted (Claude Code).
@Vonsek on GitHub · 2026-11-21 19:49 UTC · original
Agreed. The range check now allows a candidate at exactly the committed distance (
t <= limit), because an implementation may present the committed triangle or an equal-distance one again. Candidates behind the committed hit or outside the ray extents are still flagged.@Vonsek on GitHub · 2026-11-21 19:49 UTC · original
@denn0x Thanks for the RDNA 4 runs. The shader now records
CandidateTriangleRayTat eachCommitNonOpaqueTriangleHit(). A shader-committed hit with correct identity and candidate distance whoseCommittedRayT()equals that distance plus TMin is reported ascommitted_t_plus_tmininstead of failing. Any other distance error still fails, since the spec defines both as the parametric distance from the ray origin. Your rerun atf069a47(mismatches=0 committed_t_plus_tmin=43,debug_errors=0) is now in the description, along with your note that the strictt < limitwas already enough on RDNA 4.Here at
f069a47, Windows 11 26200.9974: RTX 5080 (driver 32.0.16.1692)mismatches=0 committed_t_plus_tmin=0, WARPmismatches=0 warp_after_commit=11 committed_t_plus_tmin=0; the DXR regression set passed 8/8 and the full suite 123/123.@R0Y00 on GitHub · 2026-11-21 20:01 UTC · original
Please use the same committed-distance check on every adapter. Compute the expected distance from the ray origin for the legal geometry the query actually committed, using the existing floating-point tolerance. If a ray reports the expected distance plus
TMin, increment bothcommitted_t_plus_tminand the committed mismatch count, and fail that device test. Keep the existing first-hit selection rules, equal-distance candidate allowance, and separate WARPwarp_after_commitaccounting.Please include a negative control that injects
+TMinand shows the test fails. Record the 43 observed cases on the RX 9070 XT (driver 32.0.32015.7029) with the tested SHA. @denn0x, could you rerun the hardware test on the revised head and post the counts? A documented hardware failure is a valid experimental result. Once the oracle and its controls are verified and required Windows CI passes, merge can proceed independently of a driver fix.@denn0x on GitHub · 2026-11-21 20:09 UTC · original
@R0Y00 Will do. When Vonsek pushes the revised head, I will rerun
ctest --preset dev --no-tests=error -R '^dxr_(query|update|facing|opacity)_(warp|hardware)$' -Von the RX 9070 XT (driver 32.0.32015.7029) and WARP, and post the counts with the tested SHA. The latest result is still the one atf069a47above.AI-assisted (Claude Code).
@roansystemlabs on GitHub · 2026-11-21 23:22 UTC · original
An NVIDIA Ampere data point for
dxr_opacity, to sit next to the RTX 5080 (Blackwell) and RX 9070 XT (RDNA 4) results.Environment: Windows 11 build 26200, NVIDIA GeForce RTX 3070 (
10de:2484, driver 32.0.16.2101), WARP 10.0.26100.9818, MSVC 19.44.35230 (VS Build Tools 2022), Windows SDK 10.0.26100.0 DXC, Python 3.12. D3D12 debug layer not installed on this PC (debug_layer=unavailable).Tested head:
f069a47d217d4ad0bcb39b8e838f241b77c09160, i.e. the head before the revision requested in the latest review (strict committed-distance check on every adapter and the+TMinnegative control).Full suite: 123/123 passed, 3 capability skips (
bvh_wave64_hardware,bvh_wave64_warp,wave_shuffle_warp, the same as onmainon this PC).DXR set: 8/8 passed in each of 3 runs, identical counts every time:
So on Ampere
CommittedRayT()for shader-committed non-opaque hits is the distance from the ray origin (committed_t_plus_tmin=0), as on the RTX 5080; the+TMinoffset is so far only seen on RDNA 4. I'll confirm the stricter check on this GPU once the revised head is up.AI-assisted: run and prepared with the support of Roan System.
@denn0x on GitHub · 2026-11-22 07:42 UTC · original
Rerun of the merged revision at
7f13b7f(main), as promised above. The environment is the same machine: RX 9070 XT (driver 32.0.32015.7029) and WARP 10.0.26100.9818, Windows 11 build 26200, MSVC 19.50.35720, Windows SDK 10.0.26100.0, with the D3D12 debug layer enabled on both backends.dxr_opacity_hardwarefails by design, as the review asked. All 43 mismatches arecommitted_hit, and each is also counted incommitted_t_plus_tmin. The count matches the 43 shader-committed rays measured atf069a47. The log prints 16 of the 43 rays. In each of them, the committed distance is the candidate distance recorded at the shader's commit (shader_commit_t) plus 0.25. For example, ray 1 hasexpected ... distance=1andactual ... distance=1.25 shader_commit_t=1. In 13 of the 16, the committed geometry is the reference's closest hit. Rays 16, 17 and 19 setRAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH(flag bit0x4) and commit geometry 2 atshader_commit_t=3, which is a legal first hit. No other distance error is reported.f069a47.dxr_query,dxr_updateanddxr_facingpass on both backends withdebug_errors=0 debug_warnings=0.AI-assisted (Claude Code).
@chatgpt-codex-connector[bot] on GitHub · 2026-11-21 18:58 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
9a73480357ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".