Recompiler: bound a shadow traversal with native RayQuery #2179

Open
rison1337 wants to merge 7 commits from upstream-pr/2189 into main
rison1337 commented 2026-11-25 08:17:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by rison1337 on 2026-11-25T08:17:19Z.


Stacked on #2085 and the preceding native-AS preparation branches. Immediate predecessor: feat/shadow-traversal-matcher (190885bb24ee). Only commit 24206a657b11 belongs to this PR; earlier commits are dependencies.

Connect one verified shadow traversal region to an opt-in native RayQuery upper bound for #1751. A compatible TLAS is bound directly at t0/space2. The original traversal still checks nearer intersections, including t=0, before the native endpoint is merged. No retail FPS benefit is established.

What is in it

  • Gate the HLSL rewrite to one known record and preserve the original path for unavailable/incompatible inputs.
  • Use a root SRV rather than descriptor-heap AS lookup; keep the opt-in translation out of legacy variant caches.
  • GPU differential coverage: four scenes × seven scenarios × 64 lanes, including zero-distance, strict TMax, masked EXEC, NaN and address mismatch. Counters record 640 hardware queries.

Tested

  • Ryzen 5 7500F, RTX 4060 8 GB, NVIDIA 615.78.08, CachyOS Linux, Rust 1.99.1; Windows x86_64-pc-windows-gnullvm cross-build, debug tests and release runtime. Executed under Proton Experimental, with DXC 1.9.2609.5 and the local vkd3d-proton compatibility build.
  • Complete library executable on this head, cross-built with cargo test --locked --target x86_64-pc-windows-gnullvm -p xcl --lib --no-run, then run through the local Proton runner with --test-threads=4: 1104 passed, 2 failed, 26 ignored; 24 explicit SKIPPED messages. XCL_HOST_RAYQUERY=1; the private shader sample was available through XCL_SAMPLE_RAYQUERY. No title bytes are committed.
  • Fresh main (568e7db7729c), same runner and hardware: 1096 passed, 2 failed, 26 ignored; 24 explicit SKIPPED messages. Both fail the same existing depth-state negative check (gpu_depth_buffer_created_for_unordered_access_is_placed) and XMA voice check (xma2_source_voice_decodes_and_manages_lifetime). Skips include unavailable hardware wave64 and Windows Developer Mode.
  • Final stack 24206a657b11: cargo build --locked --target x86_64-pc-windows-gnullvm --workspace and cargo test --locked --target x86_64-pc-windows-gnullvm --workspace --no-run passed after adapting the four integration-test accesses to the shared-DXIL Arc API in #2085.

Regression run

The repository's unchanged scripts/smoke.ps1 generated these blocks, using PowerShell 7.7.0 on Linux and a shell wrapper that executes the EXE through Proton. Z: is mapped for reading the Windows log path. Both clean-source runs use the same title/profile copy, 90 s, XCL_PSO_PRELOAD=0, no automatic input, and a separate Xwayland surface on a background workspace. The PR's opt-in flag is enabled where available. Coverage is startup/start screen/menu, not world loading or native traversal execution.

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 4060
title: 6ca5cab7
seconds: 90
exit: 0x0
frames shown: 1828 (PresentX 1828)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB
xcl-smoke v1
commit: 24206a657b11ccde6884a3a6cb3bb7a262d18075
gpu: NVIDIA GeForce RTX 4060
title: 6ca5cab7
seconds: 90
exit: 0x0
frames shown: 1874 (PresentX 1874)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

Both runs exited without recorded crashes or device removals. Wine prints 0 MB for process commit, so the memory-growth comparison is not established by this counter. The existing queue-drain warning may be present at timer shutdown.

Not tested

  • Native Windows, AMD and hardware wave64.
  • A green complete workspace GPU-suite run. The library failures reproduced on main are listed above; integration execution under Wine is reported separately below. Passing cases with SKIPPED output do not establish GPU coverage.
  • World loading, gameplay performance, arbitrary title geometry and cross-list/cross-queue publication. Earlier exploratory world loads hit OOM; the native consumer has not been confirmed executing in a title.
  • On final stack 24206a657b11, all 19 non-library workspace executables were attempted under Proton. e2e, pls_quota, gpu_compute_e2e and predication_e2e fail on both main and head. The resource/sync executable aborts with four test threads on both (main: access violation; head: division by zero), so no aggregate pass is claimed.
  • Resource/sync recheck with one test thread: main: test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.41s; final stack: test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.01s. The parallel failure cause is unresolved.
  • Integration with the HLSL helper changes in #1901 the sparse-window changes in #2090 and the scheduling changes in #2118; #1901 overlaps the emitter and #2090 overlaps README.

AI use

Codex (GPT-6 family; exact variant unavailable in this session) prepared the implementation, split the commits, cross-built the binaries, ran the listed Linux/Proton checks and drafted this description. No game data or console SDK headers are included.

<!-- greyfinch-sync:ivall/xcl:issue:5487673485 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2189). Originally posted by [rison1337](https://github.com/rison1337) on 2026-11-25T08:17:19Z. --- Stacked on #2085 and the preceding native-AS preparation branches. Immediate predecessor: [`feat/shadow-traversal-matcher`](https://github.com/rison1337/xcl/tree/feat/shadow-traversal-matcher) (`190885bb24ee`). Only commit [`24206a657b11`](https://github.com/rison1337/xcl/commit/24206a657b11ccde6884a3a6cb3bb7a262d18075) belongs to this PR; earlier commits are dependencies. Connect one verified shadow traversal region to an opt-in native RayQuery upper bound for #1751. A compatible TLAS is bound directly at t0/space2. The original traversal still checks nearer intersections, including t=0, before the native endpoint is merged. No retail FPS benefit is established. **What is in it** - Gate the HLSL rewrite to one known record and preserve the original path for unavailable/incompatible inputs. - Use a root SRV rather than descriptor-heap AS lookup; keep the opt-in translation out of legacy variant caches. - GPU differential coverage: four scenes × seven scenarios × 64 lanes, including zero-distance, strict TMax, masked EXEC, NaN and address mismatch. Counters record 640 hardware queries. **Tested** - Ryzen 5 7500F, RTX 4060 8 GB, NVIDIA 615.78.08, CachyOS Linux, Rust 1.99.1; Windows `x86_64-pc-windows-gnullvm` cross-build, debug tests and release runtime. Executed under Proton Experimental, with DXC 1.9.2609.5 and the local vkd3d-proton compatibility build. - Complete library executable on this head, cross-built with `cargo test --locked --target x86_64-pc-windows-gnullvm -p xcl --lib --no-run`, then run through the local Proton runner with `--test-threads=4`: **1104 passed, 2 failed, 26 ignored; 24 explicit SKIPPED messages**. `XCL_HOST_RAYQUERY=1`; the private shader sample was available through `XCL_SAMPLE_RAYQUERY`. No title bytes are committed. - Fresh `main` (`568e7db7729c`), same runner and hardware: **1096 passed, 2 failed, 26 ignored; 24 explicit SKIPPED messages**. Both fail the same existing depth-state negative check (`gpu_depth_buffer_created_for_unordered_access_is_placed`) and XMA voice check (`xma2_source_voice_decodes_and_manages_lifetime`). Skips include unavailable hardware wave64 and Windows Developer Mode. - Final stack `24206a657b11`: `cargo build --locked --target x86_64-pc-windows-gnullvm --workspace` and `cargo test --locked --target x86_64-pc-windows-gnullvm --workspace --no-run` passed after adapting the four integration-test accesses to the shared-DXIL `Arc` API in #2085. **Regression run** The repository's unchanged `scripts/smoke.ps1` generated these blocks, using PowerShell 7.7.0 on Linux and a shell wrapper that executes the EXE through Proton. `Z:` is mapped for reading the Windows log path. Both clean-source runs use the same title/profile copy, 90 s, `XCL_PSO_PRELOAD=0`, no automatic input, and a separate Xwayland surface on a background workspace. The PR's opt-in flag is enabled where available. Coverage is startup/start screen/menu, not world loading or native traversal execution. ``` xcl-smoke v1 commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb gpu: NVIDIA GeForce RTX 4060 title: 6ca5cab7 seconds: 90 exit: 0x0 frames shown: 1828 (PresentX 1828) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 0 MB ``` ``` xcl-smoke v1 commit: 24206a657b11ccde6884a3a6cb3bb7a262d18075 gpu: NVIDIA GeForce RTX 4060 title: 6ca5cab7 seconds: 90 exit: 0x0 frames shown: 1874 (PresentX 1874) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 0 MB ``` Both runs exited without recorded crashes or device removals. Wine prints 0 MB for process commit, so the memory-growth comparison is not established by this counter. The existing queue-drain warning may be present at timer shutdown. **Not tested** - Native Windows, AMD and hardware wave64. - A green complete workspace GPU-suite run. The library failures reproduced on main are listed above; integration execution under Wine is reported separately below. Passing cases with SKIPPED output do not establish GPU coverage. - World loading, gameplay performance, arbitrary title geometry and cross-list/cross-queue publication. Earlier exploratory world loads hit OOM; the native consumer has not been confirmed executing in a title. - On final stack `24206a657b11`, all 19 non-library workspace executables were attempted under Proton. `e2e`, `pls_quota`, `gpu_compute_e2e` and `predication_e2e` fail on both main and head. The resource/sync executable aborts with four test threads on both (main: access violation; head: division by zero), so no aggregate pass is claimed. - Resource/sync recheck with one test thread: main: test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.41s; final stack: test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.01s. The parallel failure cause is unresolved. - Integration with the HLSL helper changes in #1901 the sparse-window changes in #2090 and the scheduling changes in #2118; #1901 overlaps the emitter and #2090 overlaps README. **AI use** Codex (GPT-6 family; exact variant unavailable in this session) prepared the implementation, split the commits, cross-built the binaries, ran the listed Linux/Proton checks and drafted this description. No game data or console SDK headers are included.
ertugrul-tug commented 2026-11-25 09:08:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ertugrul-tug on 2026-11-25T08:28:41Z.

Review: APPROVED


No description provided.

<!-- greyfinch-sync:ivall/xcl:review:6054133849 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2189#pullrequestreview-6054133849). Originally posted by [ertugrul-tug](https://github.com/ertugrul-tug) on 2026-11-25T08:28:41Z. **Review:** APPROVED --- _No description provided._
DarkPanda69 commented 2026-11-25 09:08:16 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-25T08:34:45Z.


Native Windows run on AMD (native wave64) and NVIDIA, which the stack lists as untested. I applied this PR's diff against main, so it includes the lower native-AS branches it is stacked on (#2184–#2188 as of their current heads).

Head 24206a6 applied on main 568e7db, debug, Windows 11 Pro 26200, XCL_ADAPTER set to each card:

  • RX 9070 XT (RDNA4, driver 32.0.32029.2010, waves 32..64):
    • cargo test -p xcl --lib -- host_bvh rayquery: 7 passed, 0 failed. gpu_shadow_dxr_builds_and_clones_blas_then_traces_a_tlas ran and passed; gpu_retail_shadow_region_matches_console_scene SKIPPED (no XCL_SAMPLE_RAYQUERY).
    • cargo test -p xcl --lib -- gpu::: 586 passed, 2 failed, 22 ignored. The 2 failures are the AMD fuzz seeds 722 and 1599 tracked in #2115, which fail the same way on main.
    • cargo test -p xcl --test console_shaders: 3 passed, 0 failed, 4 ignored, no skips.
  • RTX 3060 (driver 32.0.16.1088, waves 32 only): same 7 passed / 1 SKIPPED for host_bvh rayquery; gpu:: 588 passed, 0 failed, 22 ignored; console_shaders 3 passed, 4 ignored.

Not tested: the retail shadow region (no sample), XCL_SAMPLE_*, a title, release build.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

<!-- greyfinch-sync:ivall/xcl:comment:7157211517 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2189#issuecomment-7157211517). Originally posted by [DarkPanda69](https://github.com/DarkPanda69) on 2026-11-25T08:34:45Z. --- Native Windows run on AMD (native wave64) and NVIDIA, which the stack lists as untested. I applied this PR's diff against `main`, so it includes the lower native-AS branches it is stacked on (#2184–#2188 as of their current heads). Head `24206a6` applied on `main` `568e7db`, debug, Windows 11 Pro 26200, `XCL_ADAPTER` set to each card: - **RX 9070 XT** (RDNA4, driver 32.0.32029.2010, waves 32..64): - `cargo test -p xcl --lib -- host_bvh rayquery`: 7 passed, 0 failed. `gpu_shadow_dxr_builds_and_clones_blas_then_traces_a_tlas` ran and passed; `gpu_retail_shadow_region_matches_console_scene` SKIPPED (no `XCL_SAMPLE_RAYQUERY`). - `cargo test -p xcl --lib -- gpu::`: 586 passed, 2 failed, 22 ignored. The 2 failures are the AMD fuzz seeds 722 and 1599 tracked in #2115, which fail the same way on `main`. - `cargo test -p xcl --test console_shaders`: 3 passed, 0 failed, 4 ignored, no skips. - **RTX 3060** (driver 32.0.16.1088, waves 32 only): same 7 passed / 1 SKIPPED for `host_bvh rayquery`; `gpu::` 588 passed, 0 failed, 22 ignored; `console_shaders` 3 passed, 4 ignored. Not tested: the retail shadow region (no sample), `XCL_SAMPLE_*`, a title, release build. AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
luckyteagirl commented 2026-11-25 10:10:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-25T09:19:48Z.


Independent native Windows RX 6800M check of the exact stacked head 24206a657b11ccde6884a3a6cb3bb7a262d18075. The final worktree is clean.

Environment: Windows 11 build 26200; Ryzen 9 5980HX; Radeon RX 6800M, driver 30.0.13002.13003; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5. Tests used XCL_ADAPTER=6800M, XCL_REQUIRE_GPU=wave64, and XCL_HOST_RAYQUERY=1 unless stated otherwise.

Host BVH fixture without the private sample: hle::d3d12x::host_bvh::tests passed 6/0/0, with no skip. The hardware test identified the RX 6800M, built and cloned a shadow BLAS, traced a TLAS, and reported that its hit distance and miss matched the console BVH fixture. The final clean-head rerun passed. This exercises the host DXR setup and synthetic scene; without the sample it does not execute the new retail native-query differential.

Owned retail record, local only: I extracted the exact record selected by the test (FNV-1a 9d51ce32ab9a9ab5) from my own title copy into a local XCL_SAMPLE_RAYQUERY file; no title or shader bytes are included here. gpu_retail_shadow_region_matches_console_scene passed 1/0/0 on the final clean head, with no skip. The full retail shader including RayQuery compiled to 89,932 B DXIL; the test identified live vector outputs [28, 31] and its original shadow region produced the expected four lane results on the RX 6800M. This test runs the original region, not the new native-query replacement.

Native-query differential limitation: With that sample supplied to the host BVH GPU fixture, the test process exited with Windows access violation 0xc0000005; it did not reach a test result. Temporary local diagnostics showed both original and native variants compiled (22,412 B and 23,980 B DXIL) and both compute pipelines were created. The first case crashed at SetComputeRootSignature, before either pipeline dispatched. It reproduced with XCL_HOST_RAYQUERY=1 and with the flag unset, using the helper's other root-signature path. I removed all diagnostic edits and verified the clean PR head. The fault's cause is unresolved, so this run does not establish native-query GPU output parity or title performance on AMD.

AI use: OpenAI Codex prepared the local record extraction and temporary diagnostics, ran the listed native Windows tests, restored the exact PR head, and drafted this report. No game data or console SDK headers were posted.

<!-- greyfinch-sync:ivall/xcl:comment:7158184627 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2189#issuecomment-7158184627). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-25T09:19:48Z. --- Independent native Windows RX 6800M check of the exact stacked head `24206a657b11ccde6884a3a6cb3bb7a262d18075`. The final worktree is clean. **Environment:** Windows 11 build 26200; Ryzen 9 5980HX; Radeon RX 6800M, driver `30.0.13002.13003`; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5. Tests used `XCL_ADAPTER=6800M`, `XCL_REQUIRE_GPU=wave64`, and `XCL_HOST_RAYQUERY=1` unless stated otherwise. **Host BVH fixture without the private sample:** `hle::d3d12x::host_bvh::tests` passed **6/0/0**, with no skip. The hardware test identified the RX 6800M, built and cloned a shadow BLAS, traced a TLAS, and reported that its hit distance and miss matched the console BVH fixture. The final clean-head rerun passed. This exercises the host DXR setup and synthetic scene; without the sample it does not execute the new retail native-query differential. **Owned retail record, local only:** I extracted the exact record selected by the test (FNV-1a `9d51ce32ab9a9ab5`) from my own title copy into a local `XCL_SAMPLE_RAYQUERY` file; no title or shader bytes are included here. `gpu_retail_shadow_region_matches_console_scene` passed **1/0/0** on the final clean head, with no skip. The full retail shader including RayQuery compiled to **89,932 B DXIL**; the test identified live vector outputs `[28, 31]` and its original shadow region produced the expected four lane results on the RX 6800M. This test runs the original region, not the new native-query replacement. **Native-query differential limitation:** With that sample supplied to the host BVH GPU fixture, the test process exited with Windows access violation `0xc0000005`; it did not reach a test result. Temporary local diagnostics showed both original and native variants compiled (22,412 B and 23,980 B DXIL) and both compute pipelines were created. The first case crashed at `SetComputeRootSignature`, before either pipeline dispatched. It reproduced with `XCL_HOST_RAYQUERY=1` and with the flag unset, using the helper's other root-signature path. I removed all diagnostic edits and verified the clean PR head. The fault's cause is unresolved, so this run does **not** establish native-query GPU output parity or title performance on AMD. AI use: OpenAI Codex prepared the local record extraction and temporary diagnostics, ran the listed native Windows tests, restored the exact PR head, and drafted this report. No game data or console SDK headers were posted.
github-actions[bot] commented 2026-11-29 07:41:16 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T07:41:16Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7252627724 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2189#issuecomment-7252627724). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T07:41:16Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 07:33:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:33:36Z.


Triage (#1607) – head 24206a6

Stacked PR: only 24206a6 belongs here; it sits on #2188 (and #2184-#2187, #2085). #2085 was closed as a duplicate of #2767, so the stack needs a rebase. The overlap with the other rison1337 PRs comes from the stack.
On rebase: recomp/mod.rs adds IO_HOST_AS_LO/HI/MAGIC = 113/114/115, but main now uses those io slots for IO_LOOP_BUDGET (113), IO_GROUP_LIMIT (114) and IO_THREAD_LIMIT[0] (115). The new slots and the hard-coded io.Load(452/456/460) in rayquery::LOOKUP must move to free slots, or bind_abi will overwrite the loop budget and group limit.
No other open or merged PR makes this change.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7304203943 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2189#issuecomment-7304203943). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T07:33:36Z. --- **Triage (#1607)** – head 24206a6 Stacked PR: only 24206a6 belongs here; it sits on #2188 (and #2184-#2187, #2085). #2085 was closed as a duplicate of #2767, so the stack needs a rebase. The overlap with the other rison1337 PRs comes from the stack. On rebase: recomp/mod.rs adds IO_HOST_AS_LO/HI/MAGIC = 113/114/115, but main now uses those io slots for IO_LOOP_BUDGET (113), IO_GROUP_LIMIT (114) and IO_THREAD_LIMIT[0] (115). The new slots and the hard-coded io.Load(452/456/460) in rayquery::LOOKUP must move to free slots, or bind_abi will overwrite the loop budget and group limit. No other open or merged PR makes this change. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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/2189:upstream-pr/2189'
git switch 'upstream-pr/2189'

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