Recompiler: emit DXR 1.1 RayQuery and acceleration-structure SRVs #3659

Open
Kalmarv wants to merge 1 commit from upstream-pr/3659 into main
Kalmarv commented 2026-12-02 04:41:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T04:41:58Z.


Add direct-DXIL DXR 1.1 RayQuery emission and RaytracingAccelerationStructure SRV support to gpu::dxil::Shader. Nothing calls the new helpers yet, so default runtime behavior is unchanged; Live caller: #3705 (XCL_HW_RT_TRAVERSE=1 swaps GPURT traversal loops for heap_accel_struct + trace_any_hit / trace_translucent). Part of #1751.

Related: #2189 lowers RayQuery through the HLSL path (gpu/recomp/rayquery.rs); this PR is the direct-DXIL emitter (gpu/dxil), with no shared files.

(Why this is 951 lines and not split further: ~205 lines are the direct-DXIL RayQuery emitter and Shader plumbing, and ~746 lines are the DXIL 1.9 validator, shader-model guard, and WARP execution tests for this same emitter, kept together because CONTRIBUTING.md requires new code to ship with its tests.)

What is in it

  • crates/xcl/src/gpu/dxil/ray_query.rs:
    • RaytracingAccelerationStructure SRV bindings (static t# binding and ResourceDescriptorHeap indexing requiring SM 6.6+, resource kind 16, U32 element type, PSV0 SrvRaw).
    • Direct DXIL opcodes for dx.op.allocateRayQuery (requiring SM 6.5+), rayQuery_TraceRayInline, rayQuery_Proceed, rayQuery_Abort, rayQuery_CommitNonOpaqueTriangleHit, and rayQuery_StateScalar / rayQuery_StateVector (committed and candidate status, type, t, barycentrics, instance index / ID, geometry, primitive, front face). State queries carry ReadOnly so optimization/CSE never merges or hoists them across Proceed.
    • High-level helpers Shader::trace_any_hit (opaque first-hit shadow query with SKIP_PROCEDURAL_PRIMITIVES so procedural AABB candidates cannot stall the single-Proceed search; the only planned producer (the opt-in XCL_HW_RT shadow builder) builds triangle geometry only) and Shader::trace_translucent (FORCE_NON_OPAQUE Proceed loop that commits back faces and tracks the nearest front face).
    • DXIL 1.9 validator, SM 6.5/6.6 assertion tests, and WARP DXR 1.1 execution tests comparing closest hit (t0 and descriptor heap, using 48 single-triangle BLAS instances under one TLAS so the comparison tests DXIL emission without depending on WARP's multi-triangle BLAS builder, which dropped one triangle in one Windows CI run (not reproduced locally)), non-zero primitive index readout on a 2-triangle BLAS, first hit, procedural-AABB skip in trace_any_hit, translucent back-face commit, FRONT_COUNTERCLOCKWISE, negative-determinant mirrored instance transform (object-space winding per DXR spec), front1/back2, and fronts-only against a CPU walk and f64 Möller–Trumbore reference.
  • crates/xcl/src/gpu/dxil/shader.rs & crates/xcl/src/gpu/dxil/mod.rs:
    • Expose ray_query, add Feature::RaytracingTier1_1 (metadata bit 25, container bit 0x100000), add kind::RT_ACCELERATION_STRUCTURE (16), and register DXR 1.1 opcodes (178..=183 NoUnwind, 184..=212 | 214 | 215 ReadOnly) in dxc_fn_attrs.

Tested

  • Hardware & toolchain: NVIDIA GeForce RTX 5070 Ti (driver 610.74), AMD Ryzen 9 9950X, Windows 11 x64, rustc 1.99.0 (b940084d7 2026-09-28), DXC 1.9.2609.5 (01b62ad47).
  • cargo build --release -p xcl (commit 5bfb227466149a342e2b1a4e10cfdc4f8aef495a): succeeded, 39 warnings (0 new vs main).
  • cargo test -p xcl --lib -- gpu::dxil::ray_query --nocapture: 4 passed, 0 failed, 0 ignored (ray_query_kernels_validate, ray_query_rejects_sm_below_6_5, heap_accel_struct_rejects_sm_below_6_6, warp_ray_query_matches_console_bvh_walk), plus 100 pinned-affinity runs (50 at 0xF, 50 at 0x3, 0/100 failures).
  • .\scripts\test.ps1 (debug build + benches + workspace tests --test-threads=4, commit 5bfb227466149a342e2b1a4e10cfdc4f8aef495a): 2978 passed, 0 failed, 52 ignored across 43 test binaries.
  • SKIPPED GPU tests (24): 22 no wave64 (RTX 5070 Ti is wave32-only), 2 no heap windows (XCL_HEAP_WINDOWS opt-in off by default).

Regression run

xcl-smoke v1
commit: 5eaadb54c14e0fc29597b2a1689d7dbd83491303
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1658 (PresentX 1658)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 16763 MB
xcl-smoke v1
commit: 5bfb227466149a342e2b1a4e10cfdc4f8aef495a
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1671 (PresentX 1671)
presents per 2 s (last 3): 60 63 61
device removals: 0
crashes: 0
peak commit: 16063 MB

Not tested

  • The smoke title never reaches the new code (nothing calls it yet), so the regression run only confirms default runtime behavior is unaffected.
  • Live hardware GPU execution of translated game shaders emitting RayQuery (tested on WARP DXR 1.1 and validated with DXC 1.9 here; live shader traversal callers are in the stacked follow-up PRs).
  • AMD / Intel GPUs and wave64-only GPU tests.

AI use

  • Claude Code (Claude Opus 5.5): wrote the direct-DXIL RayQuery emitter and WARP reference tests, and audited the diff, optimizer safety (ReadOnly state queries across Proceed), and DXR object-space winding semantics.
  • Antigravity (Gemini 4 Neon): extracted the standalone PR on main, extended the WARP test suite for deterministic front/back-face, mirrored-transform, procedural-AABB, and single-triangle-instance BLAS semantics, applied review fixes, ran the full build/test/smoke suite, and drafted the PR description.
<!-- greyfinch-sync:ivall/xcl:issue:5599980660 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3659). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T04:41:58Z. --- Add direct-DXIL DXR 1.1 `RayQuery` emission and `RaytracingAccelerationStructure` SRV support to `gpu::dxil::Shader`. Nothing calls the new helpers yet, so default runtime behavior is unchanged; Live caller: #3705 (`XCL_HW_RT_TRAVERSE=1` swaps GPURT traversal loops for `heap_accel_struct` + `trace_any_hit` / `trace_translucent`). Part of #1751. Related: #2189 lowers `RayQuery` through the HLSL path (`gpu/recomp/rayquery.rs`); this PR is the direct-DXIL emitter (`gpu/dxil`), with no shared files. (Why this is 951 lines and not split further: ~205 lines are the direct-DXIL `RayQuery` emitter and `Shader` plumbing, and ~746 lines are the DXIL 1.9 validator, shader-model guard, and WARP execution tests for this same emitter, kept together because `CONTRIBUTING.md` requires new code to ship with its tests.) **What is in it** - `crates/xcl/src/gpu/dxil/ray_query.rs`: - `RaytracingAccelerationStructure` SRV bindings (static `t#` binding and `ResourceDescriptorHeap` indexing requiring SM 6.6+, resource kind 16, U32 element type, PSV0 `SrvRaw`). - Direct DXIL opcodes for `dx.op.allocateRayQuery` (requiring SM 6.5+), `rayQuery_TraceRayInline`, `rayQuery_Proceed`, `rayQuery_Abort`, `rayQuery_CommitNonOpaqueTriangleHit`, and `rayQuery_StateScalar` / `rayQuery_StateVector` (committed and candidate status, type, `t`, barycentrics, instance index / ID, geometry, primitive, front face). State queries carry `ReadOnly` so optimization/CSE never merges or hoists them across `Proceed`. - High-level helpers `Shader::trace_any_hit` (opaque first-hit shadow query with `SKIP_PROCEDURAL_PRIMITIVES` so procedural AABB candidates cannot stall the single-`Proceed` search; the only planned producer (the opt-in `XCL_HW_RT` shadow builder) builds triangle geometry only) and `Shader::trace_translucent` (`FORCE_NON_OPAQUE` `Proceed` loop that commits back faces and tracks the nearest front face). - DXIL 1.9 validator, SM 6.5/6.6 assertion tests, and WARP DXR 1.1 execution tests comparing closest hit (`t0` and descriptor heap, using 48 single-triangle BLAS instances under one TLAS so the comparison tests DXIL emission without depending on WARP's multi-triangle BLAS builder, which dropped one triangle in one Windows CI run (not reproduced locally)), non-zero primitive index readout on a 2-triangle BLAS, first hit, procedural-AABB skip in `trace_any_hit`, translucent back-face commit, `FRONT_COUNTERCLOCKWISE`, negative-determinant mirrored instance transform (object-space winding per DXR spec), `front1/back2`, and fronts-only against a CPU walk and `f64` Möller–Trumbore reference. - `crates/xcl/src/gpu/dxil/shader.rs` & `crates/xcl/src/gpu/dxil/mod.rs`: - Expose `ray_query`, add `Feature::RaytracingTier1_1` (metadata bit 25, container bit `0x100000`), add `kind::RT_ACCELERATION_STRUCTURE` (16), and register DXR 1.1 opcodes (`178..=183` `NoUnwind`, `184..=212 | 214 | 215` `ReadOnly`) in `dxc_fn_attrs`. **Tested** - Hardware & toolchain: NVIDIA GeForce RTX 5070 Ti (driver 610.74), AMD Ryzen 9 9950X, Windows 11 x64, `rustc 1.99.0 (b940084d7 2026-09-28)`, DXC `1.9.2609.5 (01b62ad47)`. - `cargo build --release -p xcl` (commit `5bfb227466149a342e2b1a4e10cfdc4f8aef495a`): succeeded, 39 warnings (0 new vs `main`). - `cargo test -p xcl --lib -- gpu::dxil::ray_query --nocapture`: 4 passed, 0 failed, 0 ignored (`ray_query_kernels_validate`, `ray_query_rejects_sm_below_6_5`, `heap_accel_struct_rejects_sm_below_6_6`, `warp_ray_query_matches_console_bvh_walk`), plus 100 pinned-affinity runs (50 at `0xF`, 50 at `0x3`, `0/100` failures). - `.\scripts\test.ps1` (debug build + benches + workspace tests `--test-threads=4`, commit `5bfb227466149a342e2b1a4e10cfdc4f8aef495a`): **2978 passed, 0 failed, 52 ignored** across 43 test binaries. - SKIPPED GPU tests (24): 22 `no wave64` (RTX 5070 Ti is wave32-only), 2 `no heap windows` (`XCL_HEAP_WINDOWS` opt-in off by default). **Regression run** ``` xcl-smoke v1 commit: 5eaadb54c14e0fc29597b2a1689d7dbd83491303 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1658 (PresentX 1658) presents per 2 s (last 3): 60 61 60 device removals: 0 crashes: 0 peak commit: 16763 MB ``` ``` xcl-smoke v1 commit: 5bfb227466149a342e2b1a4e10cfdc4f8aef495a gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1671 (PresentX 1671) presents per 2 s (last 3): 60 63 61 device removals: 0 crashes: 0 peak commit: 16063 MB ``` **Not tested** - The smoke title never reaches the new code (nothing calls it yet), so the regression run only confirms default runtime behavior is unaffected. - Live hardware GPU execution of translated game shaders emitting `RayQuery` (tested on WARP DXR 1.1 and validated with DXC 1.9 here; live shader traversal callers are in the stacked follow-up PRs). - AMD / Intel GPUs and wave64-only GPU tests. **AI use** - Claude Code (`Claude Opus 5.5`): wrote the direct-DXIL `RayQuery` emitter and WARP reference tests, and audited the diff, optimizer safety (`ReadOnly` state queries across `Proceed`), and DXR object-space winding semantics. - Antigravity (`Gemini 4 Neon`): extracted the standalone PR on `main`, extended the WARP test suite for deterministic front/back-face, mirrored-transform, procedural-AABB, and single-triangle-instance BLAS semantics, applied review fixes, ran the full build/test/smoke suite, and drafted the PR description.
Foniass commented 2026-12-02 09:08:06 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T09:08:06Z.


Review (head 9c33b8cc, diff read, not a merge-check):

  • No caller, and none is in sight. Nothing in the tree calls accel_struct, ray_query*, trace_any_hit or trace_translucent, and no open PR does. #2189, the PR that does consume RayQuery, goes through the HLSL path. The direct-DXIL path lowers image_bvh_intersect_ray one node at a time (gpu/dxil/lower_image.rs ~979). Swapping that for a whole-traversal query needs a traversal-region matcher, and only the HLSL stack has one (#2188). So 1021 lines would land for a consumer whose shape is unknown, and nobody can check whether the two high-level helpers fit it. The size reason in the description (tests have to ship with the code) is fine. The missing consumer is the problem: hold this until the caller exists, or ship it stacked under the caller.
  • trace_any_hit can report a miss on a hit. gpu/dxil/ray_query.rs ~135 calls Proceed once and assumes "all candidates are opaque". Per the DXR spec, FORCE_OPAQUE does not stop procedural (AABB) candidates being handed to the shader. If the structure holds AABB geometry, the first Proceed stops on that candidate and COMMITTED_STATUS is still COMMITTED_NOTHING, so a shadow ray that would have hit a triangle further on comes back as a miss. Fix: add RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES (0x200) to the constant flags, or loop the way trace_translucent does.
  • The test carries ~150 lines of WARP workaround. ray_query.rs ~728-822 rebuilds the scene up to twice when it sees a "dropped triangle" pattern, and ~381 scans d3d10warp.dll for its file version. The description says the retry never ran in 940/940 runs once the scene got its own submit. As written, though, a real regression that loses hits on one triangle in a fresh build passes on a retry. The cause was never found. Dropping the retry and failing hard would keep the test strict and make it much shorter.
  • The finish() feature drop is untested and probably never fires. shader.rs ~550 removes RaytracingTier1_1 when no allocateRayQuery survives. But allocateRayQuery is NoUnwind and not in removable's prefix list (module/opt.rs ~523-531), and its result feeds a void TraceRayInline, so DCE never removes it. No test builds a shader where the drop happens. Also, ray_query (~75) and heap_accel_struct (~69) do not check self.sm. A caller that builds a shader below SM 6.5 (6.6 for the heap path) only finds out if validation runs.

Fine: by reading, the dx.op opcodes 178-182 and 184-215, the overload suffixes (Proceed.i1, StateScalar.i32/f32/i1, StateVector.f32 with an i8 component) and the function attributes (NoUnwind for allocate/trace/proceed/abort/commit, ReadOnly for state reads, 213 left out) all match DXC. Shader flag bit 25 and container bit 0x100000 are right, and so are resource kind 16 with struct.RaytracingAccelerationStructure, U32 element type and PSV SrvRaw. The optimizer only CSEs ReadNone calls, so state reads are not merged across Proceed. No file overlap with #3662, which only hooks the builder DLL.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7340427796 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3659#issuecomment-7340427796). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T09:08:06Z. --- Review (head 9c33b8cc, diff read, not a merge-check): - **No caller, and none is in sight.** Nothing in the tree calls `accel_struct`, `ray_query*`, `trace_any_hit` or `trace_translucent`, and no open PR does. #2189, the PR that does consume RayQuery, goes through the HLSL path. The direct-DXIL path lowers `image_bvh_intersect_ray` one node at a time (`gpu/dxil/lower_image.rs` ~979). Swapping that for a whole-traversal query needs a traversal-region matcher, and only the HLSL stack has one (#2188). So 1021 lines would land for a consumer whose shape is unknown, and nobody can check whether the two high-level helpers fit it. The size reason in the description (tests have to ship with the code) is fine. The missing consumer is the problem: hold this until the caller exists, or ship it stacked under the caller. - **`trace_any_hit` can report a miss on a hit.** `gpu/dxil/ray_query.rs` ~135 calls `Proceed` once and assumes "all candidates are opaque". Per the DXR spec, `FORCE_OPAQUE` does not stop procedural (AABB) candidates being handed to the shader. If the structure holds AABB geometry, the first `Proceed` stops on that candidate and `COMMITTED_STATUS` is still `COMMITTED_NOTHING`, so a shadow ray that would have hit a triangle further on comes back as a miss. Fix: add `RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES` (0x200) to the constant flags, or loop the way `trace_translucent` does. - **The test carries ~150 lines of WARP workaround.** `ray_query.rs` ~728-822 rebuilds the scene up to twice when it sees a "dropped triangle" pattern, and ~381 scans `d3d10warp.dll` for its file version. The description says the retry never ran in 940/940 runs once the scene got its own submit. As written, though, a real regression that loses hits on one triangle in a fresh build passes on a retry. The cause was never found. Dropping the retry and failing hard would keep the test strict and make it much shorter. - **The `finish()` feature drop is untested and probably never fires.** `shader.rs` ~550 removes `RaytracingTier1_1` when no `allocateRayQuery` survives. But `allocateRayQuery` is `NoUnwind` and not in `removable`'s prefix list (`module/opt.rs` ~523-531), and its result feeds a void `TraceRayInline`, so DCE never removes it. No test builds a shader where the drop happens. Also, `ray_query` (~75) and `heap_accel_struct` (~69) do not check `self.sm`. A caller that builds a shader below SM 6.5 (6.6 for the heap path) only finds out if validation runs. Fine: by reading, the `dx.op` opcodes 178-182 and 184-215, the overload suffixes (`Proceed.i1`, `StateScalar.i32/f32/i1`, `StateVector.f32` with an `i8` component) and the function attributes (`NoUnwind` for allocate/trace/proceed/abort/commit, `ReadOnly` for state reads, 213 left out) all match DXC. Shader flag bit 25 and container bit 0x100000 are right, and so are resource kind 16 with `struct.RaytracingAccelerationStructure`, U32 element type and PSV `SrvRaw`. The optimizer only CSEs `ReadNone` calls, so state reads are not merged across `Proceed`. No file overlap with #3662, which only hooks the builder DLL. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Foniass commented 2026-12-02 10:35:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T10:35:45Z.


merge-check
base: 1c8b551475
head: 9c33b8cc57
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2909 passed, 2 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: hle::d3d12x::uma_driver::tests::a_refused_gpu_upload_segment_becomes_custom, hle::d3d12x::uma_driver::tests::mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment
review: read by one reviewer at this same head; the review is at https://github.com/xcl-dev/xcl/pull/3659#issuecomment-7340427796 and its findings stand. Most serious: 1021 lines with no caller, and trace_any_hit can report a miss when the ray meets AABB geometry. The 2 failing tests are this machine's intermittent uma_driver "Map gave X, wanted Y" failures, seen on other PRs and not in code this PR touches.
performance: 60 s smoke of a retail title, main 1c8b5514 vs this merge (9c33b8cc): 1652 -> 1688 frames shown (102 %; last presents per 2 s: 60 60 60), peak commit 18228 -> 17001 MB, 0 device removals, 0 crashes.
verdict: not yet: 1021 lines with no caller, and trace_any_hit can report a miss when the ray meets AABB geometry (see the review); the build, the rest of the suite and the smoke run are fine
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7342700925 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3659#issuecomment-7342700925). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T10:35:45Z. --- merge-check base: 1c8b551475e1e7bfe48f94448492a4c3544a2e0f head: 9c33b8cc57491183f5cec44ac34e0e9359caf45f merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2909 passed, 2 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: hle::d3d12x::uma_driver::tests::a_refused_gpu_upload_segment_becomes_custom, hle::d3d12x::uma_driver::tests::mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment review: read by one reviewer at this same head; the review is at https://github.com/xcl-dev/xcl/pull/3659#issuecomment-7340427796 and its findings stand. Most serious: 1021 lines with no caller, and `trace_any_hit` can report a miss when the ray meets AABB geometry. The 2 failing tests are this machine's intermittent `uma_driver` "Map gave X, wanted Y" failures, seen on other PRs and not in code this PR touches. performance: 60 s smoke of a retail title, main 1c8b5514 vs this merge (9c33b8cc): 1652 -> 1688 frames shown (102 %; last presents per 2 s: 60 60 60), peak commit 18228 -> 17001 MB, 0 device removals, 0 crashes. verdict: not yet: 1021 lines with no caller, and `trace_any_hit` can report a miss when the ray meets AABB geometry (see the review); the build, the rest of the suite and the smoke run are fine hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 AI-written and posted by Foniass without a human check of each point.
Kalmarv commented 2026-12-02 14:17:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T14:17:43Z.


@Foniass Thanks for the review! Rebased onto main (5eaadb54c) and updated to bd104a36b:

  • trace_any_hit procedural AABB handling: added RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES (0x200) to trace_any_hit so procedural AABB candidates cannot stop the single-Proceed search before a triangle behind them. ray_query_kernels_validate now asserts the emitted allocateRayQuery flags (i32 525) and fails without the flag; we also added a WARP procedural-AABB + triangle case (though on WARP 10.0.26100 that WARP check still passes without the flag, likely due to TLAS instance visit order, so the disassembly check is what pins the flag). Note also that the only planned producer (the opt-in XCL_HW_RT shadow builder) builds triangle geometry only.
  • Shader-model guards & dead finish() feature drop: removed the untested infer_type_features() RaytracingTier1_1 removal and Shader::calls(), and added assert!(self.sm >= (6, 5)) in ray_query() and assert!(self.sm >= (6, 6)) in heap_accel_struct() with #[should_panic] unit tests.
  • WARP retry & d3d10warp.dll scanner: removed the ~150-line retry loop and version scanner; kept the own-submit build_scene and fail hard immediately on any mismatch.
  • Live caller: the stacked hardware ray-tracing PRs (registry, shadow builder, GPU top-level table, and direct-DXIL GPURT traversal swap calling heap_accel_struct, trace_any_hit, and trace_translucent) are opening right behind this PR; I will link the live caller PR here as soon as it is open.

Verified bd104a36b with cargo build --release -p xcl (39 warnings, 0 new), scripts/test.ps1 (2978 passed, 0 failed, 52 ignored, 24 SKIPPED GPU on RTX 5070 Ti), and a fresh 60 s smoke pair against 5eaadb54c.

AI use: Antigravity (Gemini 4 Neon) applied the fixes and ran the build/test/smoke verification; Claude Code (Claude Opus 5.5) reviewed the diff and drafted the verification checks.

<!-- greyfinch-sync:ivall/xcl:comment:7348306436 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3659#issuecomment-7348306436). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T14:17:43Z. --- @Foniass Thanks for the review! Rebased onto `main` (`5eaadb54c`) and updated to `bd104a36b`: - **`trace_any_hit` procedural AABB handling:** added `RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES` (`0x200`) to `trace_any_hit` so procedural AABB candidates cannot stop the single-`Proceed` search before a triangle behind them. `ray_query_kernels_validate` now asserts the emitted `allocateRayQuery` flags (`i32 525`) and fails without the flag; we also added a WARP procedural-AABB + triangle case (though on WARP 10.0.26100 that WARP check still passes without the flag, likely due to TLAS instance visit order, so the disassembly check is what pins the flag). Note also that the only planned producer (the opt-in `XCL_HW_RT` shadow builder) builds triangle geometry only. - **Shader-model guards & dead `finish()` feature drop:** removed the untested `infer_type_features()` `RaytracingTier1_1` removal and `Shader::calls()`, and added `assert!(self.sm >= (6, 5))` in `ray_query()` and `assert!(self.sm >= (6, 6))` in `heap_accel_struct()` with `#[should_panic]` unit tests. - **WARP retry & `d3d10warp.dll` scanner:** removed the ~150-line retry loop and version scanner; kept the own-submit `build_scene` and fail hard immediately on any mismatch. - **Live caller:** the stacked hardware ray-tracing PRs (registry, shadow builder, GPU top-level table, and direct-DXIL GPURT traversal swap calling `heap_accel_struct`, `trace_any_hit`, and `trace_translucent`) are opening right behind this PR; I will link the live caller PR here as soon as it is open. Verified `bd104a36b` with `cargo build --release -p xcl` (39 warnings, 0 new), `scripts/test.ps1` (2978 passed, 0 failed, 52 ignored, 24 SKIPPED GPU on RTX 5070 Ti), and a fresh 60 s smoke pair against `5eaadb54c`. AI use: Antigravity (Gemini 4 Neon) applied the fixes and ran the build/test/smoke verification; Claude Code (Claude Opus 5.5) reviewed the diff and drafted the verification checks.
Kalmarv commented 2026-12-02 14:32:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T14:32:58Z.


Note on the Build and test (Windows, no GPU) failure on bd104a36b (warp_ray_query_matches_console_bvh_walk missed a closer triangle on ray 41 and hit the triangle behind it): investigating by pinning the test to 2–4 cores to reproduce and test build flags (or split the 48-triangle BLAS into 1-triangle BLASes under one TLAS if WARP's multi-triangle builder is nondeterministic) rather than rerunning or re-adding a retry.

<!-- greyfinch-sync:ivall/xcl:comment:7348735434 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3659#issuecomment-7348735434). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T14:32:58Z. --- Note on the `Build and test (Windows, no GPU)` failure on `bd104a36b` (`warp_ray_query_matches_console_bvh_walk` missed a closer triangle on ray 41 and hit the triangle behind it): investigating by pinning the test to 2–4 cores to reproduce and test build flags (or split the 48-triangle BLAS into 1-triangle BLASes under one TLAS if WARP's multi-triangle builder is nondeterministic) rather than rerunning or re-adding a retry.
Kalmarv commented 2026-12-02 15:06:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T15:06:52Z.


Updated in 5bfb22746 to fix the Windows CI failure on warp_ray_query_matches_console_bvh_walk without adding a retry:

  • Investigation: Pinned bd104a36b on local d3d10warp.dll 10.0.26100.9711 at reduced core counts: 0/100 failures at affinity 0xF (4 cores), 0/100 at 0x3 (2 cores), and 0/100 across 4-way concurrent runs on 0xF (0/300 total; did not reproduce locally).
  • Fix (crates/xcl/src/gpu/dxil/ray_query.rs): Restructured build_scene to build 48 separate 1-triangle BLASes under one TLAS of 48 identity instances ([instance_index, instance_id, geometry, primitive] == [prim, 7, 0, 0]) so the strict console-walk comparison tests our DXIL emission without depending on WARP's multi-triangle BLAS builder (which dropped one triangle in one Windows CI run). Added an explicit non-zero COMMITTED_PRIMITIVE_INDEX ([0, 1, 0, 1]) check on the 2-triangle blas_fb in sem_tlas so multi-primitive index readout stays covered.
  • Verified gpu::dxil::ray_query (4/4), 100 pinned affinity runs (50 at 0xF + 50 at 0x3, 0/100 failures), full scripts/test.ps1, and fresh back-to-back default smoke; PR body updated.
<!-- greyfinch-sync:ivall/xcl:comment:7349744165 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3659#issuecomment-7349744165). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T15:06:52Z. --- Updated in `5bfb22746` to fix the Windows CI failure on `warp_ray_query_matches_console_bvh_walk` without adding a retry: - **Investigation:** Pinned `bd104a36b` on local `d3d10warp.dll` `10.0.26100.9711` at reduced core counts: `0/100` failures at affinity `0xF` (4 cores), `0/100` at `0x3` (2 cores), and `0/100` across 4-way concurrent runs on `0xF` (`0/300` total; did not reproduce locally). - **Fix (`crates/xcl/src/gpu/dxil/ray_query.rs`):** Restructured `build_scene` to build 48 separate 1-triangle BLASes under one TLAS of 48 identity instances (`[instance_index, instance_id, geometry, primitive] == [prim, 7, 0, 0]`) so the strict console-walk comparison tests our DXIL emission without depending on WARP's multi-triangle BLAS builder (which dropped one triangle in one Windows CI run). Added an explicit non-zero `COMMITTED_PRIMITIVE_INDEX` (`[0, 1, 0, 1]`) check on the 2-triangle `blas_fb` in `sem_tlas` so multi-primitive index readout stays covered. - Verified `gpu::dxil::ray_query` (4/4), 100 pinned affinity runs (`50` at `0xF` + `50` at `0x3`, `0/100` failures), full `scripts/test.ps1`, and fresh back-to-back default smoke; PR body updated.
Kalmarv commented 2026-12-02 16:00:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T16:00:54Z.


Live caller is now open: #3705 (XCL_HW_RT_TRAVERSE=1 swaps GPURT traversal loops for heap_accel_struct + trace_any_hit / trace_translucent, stacked on #3704, #3700, #3697, and #3662). Added the link to the PR body as well.

<!-- greyfinch-sync:ivall/xcl:comment:7351307143 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3659#issuecomment-7351307143). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T16:00:54Z. --- Live caller is now open: #3705 (`XCL_HW_RT_TRAVERSE=1` swaps GPURT traversal loops for `heap_accel_struct` + `trace_any_hit` / `trace_translucent`, stacked on #3704, #3700, #3697, and #3662). Added the link to the PR body as well.
Foniass commented 2026-12-02 18:02:59 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T18:02:59Z.


merge-check
base: 5eaadb54c1
head: 5bfb227466
merge: clean
build: ok
tests: 2978 passed, 0 failed, 52 ignored; 28 skipped, the same as on main
review: 2 medium, 2 nits (below)
performance: 60 s smoke run: 1422 → 1659 frames (116 % of main), peak commit 17184 → 16435 MB, no device removal, no crash
title run: not run
verdict: safe to merge: no blocking finding (the points below are medium or nits), the suite passes and the smoke run is clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5


In short: Follow-up on 5bfb2274; my last review was on 9c33b8cc. The PR adds DXIL emitters for inline ray queries (gpu/dxil/ray_query.rs) with GPU tests against WARP. Three of the four earlier findings are fixed. The one left (nothing calls the new helpers yet) is allowed by CONTRIBUTING and is the maintainer's call. Nothing blocks: the suite passes and the smoke run is clean.

Medium

  1. Nothing calls the new helpers yet. Nothing outside gpu/dxil/ray_query.rs calls accel_struct, ray_query*, trace_any_hit or trace_translucent, so their shape isn't checked against a real consumer. The hw_rt PRs opened since (#3697 / #3700 / #3704 / #3705) may be those consumers; this review didn't check them. CONTRIBUTING allows new code that isn't called yet.
  2. The WARP dropped-triangle flake is avoided, not explained. The amendment builds the 256-ray comparison scene as 48 one-triangle BLAS instances under one TLAS, so the earlier flake with multi-triangle BLAS no longer shows, but its cause is still unknown.

Nit

  1. Commit area. The commit subject uses DXIL:, which isn't in the AGENTS.md list; the PR title uses Recompiler:.
  2. Size. 951 lines, over the ~800 mark; the description gives the reason (the tests ship with the emitter).
Checked and fine
  • Earlier finding fixed: trace_any_hit no longer misses a hit behind AABBs (flags 0x20D, ray_query.rs ~139, with a disassembly assert at ~343-347).
  • Earlier finding fixed: the WARP rebuild / retry loop and the d3d10warp.dll version scan are gone; a mismatch now fails hard.
  • Earlier finding fixed: the finish() feature drop is removed, with SM 6.5 / 6.6 guards (~71, ~78) and should_panic tests.
  • No default-path change: the new dxc_fn_attrs arms and the PSV SrvRaw / kind 16 arm apply only when RayQuery ops or acceleration-structure bindings are emitted, and nothing emits them yet.
  • By reading, opcodes, overloads, attributes and feature bits match DXC.
How this was tested
  • Merged onto main 5eaadb54, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main 5eaadb54 and on this merge; presents per 2 s at the end: 60 60 60.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7353893484 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3659#issuecomment-7353893484). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T18:02:59Z. --- merge-check base: 5eaadb54c14e0fc29597b2a1689d7dbd83491303 head: 5bfb227466149a342e2b1a4e10cfdc4f8aef495a merge: clean build: ok tests: 2978 passed, 0 failed, 52 ignored; 28 skipped, the same as on main review: 2 medium, 2 nits (below) performance: 60 s smoke run: 1422 → 1659 frames (116 % of main), peak commit 17184 → 16435 MB, no device removal, no crash title run: not run verdict: safe to merge: no blocking finding (the points below are medium or nits), the suite passes and the smoke run is clean hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 --- **In short:** Follow-up on 5bfb2274; my last review was on 9c33b8cc. The PR adds DXIL emitters for inline ray queries (`gpu/dxil/ray_query.rs`) with GPU tests against WARP. Three of the four earlier findings are fixed. The one left (nothing calls the new helpers yet) is allowed by CONTRIBUTING and is the maintainer's call. Nothing blocks: the suite passes and the smoke run is clean. #### Medium 1. **Nothing calls the new helpers yet.** Nothing outside `gpu/dxil/ray_query.rs` calls `accel_struct`, `ray_query*`, `trace_any_hit` or `trace_translucent`, so their shape isn't checked against a real consumer. The hw_rt PRs opened since (#3697 / #3700 / #3704 / #3705) may be those consumers; this review didn't check them. CONTRIBUTING allows new code that isn't called yet. 2. **The WARP dropped-triangle flake is avoided, not explained.** The amendment builds the 256-ray comparison scene as 48 one-triangle BLAS instances under one TLAS, so the earlier flake with multi-triangle BLAS no longer shows, but its cause is still unknown. #### Nit 3. **Commit area.** The commit subject uses `DXIL:`, which isn't in the AGENTS.md list; the PR title uses `Recompiler:`. 4. **Size.** 951 lines, over the ~800 mark; the description gives the reason (the tests ship with the emitter). <details><summary>Checked and fine</summary> - Earlier finding fixed: `trace_any_hit` no longer misses a hit behind AABBs (flags 0x20D, `ray_query.rs` ~139, with a disassembly assert at ~343-347). - Earlier finding fixed: the WARP rebuild / retry loop and the d3d10warp.dll version scan are gone; a mismatch now fails hard. - Earlier finding fixed: the `finish()` feature drop is removed, with SM 6.5 / 6.6 guards (~71, ~78) and `should_panic` tests. - No default-path change: the new `dxc_fn_attrs` arms and the PSV `SrvRaw` / kind 16 arm apply only when RayQuery ops or acceleration-structure bindings are emitted, and nothing emits them yet. - By reading, opcodes, overloads, attributes and feature bits match DXC. </details> <details><summary>How this was tested</summary> - Merged onto main `5eaadb54`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `5eaadb54` and on this merge; presents per 2 s at the end: 60 60 60. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
stijn-boer commented 2026-12-02 19:12:16 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by stijn-boer on 2026-12-02T19:12:16Z.


merge-check
base: c53e969602
head: 5bfb227466
verdict: not yet: the emitted DXIL and shader-model guards passed, and the workspace abort was shared with main. The WARP runner lacked DXR 1.1 on this host, so this report did not verify ray-query results against the BVH reference.

Windows / AMD RDNA4 (native D3D12) — DXIL inline ray-query validation on 5bfb227

Clean merge onto main at c53e969 (merge commit f6e66b56178ccd8bd3acbea4aaa01cd16693cfea). git diff --check was clean.

Setup

  • AMD Radeon RX 9060 XT (driver 32.0.32029.2010), Ryzen 7 5700X, Windows 10 21H2 build 19044.6332
  • Rust 1.100.0, debug builds, Agility SDK 1.620.2 with matching d3d12SDKLayers.dll, DXC 1.9.2609.5

Tested

cargo build --workspace passed. cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output exited 101 on both builds. The baseline table row is from a prior run of the same commit, machine, SDK, and command.

Build Passed Failed Ignored SKIPPED notices
main 338 3 23 0
Merged PR 339 3 23 0

Counts are partial because two test processes aborted on each build.

  • Tests that failed on the PR and passed on main — none observed in comparable results.
  • New focused tests — libtest reported 4 passed, 0 failed, 0 ignored with --test-threads=1 --show-output --nocapture. One of those returned with SKIPPED no DXR 1.1 on WARP, so 3 checks exercised their assertions. The validator test passed, and both lower shader-model guards panicked as expected (RayQuery below 6.5, heap acceleration-structure SRV below 6.6).
  • Debug-layer coverage — both debug-layer E2E tests, including DRED, and uploads_start_from_each_subresources_state passed.
Shared failures and process aborts
  • fuzz_validate_and_gpu_1, fuzz_validate_and_gpu_3, and two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs reported failures on both builds.
  • The library and gpu_compute_e2e test processes exited with 0xc0000409 on both builds.

Diff review

The selected checks covered emitted ray-query kernels and the shader-model gates. The execution fixture explicitly selects WARP, which lacked DXR 1.1 on this host.

Not tested

Remaining workspace tests after the aborts, ray-query execution against the BVH reference on WARP or the AMD hardware, and retail smoke (tier 1).

AI use

Codex (GPT-6) merged and built the PR, ran the tests, compared the results with main, reviewed the diff, and drafted this report.

<!-- greyfinch-sync:ivall/xcl:comment:7355781428 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3659#issuecomment-7355781428). Originally posted by [stijn-boer](https://github.com/stijn-boer) on 2026-12-02T19:12:16Z. --- merge-check base: c53e96960265a82477a9c98677afb0402e98d486 head: 5bfb227466149a342e2b1a4e10cfdc4f8aef495a verdict: not yet: the emitted DXIL and shader-model guards passed, and the workspace abort was shared with main. The WARP runner lacked DXR 1.1 on this host, so this report did not verify ray-query results against the BVH reference. **Windows / AMD RDNA4 (native D3D12) — DXIL inline ray-query validation on `5bfb227`** Clean merge onto `main` at `c53e969` (merge commit `f6e66b56178ccd8bd3acbea4aaa01cd16693cfea`). `git diff --check` was clean. **Setup** - AMD Radeon RX 9060 XT (driver 32.0.32029.2010), Ryzen 7 5700X, Windows 10 21H2 build 19044.6332 - Rust 1.100.0, debug builds, Agility SDK 1.620.2 with matching `d3d12SDKLayers.dll`, DXC 1.9.2609.5 **Tested** `cargo build --workspace` passed. `cargo test --workspace --no-fail-fast -- --test-threads=4 --show-output` exited 101 on both builds. The baseline table row is from a prior run of the same commit, machine, SDK, and command. | Build | Passed | Failed | Ignored | `SKIPPED` notices | |---|---:|---:|---:|---:| | `main` | 338 | 3 | 23 | 0 | | Merged PR | 339 | 3 | 23 | 0 | Counts are partial because two test processes aborted on each build. - **Tests that failed on the PR and passed on `main`** — none observed in comparable results. - **New focused tests** — libtest reported 4 passed, 0 failed, 0 ignored with `--test-threads=1 --show-output --nocapture`. One of those returned with `SKIPPED no DXR 1.1 on WARP`, so 3 checks exercised their assertions. The validator test passed, and both lower shader-model guards panicked as expected (RayQuery below 6.5, heap acceleration-structure SRV below 6.6). - **Debug-layer coverage** — both debug-layer E2E tests, including DRED, and `uploads_start_from_each_subresources_state` passed. <details><summary>Shared failures and process aborts</summary> - `fuzz_validate_and_gpu_1`, `fuzz_validate_and_gpu_3`, and `two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs` reported failures on both builds. - The library and `gpu_compute_e2e` test processes exited with `0xc0000409` on both builds. </details> **Diff review** The selected checks covered emitted ray-query kernels and the shader-model gates. The execution fixture explicitly selects WARP, which lacked DXR 1.1 on this host. **Not tested** Remaining workspace tests after the aborts, ray-query execution against the BVH reference on WARP or the AMD hardware, and retail smoke (tier 1). **AI use** Codex (GPT-6) merged and built the PR, ran the tests, compared the results with `main`, reviewed the diff, and drafted this report.
bmjask commented 2026-12-02 19:55:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T19:55:54Z.

Code review location: crates/xcl/src/gpu/dxil/ray_query.rs; line 62

@@ -0,0 +1,941 @@
+//! DXR 1.1 inline ray tracing on a [`Shader`]: the `RaytracingAccelerationStructure` SRV and
+//! the `dx.op.allocateRayQuery` / `dx.op.rayQuery_*` operations. Opcodes, signatures and
+//! attributes follow DXC 1.9's `DxilOperations` (checked against `dxc -T cs_6_6 -Fc` listings
+//! and the validator in the tests). RayQuery needs shader model 6.5+.
+
+use super::module::{FnAttrs, Pred, Value};
+use super::ops::Binary;
+use super::shader::{kind, Binding, Feature, ResClass, Shader};
+
+/// `dx.op` opcodes of the RayQuery operations.
+pub mod op {
+    pub const ALLOCATE: u32 = 178;
+    pub const TRACE_RAY_INLINE: u32 = 179;
+    pub const PROCEED: u32 = 180;
+    pub const ABORT: u32 = 181;
+    pub const COMMIT_NON_OPAQUE_TRIANGLE_HIT: u32 = 182;
+    pub const COMMITTED_STATUS: u32 = 184;
+    pub const CANDIDATE_TYPE: u32 = 185;
+    pub const CANDIDATE_TRIANGLE_FRONT_FACE: u32 = 191;
+    pub const COMMITTED_TRIANGLE_FRONT_FACE: u32 = 192;
+    pub const CANDIDATE_TRIANGLE_BARYCENTRICS: u32 = 193;
+    pub const COMMITTED_TRIANGLE_BARYCENTRICS: u32 = 194;
+    pub const CANDIDATE_TRIANGLE_RAY_T: u32 = 199;
+    pub const COMMITTED_RAY_T: u32 = 200;
+    pub const CANDIDATE_INSTANCE_INDEX: u32 = 201;
+    pub const CANDIDATE_INSTANCE_ID: u32 = 202;
+    pub const CANDIDATE_GEOMETRY_INDEX: u32 = 203;
+    pub const CANDIDATE_PRIMITIVE_INDEX: u32 = 204;
+    pub const COMMITTED_INSTANCE_INDEX: u32 = 207;
+    pub const COMMITTED_INSTANCE_ID: u32 = 208;
+    pub const COMMITTED_GEOMETRY_INDEX: u32 = 209;
+    pub const COMMITTED_PRIMITIVE_INDEX: u32 = 210;
+}
+
+/// `COMMITTED_STATUS` values.
+pub const COMMITTED_NOTHING: u32 = 0;
+pub const COMMITTED_TRIANGLE_HIT: u32 = 1;
+/// `CANDIDATE_TYPE` of a non-opaque triangle.
+pub const CANDIDATE_NON_OPAQUE_TRIANGLE: u32 = 0;
+
+/// `RAY_FLAG_*` bits.
+pub mod ray_flag {
+    pub const FORCE_OPAQUE: u32 = 0x1;
+    pub const FORCE_NON_OPAQUE: u32 = 0x2;
+    pub const ACCEPT_FIRST_HIT_AND_END_SEARCH: u32 = 0x4;
+    pub const SKIP_CLOSEST_HIT_SHADER: u32 = 0x8;
+    pub const SKIP_PROCEDURAL_PRIMITIVES: u32 = 0x200;
+}
+
+/// A ray: origin, `t` interval and direction (`RayDesc`).
+#[derive(Clone, Copy)]
+pub struct Ray {
+    pub origin: [Value; 3],
+    pub tmin: Value,
+    pub dir: [Value; 3],
+    pub tmax: Value,
+}
+
+impl Shader {
+    /// `RaytracingAccelerationStructure` at `t<lower>, space<space>`: its handle, created in the
+    /// current block (call before emitting other code in the entry block).
+    pub fn accel_struct(&mut self, lower: u32, space: u32) -> Value {

Medium: ray_query only requires SM 6.5, but both ways to get an acceleration structure need SM 6.6: accel_struct (no guard) and heap_accel_struct (guarded at 6.6). Shader::new(_, (6, 5)) plus accel_struct(0, 0) and trace_any_hit passes every assertion but emits createHandleFromBinding/annotateHandle (ops 217/216), which only exist in SM 6.6, so the output is invalid DXIL. The 6.5 guard and ray_query_rejects_sm_below_6_5 claim support the builder can't produce. Adding the 6.6 assert to accel_struct (or raising ray_query's guard) would make it consistent.

<!-- greyfinch-sync:ivall/xcl:review-comment:4775155082 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3659#discussion_r4775155082). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T19:55:54Z. **Code review location:** `crates/xcl/src/gpu/dxil/ray_query.rs`; line 62 ~~~~diff @@ -0,0 +1,941 @@ +//! DXR 1.1 inline ray tracing on a [`Shader`]: the `RaytracingAccelerationStructure` SRV and +//! the `dx.op.allocateRayQuery` / `dx.op.rayQuery_*` operations. Opcodes, signatures and +//! attributes follow DXC 1.9's `DxilOperations` (checked against `dxc -T cs_6_6 -Fc` listings +//! and the validator in the tests). RayQuery needs shader model 6.5+. + +use super::module::{FnAttrs, Pred, Value}; +use super::ops::Binary; +use super::shader::{kind, Binding, Feature, ResClass, Shader}; + +/// `dx.op` opcodes of the RayQuery operations. +pub mod op { + pub const ALLOCATE: u32 = 178; + pub const TRACE_RAY_INLINE: u32 = 179; + pub const PROCEED: u32 = 180; + pub const ABORT: u32 = 181; + pub const COMMIT_NON_OPAQUE_TRIANGLE_HIT: u32 = 182; + pub const COMMITTED_STATUS: u32 = 184; + pub const CANDIDATE_TYPE: u32 = 185; + pub const CANDIDATE_TRIANGLE_FRONT_FACE: u32 = 191; + pub const COMMITTED_TRIANGLE_FRONT_FACE: u32 = 192; + pub const CANDIDATE_TRIANGLE_BARYCENTRICS: u32 = 193; + pub const COMMITTED_TRIANGLE_BARYCENTRICS: u32 = 194; + pub const CANDIDATE_TRIANGLE_RAY_T: u32 = 199; + pub const COMMITTED_RAY_T: u32 = 200; + pub const CANDIDATE_INSTANCE_INDEX: u32 = 201; + pub const CANDIDATE_INSTANCE_ID: u32 = 202; + pub const CANDIDATE_GEOMETRY_INDEX: u32 = 203; + pub const CANDIDATE_PRIMITIVE_INDEX: u32 = 204; + pub const COMMITTED_INSTANCE_INDEX: u32 = 207; + pub const COMMITTED_INSTANCE_ID: u32 = 208; + pub const COMMITTED_GEOMETRY_INDEX: u32 = 209; + pub const COMMITTED_PRIMITIVE_INDEX: u32 = 210; +} + +/// `COMMITTED_STATUS` values. +pub const COMMITTED_NOTHING: u32 = 0; +pub const COMMITTED_TRIANGLE_HIT: u32 = 1; +/// `CANDIDATE_TYPE` of a non-opaque triangle. +pub const CANDIDATE_NON_OPAQUE_TRIANGLE: u32 = 0; + +/// `RAY_FLAG_*` bits. +pub mod ray_flag { + pub const FORCE_OPAQUE: u32 = 0x1; + pub const FORCE_NON_OPAQUE: u32 = 0x2; + pub const ACCEPT_FIRST_HIT_AND_END_SEARCH: u32 = 0x4; + pub const SKIP_CLOSEST_HIT_SHADER: u32 = 0x8; + pub const SKIP_PROCEDURAL_PRIMITIVES: u32 = 0x200; +} + +/// A ray: origin, `t` interval and direction (`RayDesc`). +#[derive(Clone, Copy)] +pub struct Ray { + pub origin: [Value; 3], + pub tmin: Value, + pub dir: [Value; 3], + pub tmax: Value, +} + +impl Shader { + /// `RaytracingAccelerationStructure` at `t<lower>, space<space>`: its handle, created in the + /// current block (call before emitting other code in the entry block). + pub fn accel_struct(&mut self, lower: u32, space: u32) -> Value { ~~~~ --- **Medium**: `ray_query` only requires SM 6.5, but both ways to get an acceleration structure need SM 6.6: `accel_struct` (no guard) and `heap_accel_struct` (guarded at 6.6). `Shader::new(_, (6, 5))` plus `accel_struct(0, 0)` and `trace_any_hit` passes every assertion but emits `createHandleFromBinding`/`annotateHandle` (ops 217/216), which only exist in SM 6.6, so the output is invalid DXIL. The 6.5 guard and `ray_query_rejects_sm_below_6_5` claim support the builder can't produce. Adding the 6.6 assert to `accel_struct` (or raising `ray_query`'s guard) would make it consistent.
bmjask commented 2026-12-02 19:55:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T19:55:54Z.

Review: COMMENTED


Review of 5bfb2274: 2 finding(s) (2 medium), most severe first.

  1. Medium crates/xcl/src/gpu/dxil/shader.rs:510: see below.
  2. Medium crates/xcl/src/gpu/dxil/ray_query.rs:62: ray_query only requires SM 6.5, but both ways to get an acceleration structure need SM 6.6: accel_struct (no guard) and heap_accel_struct (guarded at 6.6). (inline)

On lines outside the diff:

  1. Medium crates/xcl/src/gpu/dxil/shader.rs:510: infer_type_features never clears Feature::RaytracingTier1_1 when the optimizer removes every RayQuery op, though it does for heap indexing, int64 atomics and the other flags. If a translated shader calls trace_any_hit in a branch that optimize() folds away as unreachable, ray_query() has already set the feature, so the container declares Raytracing tier 1.1 with no RayQuery op left, and the validator rejects the shader with 'Flags must match usage', the case infer_type_features exists to prevent. Recomputing the flag from the remaining ops would fix it.

These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it.

<!-- greyfinch-sync:ivall/xcl:review:6157883169 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3659#pullrequestreview-6157883169). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T19:55:54Z. **Review:** COMMENTED --- Review of `5bfb2274`: 2 finding(s) (2 medium), most severe first. 1. **Medium** `crates/xcl/src/gpu/dxil/shader.rs:510`: see below. 2. **Medium** `crates/xcl/src/gpu/dxil/ray_query.rs:62`: `ray_query` only requires SM 6.5, but both ways to get an acceleration structure need SM 6.6: `accel_struct` (no guard) and `heap_accel_struct` (guarded at 6.6). (inline) **On lines outside the diff:** 1. **Medium** `crates/xcl/src/gpu/dxil/shader.rs:510`: `infer_type_features` never clears `Feature::RaytracingTier1_1` when the optimizer removes every RayQuery op, though it does for heap indexing, int64 atomics and the other flags. If a translated shader calls `trace_any_hit` in a branch that `optimize()` folds away as unreachable, `ray_query()` has already set the feature, so the container declares Raytracing tier 1.1 with no RayQuery op left, and the validator rejects the shader with 'Flags must match usage', the case `infer_type_features` exists to prevent. Recomputing the flag from the remaining ops would fix it. --- _These findings come from an AI-assisted review (Claude Code) and focus on correctness. Each is a candidate; please check it before acting on it._
bmjask commented 2026-12-02 19:56:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T19:56:00Z.


@Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.

<!-- greyfinch-sync:ivall/xcl:comment:7356951225 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3659#issuecomment-7356951225). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T19:56:00Z. --- @Prime1997 could you take a look at this one for review and merge? My automated review notes are above, if any.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3659:upstream-pr/3659'
git switch 'upstream-pr/3659'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3659'
git switch 'upstream-pr/3659'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3659'
git switch 'upstream-pr/3659'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3659'
git switch 'main'
git merge --squash 'upstream-pr/3659'
git switch 'main'
git merge --ff-only 'upstream-pr/3659'
git switch 'main'
git merge 'upstream-pr/3659'
git push origin 'main'
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
xcl-dev/xcl!3659
No description provided.