Skip to content

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

Open
Kalmarv wants to merge 1 commit into
xcl-dev:mainfrom
Kalmarv:pr/dxil-rayquery
Open

Kalmarv wants to merge 1 commit into
xcl-dev:mainfrom
Kalmarv:pr/dxil-rayquery

Conversation

@Kalmarv

@Kalmarv Kalmarv commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Dec 2, 2026
@Kalmarv
Kalmarv marked this pull request as draft December 2, 2026 04:59
@github-actions github-actions Bot added the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Dec 2, 2026
@github-actions github-actions Bot removed the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Dec 2, 2026
@Kalmarv
Kalmarv marked this pull request as ready for review December 2, 2026 05:47
@github-actions github-actions Bot added needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU labels Dec 2, 2026
@Foniass

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Review (head 9c33b8c, 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. Recompiler: bound a shadow traversal with native RayQuery #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 (Recompiler: identify a verified shadow traversal region #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

Foniass commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: 1c8b551
head: 9c33b8c
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 #3659 (comment) 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 1c8b551 vs this merge (9c33b8c): 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.

@github-actions github-actions Bot removed needs-1st-check Passes gates; needs first independent merge-check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU needs:nvidia-test Needs a test report or merge-check on an NVIDIA GPU labels Dec 2, 2026
@Kalmarv

Kalmarv commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

@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

Kalmarv commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

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.

Add direct-DXIL inline ray tracing support on Shader without changing any runtime path yet:

- RaytracingAccelerationStructure SRVs (static t# binding and ResourceDescriptorHeap indexing requiring SM 6.6+, kind 16, U32 element type, PSV0 SrvRaw).
- allocateRayQuery (requiring SM 6.5+), rayQuery_TraceRayInline, Proceed, Abort, CommitNonOpaqueTriangleHit, and StateScalar / StateVector queries (committed and candidate status, type, t, barycentrics, instance index / ID, geometry, primitive, front face).
- Opcodes, overloads, and attributes match DXC 1.9 (state queries are readonly so CSE never merges them across Proceed); Feature::RaytracingTier1_1 sets metadata bit 25 and container bit 0x100000.
- Helpers Shader::trace_any_hit (opaque first-hit shadow query with SKIP_PROCEDURAL_PRIMITIVES so procedural AABBs cannot stall the single-Proceed search) and Shader::trace_translucent (FORCE_NON_OPAQUE Proceed loop committing back faces and tracking the nearest front face).
- DXIL 1.9 validator, SM 6.5/6.6 guard tests, and WARP DXR 1.1 execution tests comparing closest hit (t0 and descriptor heap, 48 single-triangle BLAS instances so the comparison does not depend on WARP's multi-triangle BLAS builder), non-zero primitive index on a 2-triangle BLAS, first hit, procedural-AABB skip in trace_any_hit, translucent back-face commit, FRONT_COUNTERCLOCKWISE, negative-determinant mirrored transform (object-space winding per DXR spec), front1/back2, and fronts-only against a CPU walk / f64 Moller-Trumbore reference.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assisted-by: Antigravity (Gemini 4 Neon)
@Kalmarv

Kalmarv commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

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

Kalmarv commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

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

Foniass commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

merge-check
base: 5eaadb5
head: 5bfb227
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 5bfb227; my last review was on 9c33b8c. 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 (D3D12.X: hw_rt registry and DXR geometry translation #3697 / D3D12.X: opt-in XCL_HW_RT shadow builder #3700 / D3D12.X: native top-level table for XCL_HW_RT_TRAVERSE #3704 / DXIL: swap GPURT traversal loops for native RayQuery (XCL_HW_RT_TRAVERSE) #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.

@github-actions github-actions Bot added needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) needs:amd-test Needs a test report or merge-check on an AMD GPU labels Dec 2, 2026
@stijn-boer

stijn-boer commented Dec 2, 2026 •

Copy link
Copy Markdown

merge-check
base: c53e969
head: 5bfb227
verdict: not yet: the targeted validator checks passed, the workspace suite aborted on both builds, and the WARP ray-query execution test skipped.

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.

@github-actions github-actions Bot added needs:title-run Runtime change: needs a merge-check with a real title run into the world (#3041) checks-disagree Merge-checks disagree (safe vs not yet); needs maintainer/3rd look and removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) labels Dec 2, 2026

@bmjask bmjask left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

bmjask commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 checks-disagree Merge-checks disagree (safe vs not yet); needs maintainer/3rd look gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) needs:amd-test Needs a test report or merge-check on an AMD GPU needs:title-run Runtime change: needs a merge-check with a real title run into the world (#3041)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants