DXIL: swap GPURT traversal loops for native RayQuery (XCL_HW_RT_TRAVERSE) #3705

Open
Kalmarv wants to merge 6 commits from upstream-pr/3705 into main
Kalmarv commented 2026-12-02 16:00:25 +00:00 (Migrated from github.com)

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


Add direct-DXIL GPURT inline traversal loop recognition and native RayQuery lowering (XCL_HW_RT_TRAVERSE=1, requiring XCL_HW_RT=1 and XCL_RAYTRACING not disabled). Off by default; compute disk translation cache entries are isolated via a compute-only _hwrt3 filename suffix in translated::file_for so enabling XCL_HW_RT_TRAVERSE=1 reuses all existing graphics (VS/PS/MS) translated caches instead of busting the global cache directory.

Part of #1751. Stacked on #3704 (0e42eb3f8; only commit 1f287a928 belongs here).
Related: #2184, #2185, #2186, #2187, #2188, #2189.

Why this PR is over 800 changed lines: The diff is +1161 / -6 lines across 5 files, consisting of ~870 production lines (gpurt.rs CFG liveness, visibility and translucent loop recognizers, and Lw::traversal_swap/Lw::translucent_swap lowering; kernel.rs loop-entry hook; pso.rs compute-scoped _hwrt3 cache discriminator; shaders.rs semantic pipeline setting) and ~291 lines of synthetic RDNA2 and cache-isolation unit tests. The native top-level table, Shader::native_tlas, and shared-heap descriptor reservation were already split into #3704; splitting the loop recognizers from the Lw lowering or their validation tests would either add unused code or land unverified DXIL emission.

What is in it

  • crates/xcl/src/gpu/dxil/gpurt.rs & mod.rs:
    • traverse_enabled() and with_traverse_for_tests(...) delegating directly to hw_rt::traverse_enabled() and hw_rt::with_traverse_for_tests(...).
    • CFG liveness and single-entry / single-exit natural-loop extraction for GPURT image_bvh64_intersect_ray sites.
    • visibility_of: recognizes opaque first-hit visibility loops (single live-out hit VGPR read only via zero comparisons after the loop, no side-effecting memory ops and no non-node BUFFER_/TBUFFER_/S_LOAD/S_BUFFER_LOAD/SCRATCH_/FLAT_ or non-BVH IMAGE_ loads, known ray and top-level registers, single instance-mask test).
    • translucent_of: recognizes translucent closest-hit loops with folded FORCE_NON_OPAQUE ray flags (no culling), proving front-face 0xFE hit-kind polarity directly on the lane mask SGPR driving every V_CNDMASK_B32 write to front (V_CMP_EQ_U32 0xFE with (front, min) or V_CMP_NE_U32 0xFE with (min, front) in the same block), plus committed-pointer, optional iteration-cap, and post-loop LDS checks.
    • Lw::traversal_swap / Lw::translucent_swap: looks up each active lane's console TLAS VA in MEM_HW_RT_TABLE; if any active lane misses, the whole wave falls back to the software BVH walk; otherwise each active lane with an ordered valid ray interval (tmax >= tmin, Pred::FOGe) traces via Shader::trace_any_hit or Shader::trace_translucent and jumps past the loop (zeroing capped for all active lanes).
    • Synthetic RDNA2 unit tests verifying visibility recognition and rejection of non-node loads (BUFFER_LOAD_DWORD and IMAGE_SAMPLE), translucent S3 polarity acceptance and rejection (inverted polarity and unrelated 0xFE mask), S4 fcmp oge float guard emission, and DXC 1.9 validation.
  • crates/xcl/src/gpu/dxil/kernel.rs: wire gpurt::swaps into non-compact compute/kernel translation, routing each swapped loop's entry edge through lw.swap(...).
  • crates/xcl/src/gpu/recomp/pso.rs: scope the XCL_HW_RT_TRAVERSE=1 translation disk cache discriminator strictly to Stage::Compute via a _hwrt3 filename suffix in translated::file_for / file_for_with (leaving global translated::identity_from_source() unchanged so graphics shaders VS/PS/MS keep their existing cache directory and files; direct_output_identity keeps xcl-hw-rt-traverse-3 for rerouted enormous compute shaders, and hw_rt::traverse_enabled() is process-constant OnceLock so in-RAM ShaderCache cannot mix entries). Adds hw_rt_traverse_cache_key_is_compute_only covering identity_from_source, file_for_with / file_for across graphics and compute stages, and disk round-trip non-collision.
  • crates/xcl/src/shaders.rs: add XCL_HW_RT_TRAVERSE to semantic_pipeline_setting (and assert it in warm_settings_ignore_waits_watchdogs_and_traces_but_keep_pipeline_switches) so warm pipeline preparation tracks the compute setting without altering global translation_cache_identity.

Tested
Hardware: Windows 11 x64 (10.0.26200), NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074 / 610.74, 15995 MiB VRAM, DXR Tier 1.1), AMD Ryzen 9 9950X, rustc 1.99.0, DXC 1.9.2609.5 (XCL_DXC_DIR).

  • cargo build --release -p xcl (commit 1f287a928352ac71dcb238a3a5d3d4dd4741c3e0): succeeded, 39 warnings (0 new vs main).
  • .\scripts\test.ps1 (commit 1f287a928352ac71dcb238a3a5d3d4dd4741c3e0): 3006 passed, 0 failed, 52 ignored across 43 test suites; 24 GPU tests skipped on this adapter (22 no wave64, 2 no heap windows), including hw_rt_traverse_cache_key_is_compute_only, warm_settings_ignore_waits_watchdogs_and_traces_but_keep_pipeline_switches, both gpu::dxil::gpurt synthetic tests, hw_rt_table::tests (3/3), hw_rt::tests (9/9), ray_query::tests (4/4), and hle::bvh_builder::tests (12/12) — all ran with 0 skips.
  • Prior live 180 s 16-window XCL_HW_RT=1 XCL_HW_RT_TRAVERSE=1 XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 run on previous revision 112374d1907e1d234a2cea4a9edd1eb1a83ca540 (same traversal lowering, before the compute-scoped cache fix and #3662/#3704 review fixes; XCL_PREPARE=0, XCL_NETWORK=0, XCL_PSO_EVICT_FRAMES=600, automated title-screen advance): exit: 0x0, 1971 frames shown, 0 device removals, 0 crashes:
    • D3D12.X: XCL_HW_RT_TRAVERSE: native top-level table at descriptor 22 (8 entries)
    • 4 shaders translated with [SHADER] direct DXIL: 1 ray traversal loop(s) swapped for a native RayQuery when the top level has one
    • D3D12.X: XCL_HW_RT_TRAVERSE: native top-level table: 3 published, 0 taken out
    • HW RT shadow (XCL_HW_RT): live 2620 BLAS / 5 TLAS / 134 rehydrated (240 MiB AS, 123 MiB pools); built 1331 BLAS (0 updates, 1327 skipped), 150 TLAS (80 complete, 70 hybrid, 0 skipped); insts 106502 resolved / 0 null / 2194 rehydrated-skip / 33102 missing-skip; 1764 rehydrated recorded (1618 built natively, 146 count mismatch), 159 stale invalidated, 0 copy-invalidated, 0 copied natively, 0 alloc-err, 0 budget-skip
  • Prior live 180 s default-layout XCL_HW_RT=1 XCL_HW_RT_TRAVERSE=1 run on previous revision 112374d1907e1d234a2cea4a9edd1eb1a83ca540 (same settings): exit: 0x0, 1947 frames shown, 0 device removals, 0 crashes; 4 shaders swapped, native top-level table: 2 published, 0 taken out:
    • HW RT shadow (XCL_HW_RT): live 2 BLAS / 5 TLAS / 225 rehydrated (1 MiB AS, 10 MiB pools); built 2 BLAS (0 updates, 13247 skipped), 536 TLAS (240 complete, 296 hybrid, 0 skipped); insts 259119 resolved / 0 null / 9506 rehydrated-skip / 236718 missing-skip; 4526 rehydrated recorded (0 built natively, 388 count mismatch), 0 stale invalidated, 0 copy-invalidated, 0 copied natively, 0 alloc-err, 0 budget-skip

Regression run

Base (main):

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

PR (pr/hw-rt-traverse):

xcl-smoke v1
commit: 1f287a928352ac71dcb238a3a5d3d4dd4741c3e0
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 60
exit: 0x0
frames shown: 1648 (PresentX 1648)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15404 MB

Not tested

  • The 180 s live XCL_HW_RT_TRAVERSE=1 runs were performed on previous revision 112374d19 and were not re-run after scoping the disk cache key and restacking on updated #3662/#3704 (1f287a928).
  • No runtime counter shows a swapped dispatch traced a native top level. The live runs show swapped shaders (4 shaders), published entries (3 on 16-window, 2 on default), and 0 device removals.
  • Visibility loops: the console ray's cull flags are not checked. The native query is opaque first-hit with no culling, so a loop that culls back faces would find more hits natively.
  • GLOBAL_ loads in the loop are accepted as node fetches (same as translucent_of), so an alpha test that fetches only through global loads with no image sample or buffer/scalar load would not be caught.
  • Translucent loops: the front-face side of the 0xFE select is proven. That the commit (t max, pointer) happens only on the back-face side is not proven separately; the FORCE_NON_OPAQUE fold and the 0xFE min imply it.
  • Pixel-level A/B image diff between software BVH walk and native RayQuery traversal.
  • Underlying shadow-builder stability on the 16-window layout: see #3700 Known limitations #6 (1 of 3 XCL_HW_RT=1 16-window runs ended in 0x887a0006; this PR's 180 s 16-window XCL_HW_RT_TRAVERSE=1 run completed cleanly with 0 device removals).
  • AMD/Intel GPUs, native wave64 GPU tests (22 skipped on RTX 5070 Ti), opt-in XCL_HEAP_WINDOWS=1 tests (2 skipped), and sample-gated tests (XCL_SAMPLE_* unset).

AI use

  • Claude Code (Claude Opus 5.5): architecture, traversal loop safety audit (S3 front-face polarity proof, S4 tmax >= tmin guard, visibility non-node load rejection, B4 env gating, B5 synthetic test cleanup).
  • Antigravity (Gemini 4 Neon): implementation, rebase onto updated #3662/#3704, compute-scoped _hwrt3 cache key fix and cache-isolation unit tests, synthetic RDNA2 unit tests, release build, full test suite, regression smoke, live 16-window and default XCL_HW_RT_TRAVERSE=1 verification, and PR description.
<!-- greyfinch-sync:ivall/xcl:issue:5610114141 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3705). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T16:00:25Z. --- Add direct-DXIL GPURT inline traversal loop recognition and native `RayQuery` lowering (`XCL_HW_RT_TRAVERSE=1`, requiring `XCL_HW_RT=1` and `XCL_RAYTRACING` not disabled). Off by default; compute disk translation cache entries are isolated via a compute-only `_hwrt3` filename suffix in `translated::file_for` so enabling `XCL_HW_RT_TRAVERSE=1` reuses all existing graphics (`VS`/`PS`/`MS`) translated caches instead of busting the global cache directory. Part of #1751. Stacked on #3704 (`0e42eb3f8`; only commit `1f287a928` belongs here). Related: #2184, #2185, #2186, #2187, #2188, #2189. **Why this PR is over 800 changed lines:** The diff is +1161 / -6 lines across 5 files, consisting of ~870 production lines (`gpurt.rs` CFG liveness, visibility and translucent loop recognizers, and `Lw::traversal_swap`/`Lw::translucent_swap` lowering; `kernel.rs` loop-entry hook; `pso.rs` compute-scoped `_hwrt3` cache discriminator; `shaders.rs` semantic pipeline setting) and ~291 lines of synthetic RDNA2 and cache-isolation unit tests. The native top-level table, `Shader::native_tlas`, and shared-heap descriptor reservation were already split into #3704; splitting the loop recognizers from the `Lw` lowering or their validation tests would either add unused code or land unverified DXIL emission. **What is in it** - `crates/xcl/src/gpu/dxil/gpurt.rs` & `mod.rs`: - `traverse_enabled()` and `with_traverse_for_tests(...)` delegating directly to `hw_rt::traverse_enabled()` and `hw_rt::with_traverse_for_tests(...)`. - CFG liveness and single-entry / single-exit natural-loop extraction for GPURT `image_bvh64_intersect_ray` sites. - `visibility_of`: recognizes opaque first-hit visibility loops (single live-out hit VGPR read only via zero comparisons after the loop, no side-effecting memory ops and no non-node `BUFFER_`/`TBUFFER_`/`S_LOAD`/`S_BUFFER_LOAD`/`SCRATCH_`/`FLAT_` or non-BVH `IMAGE_` loads, known ray and top-level registers, single instance-mask test). - `translucent_of`: recognizes translucent closest-hit loops with folded `FORCE_NON_OPAQUE` ray flags (no culling), proving front-face `0xFE` hit-kind polarity directly on the lane mask SGPR driving every `V_CNDMASK_B32` write to `front` (`V_CMP_EQ_U32 0xFE` with `(front, min)` or `V_CMP_NE_U32 0xFE` with `(min, front)` in the same block), plus committed-pointer, optional iteration-cap, and post-loop LDS checks. - `Lw::traversal_swap` / `Lw::translucent_swap`: looks up each active lane's console TLAS VA in `MEM_HW_RT_TABLE`; if any active lane misses, the whole wave falls back to the software BVH walk; otherwise each active lane with an ordered valid ray interval (`tmax >= tmin`, `Pred::FOGe`) traces via `Shader::trace_any_hit` or `Shader::trace_translucent` and jumps past the loop (zeroing `capped` for all active lanes). - Synthetic RDNA2 unit tests verifying visibility recognition and rejection of non-node loads (`BUFFER_LOAD_DWORD` and `IMAGE_SAMPLE`), translucent S3 polarity acceptance and rejection (inverted polarity and unrelated `0xFE` mask), S4 `fcmp oge float` guard emission, and DXC 1.9 validation. - `crates/xcl/src/gpu/dxil/kernel.rs`: wire `gpurt::swaps` into non-compact compute/kernel translation, routing each swapped loop's entry edge through `lw.swap(...)`. - `crates/xcl/src/gpu/recomp/pso.rs`: scope the `XCL_HW_RT_TRAVERSE=1` translation disk cache discriminator strictly to `Stage::Compute` via a `_hwrt3` filename suffix in `translated::file_for` / `file_for_with` (leaving global `translated::identity_from_source()` unchanged so graphics shaders `VS`/`PS`/`MS` keep their existing cache directory and files; `direct_output_identity` keeps `xcl-hw-rt-traverse-3` for rerouted enormous compute shaders, and `hw_rt::traverse_enabled()` is process-constant `OnceLock` so in-RAM `ShaderCache` cannot mix entries). Adds `hw_rt_traverse_cache_key_is_compute_only` covering `identity_from_source`, `file_for_with` / `file_for` across graphics and compute stages, and disk round-trip non-collision. - `crates/xcl/src/shaders.rs`: add `XCL_HW_RT_TRAVERSE` to `semantic_pipeline_setting` (and assert it in `warm_settings_ignore_waits_watchdogs_and_traces_but_keep_pipeline_switches`) so warm pipeline preparation tracks the compute setting without altering global `translation_cache_identity`. **Tested** Hardware: Windows 11 x64 (10.0.26200), NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074 / 610.74, 15995 MiB VRAM, DXR Tier 1.1), AMD Ryzen 9 9950X, `rustc 1.99.0`, DXC `1.9.2609.5` (`XCL_DXC_DIR`). - `cargo build --release -p xcl` (commit `1f287a928352ac71dcb238a3a5d3d4dd4741c3e0`): succeeded, 39 warnings (0 new vs `main`). - `.\scripts\test.ps1` (commit `1f287a928352ac71dcb238a3a5d3d4dd4741c3e0`): **3006 passed, 0 failed, 52 ignored** across 43 test suites; **24 GPU tests skipped** on this adapter (22 `no wave64`, 2 `no heap windows`), including `hw_rt_traverse_cache_key_is_compute_only`, `warm_settings_ignore_waits_watchdogs_and_traces_but_keep_pipeline_switches`, both `gpu::dxil::gpurt` synthetic tests, `hw_rt_table::tests` (3/3), `hw_rt::tests` (9/9), `ray_query::tests` (4/4), and `hle::bvh_builder::tests` (12/12) — all ran with 0 skips. - Prior live 180 s 16-window `XCL_HW_RT=1 XCL_HW_RT_TRAVERSE=1 XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16` run on previous revision `112374d1907e1d234a2cea4a9edd1eb1a83ca540` (same traversal lowering, before the compute-scoped cache fix and #3662/#3704 review fixes; `XCL_PREPARE=0`, `XCL_NETWORK=0`, `XCL_PSO_EVICT_FRAMES=600`, automated title-screen advance): `exit: 0x0`, `1971` frames shown, `0` device removals, `0` crashes: - `D3D12.X: XCL_HW_RT_TRAVERSE: native top-level table at descriptor 22 (8 entries)` - 4 shaders translated with `[SHADER] direct DXIL: 1 ray traversal loop(s) swapped for a native RayQuery when the top level has one` - `D3D12.X: XCL_HW_RT_TRAVERSE: native top-level table: 3 published, 0 taken out` - `HW RT shadow (XCL_HW_RT): live 2620 BLAS / 5 TLAS / 134 rehydrated (240 MiB AS, 123 MiB pools); built 1331 BLAS (0 updates, 1327 skipped), 150 TLAS (80 complete, 70 hybrid, 0 skipped); insts 106502 resolved / 0 null / 2194 rehydrated-skip / 33102 missing-skip; 1764 rehydrated recorded (1618 built natively, 146 count mismatch), 159 stale invalidated, 0 copy-invalidated, 0 copied natively, 0 alloc-err, 0 budget-skip` - Prior live 180 s default-layout `XCL_HW_RT=1 XCL_HW_RT_TRAVERSE=1` run on previous revision `112374d1907e1d234a2cea4a9edd1eb1a83ca540` (same settings): `exit: 0x0`, `1947` frames shown, `0` device removals, `0` crashes; 4 shaders swapped, `native top-level table: 2 published, 0 taken out`: - `HW RT shadow (XCL_HW_RT): live 2 BLAS / 5 TLAS / 225 rehydrated (1 MiB AS, 10 MiB pools); built 2 BLAS (0 updates, 13247 skipped), 536 TLAS (240 complete, 296 hybrid, 0 skipped); insts 259119 resolved / 0 null / 9506 rehydrated-skip / 236718 missing-skip; 4526 rehydrated recorded (0 built natively, 388 count mismatch), 0 stale invalidated, 0 copy-invalidated, 0 copied natively, 0 alloc-err, 0 budget-skip` **Regression run** Base (`main`): ``` 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 ``` PR (`pr/hw-rt-traverse`): ``` xcl-smoke v1 commit: 1f287a928352ac71dcb238a3a5d3d4dd4741c3e0 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 60 exit: 0x0 frames shown: 1648 (PresentX 1648) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15404 MB ``` **Not tested** - The 180 s live `XCL_HW_RT_TRAVERSE=1` runs were performed on previous revision `112374d19` and were not re-run after scoping the disk cache key and restacking on updated #3662/#3704 (`1f287a928`). - No runtime counter shows a swapped dispatch traced a native top level. The live runs show swapped shaders (4 shaders), published entries (`3` on 16-window, `2` on default), and `0` device removals. - Visibility loops: the console ray's cull flags are not checked. The native query is opaque first-hit with no culling, so a loop that culls back faces would find more hits natively. - `GLOBAL_` loads in the loop are accepted as node fetches (same as `translucent_of`), so an alpha test that fetches only through global loads with no image sample or buffer/scalar load would not be caught. - Translucent loops: the front-face side of the `0xFE` select is proven. That the commit (`t` max, pointer) happens only on the back-face side is not proven separately; the `FORCE_NON_OPAQUE` fold and the `0xFE` min imply it. - Pixel-level A/B image diff between software BVH walk and native `RayQuery` traversal. - Underlying shadow-builder stability on the 16-window layout: see #3700 Known limitations #6 (1 of 3 `XCL_HW_RT=1` 16-window runs ended in `0x887a0006`; this PR's 180 s 16-window `XCL_HW_RT_TRAVERSE=1` run completed cleanly with `0` device removals). - AMD/Intel GPUs, native wave64 GPU tests (22 skipped on RTX 5070 Ti), opt-in `XCL_HEAP_WINDOWS=1` tests (2 skipped), and sample-gated tests (`XCL_SAMPLE_*` unset). **AI use** - Claude Code (`Claude Opus 5.5`): architecture, traversal loop safety audit (S3 front-face polarity proof, S4 `tmax >= tmin` guard, visibility non-node load rejection, B4 env gating, B5 synthetic test cleanup). - Antigravity (`Gemini 4 Neon`): implementation, rebase onto updated #3662/#3704, compute-scoped `_hwrt3` cache key fix and cache-isolation unit tests, synthetic RDNA2 unit tests, release build, full test suite, regression smoke, live 16-window and default `XCL_HW_RT_TRAVERSE=1` verification, and PR description.
KDenKC commented 2026-12-02 16:15:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KDenKC on 2026-12-02T16:15:55Z.


@Kalmarv a heads-up for #3705 from reading the retail title's main ray program (not a run yet; we'll run your stack as soon as our rig is free):

  • The program is 8994bb33444988e6 (compute). Its node test is a GPURT site: image_bvh at 0x3a84 with s19 = 0x890003ff (your GPURT_DESC_W3).
  • Its innermost loop around that test is 0x3818-0x479c: one external entry (0xb7c: s_branch 0x3818), one exit (the fall-through at 0x47a0); 0x3810 is only reached from the back edge. So the loop itself should pass the single-entry/single-exit check.
  • But the program is about 11,700 instructions (47,768 B of code), above compact.rs's LARGE_INSTS (10,000), so it most likely gets a compact plan, and kernel.rs only swaps when plan.is_none(). If that holds, #3705 leaves this program alone, and it's the one the title's ray tracing depends on.
  • Why it matters for us: in the interior scene we measure, every lane that enters this loop leaves it before the node test (the v51 == 3 check at 0x3a38, after the loop-guard block at 0x39d4-0x39e8), so node tests stay at 0. A native RayQuery in place of this loop would bypass that.

Would the swap be possible before compact planning (or inside it, per region)? Happy to test whatever you try. Your loyal testing minion, rig permitting.

AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen.

<!-- greyfinch-sync:ivall/xcl:comment:7351688780 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3705#issuecomment-7351688780). Originally posted by [KDenKC](https://github.com/KDenKC) on 2026-12-02T16:15:55Z. --- @Kalmarv a heads-up for #3705 from reading the retail title's main ray program (not a run yet; we'll run your stack as soon as our rig is free): - The program is `8994bb33444988e6` (compute). Its node test is a GPURT site: `image_bvh` at `0x3a84` with `s19 = 0x890003ff` (your `GPURT_DESC_W3`). - Its innermost loop around that test is `0x3818`-`0x479c`: one external entry (`0xb7c: s_branch 0x3818`), one exit (the fall-through at `0x47a0`); `0x3810` is only reached from the back edge. So the loop itself should pass the single-entry/single-exit check. - But the program is about 11,700 instructions (47,768 B of code), above `compact.rs`'s `LARGE_INSTS` (10,000), so it most likely gets a compact plan, and `kernel.rs` only swaps when `plan.is_none()`. If that holds, #3705 leaves this program alone, and it's the one the title's ray tracing depends on. - Why it matters for us: in the interior scene we measure, every lane that enters this loop leaves it before the node test (the `v51 == 3` check at `0x3a38`, after the loop-guard block at `0x39d4`-`0x39e8`), so node tests stay at 0. A native RayQuery in place of this loop would bypass that. Would the swap be possible before compact planning (or inside it, per region)? Happy to test whatever you try. Your loyal testing minion, rig permitting. AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen.
Kalmarv commented 2026-12-02 16:27:00 +00:00 (Migrated from github.com)

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


Thanks for the heads-up @KDenKC — confirmed on the code: kernel.rs:477 currently gates gpurt::swaps on plan.is_none(), so any compute shader that triggers compact::automatic_plan (LARGE_INSTS = 10_000 / LARGE_BLOCKS = 2_000) skips the swap in this PR.

Yes, wiring the swap into the compact path is doable cleanly in a follow-up PR: gpurt::swaps(&cfg, o.wave64) already runs on the pre-compaction Cfg, so compact::emit can intercept the entry -> header edge (or dispatch a swap case in the state switch) to run lw.swap(...) and branch cur to exit's compact index on the native path or header's compact index on wave fallback.

One caveat to check when testing 8994bb33444988e6 (0x3818–0x479c): #3705 only recognizes opaque first-hit visibility loops (single live-out hit VGPR, no non-node BUFFER_/IMAGE_/S_LOAD/etc. loads) and FORCE_NON_OPAQUE translucent loops (0xFE front-face min). If 0x3818–0x479c returns full closest-hit attributes (e.g. t, barycentrics, primitive/instance IDs) or loads non-node buffers/textures inside the loop, it will also need a closest-hit recognizer on top of compact-path support.

Keeping #3705 scoped to the non-compact path as-is (it's already +1073 lines and CI-green), and we'll look at compact-form swap support + checking what gpurt::swaps says about 8994bb33444988e6 in a follow-up stacked PR.

<!-- greyfinch-sync:ivall/xcl:comment:7351963430 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3705#issuecomment-7351963430). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T16:27:00Z. --- Thanks for the heads-up @KDenKC — confirmed on the code: `kernel.rs:477` currently gates `gpurt::swaps` on `plan.is_none()`, so any compute shader that triggers `compact::automatic_plan` (`LARGE_INSTS = 10_000` / `LARGE_BLOCKS = 2_000`) skips the swap in this PR. Yes, wiring the swap into the compact path is doable cleanly in a follow-up PR: `gpurt::swaps(&cfg, o.wave64)` already runs on the pre-compaction `Cfg`, so `compact::emit` can intercept the `entry -> header` edge (or dispatch a swap case in the state switch) to run `lw.swap(...)` and branch `cur` to `exit`'s compact index on the native path or `header`'s compact index on wave fallback. One caveat to check when testing `8994bb33444988e6` (`0x3818`–`0x479c`): `#3705` only recognizes opaque first-hit visibility loops (single live-out hit VGPR, no non-node `BUFFER_`/`IMAGE_`/`S_LOAD`/etc. loads) and `FORCE_NON_OPAQUE` translucent loops (`0xFE` front-face min). If `0x3818`–`0x479c` returns full closest-hit attributes (e.g. `t`, barycentrics, primitive/instance IDs) or loads non-node buffers/textures inside the loop, it will also need a closest-hit recognizer on top of compact-path support. Keeping `#3705` scoped to the non-compact path as-is (it's already +1073 lines and CI-green), and we'll look at compact-form swap support + checking what `gpurt::swaps` says about `8994bb33444988e6` in a follow-up stacked PR.
KDenKC commented 2026-12-02 18:26:24 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by KDenKC on 2026-12-02T18:26:24Z.


@Kalmarv a correction to my note above, sorry: I counted the whole listing (~11,700 lines), not what compact.rs counts. For 8994bb33444988e6 the reachable blocks are 878 (under LARGE_BLOCKS 2,000) and the reachable non-terminator instructions 8,648 (under LARGE_INSTS 10,000), and its two buffer_atomic_add have GLC=0, so it most likely lowers plain and plan.is_none() holds: #3705 should get to try the swap on it after all.

For the matcher, from the disassembly: the loop is 0x3810-0x479c (back edge to 0x3810), 83 blocks / 757 instructions, entered from 0xa88 -> 0x3818 besides the latch, one exit 0x4788 -> 0x47a0, one image_bvh64 (0x3a84). The values read right after the exit come from the commit block at 0x4600-0x4660: v22 (committed t), v27 (t compared at 0x47a4), v31 (flags, bit 2), v33 (record index), v38 (a 10-bit field of the hit record), v32 (tested against -1), v28-v30. We'll confirm with a run of your stack (XCL_HW_RT=1 XCL_HW_RT_TRAVERSE=1) as soon as our rig is free and report what the swap log says for this program.

AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen.

<!-- greyfinch-sync:ivall/xcl:comment:7354585952 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3705#issuecomment-7354585952). Originally posted by [KDenKC](https://github.com/KDenKC) on 2026-12-02T18:26:24Z. --- @Kalmarv a correction to my note above, sorry: I counted the whole listing (~11,700 lines), not what `compact.rs` counts. For `8994bb33444988e6` the reachable blocks are 878 (under `LARGE_BLOCKS` 2,000) and the reachable non-terminator instructions 8,648 (under `LARGE_INSTS` 10,000), and its two `buffer_atomic_add` have GLC=0, so it most likely lowers plain and `plan.is_none()` holds: #3705 should get to try the swap on it after all. For the matcher, from the disassembly: the loop is `0x3810`-`0x479c` (back edge to `0x3810`), 83 blocks / 757 instructions, entered from `0xa88 -> 0x3818` besides the latch, one exit `0x4788 -> 0x47a0`, one `image_bvh64` (`0x3a84`). The values read right after the exit come from the commit block at `0x4600`-`0x4660`: `v22` (committed t), `v27` (t compared at `0x47a4`), `v31` (flags, bit 2), `v33` (record index), `v38` (a 10-bit field of the hit record), `v32` (tested against -1), `v28`-`v30`. We'll confirm with a run of your stack (`XCL_HW_RT=1 XCL_HW_RT_TRAVERSE=1`) as soon as our rig is free and report what the swap log says for this program. AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen.
Kalmarv commented 2026-12-02 18:36:36 +00:00 (Migrated from github.com)

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


Thanks for the correction and the live-out breakdown @KDenKC! Good news that plan.is_none() holds on 8994bb33444988e6.

From those live-outs (v22, v27, v28–v33, v38 — committed t, record index, hit-record fields, etc.), 8994bb33444988e6 looks like a general closest-hit loop rather than the opaque visibility (1 live-out hit VGPR) or FORCE_NON_OPAQUE translucent (tmax/front/committed/capped) shapes #3705 recognizes, so #3705 will likely leave it on the software walk and it would be a natural target for a dedicated closest-hit matcher follow-up on top of #3705. Looking forward to seeing what your run reports!

<!-- greyfinch-sync:ivall/xcl:comment:7354872021 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3705#issuecomment-7354872021). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T18:36:36Z. --- Thanks for the correction and the live-out breakdown @KDenKC! Good news that `plan.is_none()` holds on `8994bb33444988e6`. From those live-outs (`v22`, `v27`, `v28`–`v33`, `v38` — committed `t`, record index, hit-record fields, etc.), `8994bb33444988e6` looks like a general closest-hit loop rather than the opaque visibility (1 live-out hit VGPR) or `FORCE_NON_OPAQUE` translucent (`tmax`/`front`/`committed`/`capped`) shapes `#3705` recognizes, so `#3705` will likely leave it on the software walk and it would be a natural target for a dedicated closest-hit matcher follow-up on top of `#3705`. Looking forward to seeing what your run reports!
Foniass commented 2026-12-03 01:33:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T01:33:46Z.


merge-check
base: 078358a058
head: 1f287a9283
merge: clean
build: ok
tests: 3038 passed, 0 failed, 52 ignored; 28 skipped, the same as on main
review: 6 medium, 1 nit (below)
performance: 60 s smoke run: 1669 → 1672 frames (100 % of main), peak commit 17577 → 16497 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 220 s there, 0 device removals, 0 crashes, 3.1 presents/s; run with XCL_SKIP_CS=95cc13288a27a96e (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)
verdict: not yet: PR description is red; otherwise no blocking finding, 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: Recognizes GPURT visibility and translucent closest-hit loops in non-compact compute programs and, with XCL_HW_RT_TRAVERSE=1, replaces each with a native RayQuery when every active lane's top level is in the table, else the wave runs the software walk; disk cache entries for compute get a _hwrt3 suffix. The default path is unchanged and the CFG wiring is right. The recognizers accept loops they can't prove equivalent, no test runs a swapped program, and the test override turns the feature on for every test running at the same time; nothing is critical, and all of it is opt-in.

Medium

  1. Recognizer accepts loops it does not prove equivalent. gpurt.rs: visibility_of (~434) does not check the console ray's cull flags, so the native first-hit query (no culling) can find back-face hits the console walk culls; GLOBAL_ loads are accepted as node fetches (~446/~532), so an alpha test reading through global loads would be skipped; loop_ray (~808) always traces from tmin 0 (probably fine if GPURT offsets the origin, not checked here); the translucent commit side is implied, not proven. Any mismatch gives wrong shadows or translucency with no runtime check. Check the cull bits like translucent_of's fold check, and reject GLOBAL_ loads not addressed from the node pointer.
  2. No test executes the lowered swap. The two gpurt tests check recognition, DXC validation and that the disassembly contains TraceRayInline and an fcmp oge. Nothing runs Lw::traversal_swap / translucent_swap output on WARP against the software walk (ray_query's WARP test runs a hand-written swap_kernel instead), so the wave fallback and the hit/t/front/committed/capped writes are untested at runtime. The if let Ok(dis) = validate::disassemble(..) (~996, ~1029) also skips the string checks silently if disassembly fails. A WARP A/B on the synthetic loops, using #3704's harness, would cover it.
  3. Test override flips the feature for the whole test binary. gpurt.rs tests wrap whole kernel::translate_compute calls, and pso.rs hw_rt_traverse_cache_key_is_compute_only wraps file_for, in with_traverse_for_tests(true, ..). The override is a process-wide atomic, and the lock only serializes callers of the helper, so other tests running at the same time get _hwrt3 file names, a different direct_output_identity, and the native table if they create the shared heap first. Could flake unrelated tests. Pass the flag explicitly (file_for_with already exists; same for translate) instead of flipping a global.
  4. Size over the limit, reason given. Own commit +1161/-6 (~870 production, ~290 tests). The description explains why it isn't split further.
  5. Opt-in path not run at this head. The 180 s XCL_HW_RT_TRAVERSE=1 runs were on 112374d19, before the cache-key change and the restack, and no counter shows a swapped dispatch tracing natively. KDenKC's main ray program (8994bb33) looks like a closest-hit loop that neither recognizer accepts. The smoke run covers only the default path.
  6. Carries #3704's stack. Same as #3704: a rebased copy of #3659 (70c8c51f3 vs 5bfb22746) and #3700's readable()+read_unaligned in read_archive_prims land with this PR.

Nit

  1. "Process-constant" comment is wrong. pso.rs ~413 says hw_rt::traverse_enabled() is process-constant (OnceLock), but since #3704 it reads config().raytracing_tier_override() on every call, so a call before the boot config loads can differ from later ones (in-RAM cache and file names would then disagree). Fix the comment, or cache the whole result once the config is loaded.
Checked and fine
  • Default path unchanged: swaps are built only when traverse_enabled() and plan.is_none(); with none, swap_preds is empty, to is head(), file_for adds no suffix and direct_output_identity is unchanged
  • CFG wiring: the swap block replaces only the entry-to-header edge, so the header's predecessor count stays the same and the exit gets one more (swap_preds)
  • native_top falls back for the whole wave when any active lane misses (ballot over both words, so wave64 too); lanes with tmax < tmin skip the trace
  • Visibility recognition requires exactly one live-out VGPR, read after the loop only by zero compares, and no stores, atomics, barriers or non-node loads in the loop; translucent recognition checks the folded FORCE_NON_OPAQUE flags and the 0xFE front-face polarity on the mask that drives the select, with negative tests
  • XCL_HW_RT_TRAVERSE is in semantic_pipeline_setting with an assertion; the cache-key test checks that graphics paths are unchanged and that compute entries with and without the flag both survive a disk round trip
How this was tested
  • Merged onto main 078358a0, 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 078358a0 and on this merge; presents per 2 s at the end: 60 60 60.
  • Title run: the release build of this merge launched the retail title with XCL_RUN_SECONDS=300 and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.

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

<!-- greyfinch-sync:ivall/xcl:comment:7364481954 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3705#issuecomment-7364481954). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T01:33:46Z. --- merge-check base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a head: 1f287a928352ac71dcb238a3a5d3d4dd4741c3e0 merge: clean build: ok tests: 3038 passed, 0 failed, 52 ignored; 28 skipped, the same as on main review: 6 medium, 1 nit (below) performance: 60 s smoke run: 1669 → 1672 frames (100 % of main), peak commit 17577 → 16497 MB, no device removal, no crash title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 220 s there, 0 device removals, 0 crashes, 3.1 presents/s; run with `XCL_SKIP_CS=95cc13288a27a96e` (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590) verdict: not yet: `PR description` is red; otherwise no blocking finding, 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:** Recognizes GPURT visibility and translucent closest-hit loops in non-compact compute programs and, with XCL_HW_RT_TRAVERSE=1, replaces each with a native RayQuery when every active lane's top level is in the table, else the wave runs the software walk; disk cache entries for compute get a _hwrt3 suffix. The default path is unchanged and the CFG wiring is right. The recognizers accept loops they can't prove equivalent, no test runs a swapped program, and the test override turns the feature on for every test running at the same time; nothing is critical, and all of it is opt-in. #### Medium 1. **Recognizer accepts loops it does not prove equivalent.** gpurt.rs: visibility_of (~434) does not check the console ray's cull flags, so the native first-hit query (no culling) can find back-face hits the console walk culls; GLOBAL_ loads are accepted as node fetches (~446/~532), so an alpha test reading through global loads would be skipped; loop_ray (~808) always traces from tmin 0 (probably fine if GPURT offsets the origin, not checked here); the translucent commit side is implied, not proven. Any mismatch gives wrong shadows or translucency with no runtime check. Check the cull bits like translucent_of's fold check, and reject GLOBAL_ loads not addressed from the node pointer. 2. **No test executes the lowered swap.** The two gpurt tests check recognition, DXC validation and that the disassembly contains TraceRayInline and an fcmp oge. Nothing runs Lw::traversal_swap / translucent_swap output on WARP against the software walk (ray_query's WARP test runs a hand-written swap_kernel instead), so the wave fallback and the hit/t/front/committed/capped writes are untested at runtime. The `if let Ok(dis) = validate::disassemble(..)` (~996, ~1029) also skips the string checks silently if disassembly fails. A WARP A/B on the synthetic loops, using #3704's harness, would cover it. 3. **Test override flips the feature for the whole test binary.** gpurt.rs tests wrap whole kernel::translate_compute calls, and pso.rs hw_rt_traverse_cache_key_is_compute_only wraps file_for, in with_traverse_for_tests(true, ..). The override is a process-wide atomic, and the lock only serializes callers of the helper, so other tests running at the same time get _hwrt3 file names, a different direct_output_identity, and the native table if they create the shared heap first. Could flake unrelated tests. Pass the flag explicitly (file_for_with already exists; same for translate) instead of flipping a global. 4. **Size over the limit, reason given.** Own commit +1161/-6 (~870 production, ~290 tests). The description explains why it isn't split further. 5. **Opt-in path not run at this head.** The 180 s XCL_HW_RT_TRAVERSE=1 runs were on 112374d19, before the cache-key change and the restack, and no counter shows a swapped dispatch tracing natively. KDenKC's main ray program (8994bb33) looks like a closest-hit loop that neither recognizer accepts. The smoke run covers only the default path. 6. **Carries #3704's stack.** Same as #3704: a rebased copy of #3659 (70c8c51f3 vs 5bfb22746) and #3700's readable()+read_unaligned in read_archive_prims land with this PR. #### Nit 7. **"Process-constant" comment is wrong.** pso.rs ~413 says hw_rt::traverse_enabled() is process-constant (OnceLock), but since #3704 it reads config().raytracing_tier_override() on every call, so a call before the boot config loads can differ from later ones (in-RAM cache and file names would then disagree). Fix the comment, or cache the whole result once the config is loaded. <details><summary>Checked and fine</summary> - Default path unchanged: swaps are built only when traverse_enabled() and plan.is_none(); with none, swap_preds is empty, `to` is head(), file_for adds no suffix and direct_output_identity is unchanged - CFG wiring: the swap block replaces only the entry-to-header edge, so the header's predecessor count stays the same and the exit gets one more (swap_preds) - native_top falls back for the whole wave when any active lane misses (ballot over both words, so wave64 too); lanes with tmax < tmin skip the trace - Visibility recognition requires exactly one live-out VGPR, read after the loop only by zero compares, and no stores, atomics, barriers or non-node loads in the loop; translucent recognition checks the folded FORCE_NON_OPAQUE flags and the 0xFE front-face polarity on the mask that drives the select, with negative tests - XCL_HW_RT_TRAVERSE is in semantic_pipeline_setting with an assertion; the cache-key test checks that graphics paths are unchanged and that compute entries with and without the flag both survive a disk round trip </details> <details><summary>How this was tested</summary> - Merged onto main `078358a0`, 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 `078358a0` and on this merge; presents per 2 s at the end: 60 60 60. - Title run: the release build of this merge launched the retail title with `XCL_RUN_SECONDS=300` and scripted A presses counted from the first frame (`XCL_PRESS_BASE=frame`, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
Kalmarv commented 2026-12-03 01:46:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-03T01:46:35Z.


Thanks for the merge-check, smoke run, and title run @Foniass!

On `PR description` is red: every pull_request_target workflow on xcl-dev/xcl (PR checks, Auto triage, Testing feed, Discord mirror) has been returning startup_failure repo-wide since ~22:47 UTC on 2026-12-02, so the PR description job never started on 1f287a928 (run 46994382194). Running main's scripts/pr_check.py --local against PR #3705's current description and file list for 1f287a928 passes (description ok), and Build and test (Windows, no GPU) is green (run 46994386313). Once pull_request_target recovers, I'll retrigger PR checks via a no-op description edit without changing 1f287a928.

On the technical review points:

  • #1 (recognizer equivalence): On loop_ray using tmin = 0: RDNA2's IMAGE_BVH64_INTERSECT_RAY takes 12 VADDR VGPRs (node_ptr, tmax, origin, dir, inv_dir) with no tmin operand — GPURT pre-offsets origin by tmin * dir and shrinks tmax before entering the loop, so t inside the loop always starts at 0. Agreed that visibility cull-flag checking, narrowing GLOBAL_ loads to node-pointer bases, and proving the translucent commit side are real limits (currently listed under Not tested) and good follow-ups once checked against live swapped shaders.
  • #2 (WARP execution test & if let Ok(dis)): Good catch on if let Ok(dis) — validate::validate right above already requires dxcompiler.dll, so .expect(...) avoids silently skipping the disassembly assertions. Agreed that a WARP execution test exercising the lowered swap (native hit/miss + wave fallback) is worth adding.
  • #3 (with_traverse_for_tests global atomic): Good catch — pso.rs already has file_for_with, and passing the traverse flag explicitly into compute translation in tests (instead of toggling the process-wide TRAVERSE_OVERRIDE) avoids any cross-test interference under --test-threads=4.
  • #5 / #6: Agreed — we'll re-verify the live XCL_HW_RT_TRAVERSE=1 path and drop the carried stack commits when rebasing after #3704 lands.
  • #7 (pso.rs comment): Good catch — hw_rt::traverse_enabled() caches only the env parse in OnceLock and reads config().raytracing_tier_override() dynamically, so the "process-constant" comment is stale.

Leaving 1f287a928 untouched for now so this merge-check and green CI aren't churned during the pull_request_target outage; happy to fold #2 (disassemble().expect(...) + WARP test), #3 (explicit test flag), and #7 (comment fix) in on the next push when rebasing onto #3704 (or sooner if you'd like them before merge).

Drafted with Antigravity (Gemini 4 Neon).

<!-- greyfinch-sync:ivall/xcl:comment:7364721170 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3705#issuecomment-7364721170). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-03T01:46:35Z. --- Thanks for the merge-check, smoke run, and title run @Foniass! On `` `PR description` is red ``: every `pull_request_target` workflow on `xcl-dev/xcl` (`PR checks`, `Auto triage`, `Testing feed`, `Discord mirror`) has been returning `startup_failure` repo-wide since ~22:47 UTC on 2026-12-02, so the `PR description` job never started on `1f287a928` (run `46994382194`). Running `main`'s `scripts/pr_check.py --local` against PR #3705's current description and file list for `1f287a928` passes (`description ok`), and `Build and test (Windows, no GPU)` is green (run `46994386313`). Once `pull_request_target` recovers, I'll retrigger `PR checks` via a no-op description edit without changing `1f287a928`. On the technical review points: - **#1 (recognizer equivalence):** On `loop_ray` using `tmin = 0`: RDNA2's `IMAGE_BVH64_INTERSECT_RAY` takes 12 `VADDR` VGPRs (`node_ptr`, `tmax`, `origin`, `dir`, `inv_dir`) with no `tmin` operand — GPURT pre-offsets `origin` by `tmin * dir` and shrinks `tmax` before entering the loop, so `t` inside the loop always starts at `0`. Agreed that visibility cull-flag checking, narrowing `GLOBAL_` loads to node-pointer bases, and proving the translucent commit side are real limits (currently listed under **Not tested**) and good follow-ups once checked against live swapped shaders. - **#2 (WARP execution test & `if let Ok(dis)`):** Good catch on `if let Ok(dis)` — `validate::validate` right above already requires `dxcompiler.dll`, so `.expect(...)` avoids silently skipping the disassembly assertions. Agreed that a WARP execution test exercising the lowered swap (native hit/miss + wave fallback) is worth adding. - **#3 (`with_traverse_for_tests` global atomic):** Good catch — `pso.rs` already has `file_for_with`, and passing the traverse flag explicitly into compute translation in tests (instead of toggling the process-wide `TRAVERSE_OVERRIDE`) avoids any cross-test interference under `--test-threads=4`. - **#5 / #6:** Agreed — we'll re-verify the live `XCL_HW_RT_TRAVERSE=1` path and drop the carried stack commits when rebasing after `#3704` lands. - **#7 (`pso.rs` comment):** Good catch — `hw_rt::traverse_enabled()` caches only the env parse in `OnceLock` and reads `config().raytracing_tier_override()` dynamically, so the "process-constant" comment is stale. Leaving `1f287a928` untouched for now so this merge-check and green CI aren't churned during the `pull_request_target` outage; happy to fold `#2` (`disassemble().expect(...)` + WARP test), `#3` (explicit test flag), and `#7` (comment fix) in on the next push when rebasing onto `#3704` (or sooner if you'd like them before merge). <sub>Drafted with Antigravity (Gemini 4 Neon).</sub>
Foniass commented 2026-12-03 15:32:53 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T15:32:53Z.


merge-check
base: 078358a058
head: 1f287a9283
merge: clean
build: ok
tests: 3038 passed, 0 failed, 52 ignored; 28 skipped, the same as on main
review: 6 medium, 1 nit (below)
performance: 60 s smoke run: 1669 → 1672 frames (100 % of main), peak commit 17577 → 16497 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 220 s there, 0 device removals, 0 crashes, 3.1 presents/s; run with XCL_SKIP_CS=95cc13288a27a96e (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)
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: Recognizes GPURT visibility and translucent closest-hit loops in non-compact compute programs and, with XCL_HW_RT_TRAVERSE=1, replaces each with a native RayQuery when every active lane's top level is in the table, else the wave runs the software walk; disk cache entries for compute get a _hwrt3 suffix. The default path is unchanged and the CFG wiring is right. The recognizers accept loops they can't prove equivalent, no test runs a swapped program, and the test override turns the feature on for every test running at the same time; nothing is critical, and all of it is opt-in.

Medium

  1. Recognizer accepts loops it does not prove equivalent. gpurt.rs: visibility_of (~434) does not check the console ray's cull flags, so the native first-hit query (no culling) can find back-face hits the console walk culls; GLOBAL_ loads are accepted as node fetches (~446/~532), so an alpha test reading through global loads would be skipped; loop_ray (~808) always traces from tmin 0 (probably fine if GPURT offsets the origin, not checked here); the translucent commit side is implied, not proven. Any mismatch gives wrong shadows or translucency with no runtime check. Check the cull bits like translucent_of's fold check, and reject GLOBAL_ loads not addressed from the node pointer.
  2. No test executes the lowered swap. The two gpurt tests check recognition, DXC validation and that the disassembly contains TraceRayInline and an fcmp oge. Nothing runs Lw::traversal_swap / translucent_swap output on WARP against the software walk (ray_query's WARP test runs a hand-written swap_kernel instead), so the wave fallback and the hit/t/front/committed/capped writes are untested at runtime. The if let Ok(dis) = validate::disassemble(..) (~996, ~1029) also skips the string checks silently if disassembly fails. A WARP A/B on the synthetic loops, using #3704's harness, would cover it.
  3. Test override flips the feature for the whole test binary. gpurt.rs tests wrap whole kernel::translate_compute calls, and pso.rs hw_rt_traverse_cache_key_is_compute_only wraps file_for, in with_traverse_for_tests(true, ..). The override is a process-wide atomic, and the lock only serializes callers of the helper, so other tests running at the same time get _hwrt3 file names, a different direct_output_identity, and the native table if they create the shared heap first. Could flake unrelated tests. Pass the flag explicitly (file_for_with already exists; same for translate) instead of flipping a global.
  4. Size over the limit, reason given. Own commit +1161/-6 (~870 production, ~290 tests). The description explains why it isn't split further.
  5. Opt-in path not run at this head. The 180 s XCL_HW_RT_TRAVERSE=1 runs were on 112374d19, before the cache-key change and the restack, and no counter shows a swapped dispatch tracing natively. KDenKC's main ray program (8994bb33) looks like a closest-hit loop that neither recognizer accepts. The smoke run covers only the default path.
  6. Carries #3704's stack. Same as #3704: a rebased copy of #3659 (70c8c51f3 vs 5bfb22746) and #3700's readable()+read_unaligned in read_archive_prims land with this PR.

Nit

  1. "Process-constant" comment is wrong. pso.rs ~413 says hw_rt::traverse_enabled() is process-constant (OnceLock), but since #3704 it reads config().raytracing_tier_override() on every call, so a call before the boot config loads can differ from later ones (in-RAM cache and file names would then disagree). Fix the comment, or cache the whole result once the config is loaded.
Checked and fine
  • Default path unchanged: swaps are built only when traverse_enabled() and plan.is_none(); with none, swap_preds is empty, to is head(), file_for adds no suffix and direct_output_identity is unchanged
  • CFG wiring: the swap block replaces only the entry-to-header edge, so the header's predecessor count stays the same and the exit gets one more (swap_preds)
  • native_top falls back for the whole wave when any active lane misses (ballot over both words, so wave64 too); lanes with tmax < tmin skip the trace
  • Visibility recognition requires exactly one live-out VGPR, read after the loop only by zero compares, and no stores, atomics, barriers or non-node loads in the loop; translucent recognition checks the folded FORCE_NON_OPAQUE flags and the 0xFE front-face polarity on the mask that drives the select, with negative tests
  • XCL_HW_RT_TRAVERSE is in semantic_pipeline_setting with an assertion; the cache-key test checks that graphics paths are unchanged and that compute entries with and without the flag both survive a disk round trip
How this was tested
  • Merged onto main 078358a0, 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 078358a0 and on this merge; presents per 2 s at the end: 60 60 60.
  • Title run: the release build of this merge launched the retail title with XCL_RUN_SECONDS=300 and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.

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

<!-- greyfinch-sync:ivall/xcl:comment:7383329714 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3705#issuecomment-7383329714). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T15:32:53Z. --- merge-check base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a head: 1f287a928352ac71dcb238a3a5d3d4dd4741c3e0 merge: clean build: ok tests: 3038 passed, 0 failed, 52 ignored; 28 skipped, the same as on main review: 6 medium, 1 nit (below) performance: 60 s smoke run: 1669 → 1672 frames (100 % of main), peak commit 17577 → 16497 MB, no device removal, no crash title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 220 s there, 0 device removals, 0 crashes, 3.1 presents/s; run with `XCL_SKIP_CS=95cc13288a27a96e` (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590) 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:** Recognizes GPURT visibility and translucent closest-hit loops in non-compact compute programs and, with XCL_HW_RT_TRAVERSE=1, replaces each with a native RayQuery when every active lane's top level is in the table, else the wave runs the software walk; disk cache entries for compute get a _hwrt3 suffix. The default path is unchanged and the CFG wiring is right. The recognizers accept loops they can't prove equivalent, no test runs a swapped program, and the test override turns the feature on for every test running at the same time; nothing is critical, and all of it is opt-in. #### Medium 1. **Recognizer accepts loops it does not prove equivalent.** gpurt.rs: visibility_of (~434) does not check the console ray's cull flags, so the native first-hit query (no culling) can find back-face hits the console walk culls; GLOBAL_ loads are accepted as node fetches (~446/~532), so an alpha test reading through global loads would be skipped; loop_ray (~808) always traces from tmin 0 (probably fine if GPURT offsets the origin, not checked here); the translucent commit side is implied, not proven. Any mismatch gives wrong shadows or translucency with no runtime check. Check the cull bits like translucent_of's fold check, and reject GLOBAL_ loads not addressed from the node pointer. 2. **No test executes the lowered swap.** The two gpurt tests check recognition, DXC validation and that the disassembly contains TraceRayInline and an fcmp oge. Nothing runs Lw::traversal_swap / translucent_swap output on WARP against the software walk (ray_query's WARP test runs a hand-written swap_kernel instead), so the wave fallback and the hit/t/front/committed/capped writes are untested at runtime. The `if let Ok(dis) = validate::disassemble(..)` (~996, ~1029) also skips the string checks silently if disassembly fails. A WARP A/B on the synthetic loops, using #3704's harness, would cover it. 3. **Test override flips the feature for the whole test binary.** gpurt.rs tests wrap whole kernel::translate_compute calls, and pso.rs hw_rt_traverse_cache_key_is_compute_only wraps file_for, in with_traverse_for_tests(true, ..). The override is a process-wide atomic, and the lock only serializes callers of the helper, so other tests running at the same time get _hwrt3 file names, a different direct_output_identity, and the native table if they create the shared heap first. Could flake unrelated tests. Pass the flag explicitly (file_for_with already exists; same for translate) instead of flipping a global. 4. **Size over the limit, reason given.** Own commit +1161/-6 (~870 production, ~290 tests). The description explains why it isn't split further. 5. **Opt-in path not run at this head.** The 180 s XCL_HW_RT_TRAVERSE=1 runs were on 112374d19, before the cache-key change and the restack, and no counter shows a swapped dispatch tracing natively. KDenKC's main ray program (8994bb33) looks like a closest-hit loop that neither recognizer accepts. The smoke run covers only the default path. 6. **Carries #3704's stack.** Same as #3704: a rebased copy of #3659 (70c8c51f3 vs 5bfb22746) and #3700's readable()+read_unaligned in read_archive_prims land with this PR. #### Nit 7. **"Process-constant" comment is wrong.** pso.rs ~413 says hw_rt::traverse_enabled() is process-constant (OnceLock), but since #3704 it reads config().raytracing_tier_override() on every call, so a call before the boot config loads can differ from later ones (in-RAM cache and file names would then disagree). Fix the comment, or cache the whole result once the config is loaded. <details><summary>Checked and fine</summary> - Default path unchanged: swaps are built only when traverse_enabled() and plan.is_none(); with none, swap_preds is empty, `to` is head(), file_for adds no suffix and direct_output_identity is unchanged - CFG wiring: the swap block replaces only the entry-to-header edge, so the header's predecessor count stays the same and the exit gets one more (swap_preds) - native_top falls back for the whole wave when any active lane misses (ballot over both words, so wave64 too); lanes with tmax < tmin skip the trace - Visibility recognition requires exactly one live-out VGPR, read after the loop only by zero compares, and no stores, atomics, barriers or non-node loads in the loop; translucent recognition checks the folded FORCE_NON_OPAQUE flags and the 0xFE front-face polarity on the mask that drives the select, with negative tests - XCL_HW_RT_TRAVERSE is in semantic_pipeline_setting with an assertion; the cache-key test checks that graphics paths are unchanged and that compute entries with and without the flag both survive a disk round trip </details> <details><summary>How this was tested</summary> - Merged onto main `078358a0`, 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 `078358a0` and on this merge; presents per 2 s at the end: 60 60 60. - Title run: the release build of this merge launched the retail title with `XCL_RUN_SECONDS=300` and scripted A presses counted from the first frame (`XCL_PRESS_BASE=frame`, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
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/3705:upstream-pr/3705'
git switch 'upstream-pr/3705'

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