fix(victory-gpu): align RT pass gating, avoid builder_runs stall in ambient, and add synthetic occluder test #472

Open
github-bot wants to merge 1 commit from github-bot/gh-472 into main AGit
Owner

@⁠mauroalvare on GitHub · 2026-11-27 01:04 UTC · original
mauroalvare:rt/passes/activation-and-gating → main · +1196 −51 · 5 files · 1 commits · open

Change

Fixes three issues along the ray-tracing pass activation and lighting-handoff path in third_party/victory/crates/victory-gpu, and adds a synthetic end-to-end D3D12 GPU test and timing harness with a movable occluder (no game files):

  1. Consistent RT pass gating (pipeline/make.rs):
    • Previously, setting VICTORY_RT_RESOLVE=1 without VICTORY_BVH_BUILDER=1 enabled CS_RaytracingResolve while still silently skipping CS_ScreenProbes_ActivateRays unless VICTORY_ACTIVATE_RAYS=1 was also set, leaving zero screen-probe rays activated.
    • Conversely, setting VICTORY_BVH_BUILDER=1 ignored an explicit VICTORY_RT_RESOLVE=0 (inconsistent with VICTORY_ACTIVATE_RAYS=0).
    • make::missing() now reports p.left_out instead of misreporting skipped RT pipelines as "being made".
  2. Eliminate synchronous builder-compilation stalls and early fallback glitches from ambient::on() / builder_runs() (pipeline.rs, ambient.rs):
    • Previously, ambient::on() and ambient::bounds() called pipeline::builder_runs() on every CS_CacheScreenSpaceRadiance, CS_ScreenProbes_TemporalResolve, and CS_AccumulateLocalLightInscatteringVolume dispatch.
    • Before any builder pipeline was registered, b.off == b.pipelines.len() (0 == 0) returned false, wrongly enabling the ambient stand-in on early RT frames.
    • Once builder pipelines existed with b.whole == false, calling ambient::on() on a lighting recording thread acquired the global BUILDER mutex and synchronously compiled all builder pipelines serially on that thread.
    • Added a lock-free non-blocking pipeline::builder_active() query for ambient, added lock-free atomic fast paths in builder_runs(), and updated builder_runs() to release the BUILDER mutex and enqueue missing builder pipelines in parallel across VICTORY_PIPELINE_WORKERS before joining.
  3. Synthetic movable-occluder GPU integration test & 1080p RT cost benchmark (rt_passes_tests.rs):
    • Runs ActivateRays -> indirect dispatch argument clamp -> ExecuteIndirect RayTrace against a movable box occluder -> Resolve into R9G9B9E5 (R32_UINT) on the host GPU.
    • Verifies shadowed/lit regions shift accurately when moving the occluder left -> right, and confirms that skipping ActivateRays leaves rays unlaunched and loses occlusion.

Verification

Tested locally on Windows x64 with NVIDIA GeForce RTX 5070 Ti (driver 621.40, Wave32, SM 6.6):

cargo test -p victory-gpu --lib rt_passes_tests::
  -> test rt_passes_tests::movable_occluder_changes_rt_lighting_output ... ok (1 passed; 1 ignored)
cargo test -p victory-gpu --lib pipeline::
  -> 28 passed; 0 failed; 1 ignored
cargo test -p victory-gpu --lib ambient::
  -> 4 passed; 0 failed
cargo test -p victory-gpu --features diagnostics --lib pipeline::make::
  -> 8 passed; 0 failed
cargo xtask policy
  -> asset policy: 290 files ok

Synthetic 1920x1080 RT Enable Cost (RTX 5070 Ti, hardware D3D12 timestamps, 2,073,600 rays/frame, 30 FPS budget = 33.333 ms)

cargo test -p victory-gpu --release --lib rt_passes_tests::rt_passes_frame_cost_bench -- --ignored --nocapture --test-threads=1
Mode Median Total GPU (ms) % of 33.3 ms (30 FPS) Per-Pass Breakdown (ms)
RT OFF (resolve only) 0.0187 0.06% resolve=0.0187
RT ON (Activate -> Clamp -> Indirect Trace -> Resolve) 0.3095 0.93% activate=0.2207, clamp=0.0020, trace=0.0689, resolve=0.0176
Delta (RT ON - RT OFF) +0.2908 +0.87% —

Oracle and test data

  • Synthetic HLSL compute passes and movable AABB occluder constructed in code inside rt_passes_tests.rs (no game files or assets).
  • Failure cases caught without this change:
    • pipeline::make::tests::rt_pass_left_out_policy_keeps_activation_and_resolve_consistent fails on LeftOutPolicy::from_values(false, Some("1"), None) and LeftOutPolicy::from_values(true, Some("0"), None).
    • pipeline::make::tests::missing_reports_left_out_reason_instead_of_being_made fails (returned "being made").
    • pipeline::tests::builder_active_follows_enable_and_failure_state and rt_passes_tests::movable_occluder_changes_rt_lighting_output verify both activation gating and producer-consumer lighting updates.

Checklist

  • The PR covers a single reviewable behaviour.
  • A test fails without this change and passes with it.
  • The commands and results of each check are given above.
  • An unimplemented function returns an error (E_NOTIMPL), never a fake success.
  • README: unchanged (test count did not cross a hundred).
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: limited to what rule 2 of AGENTS.md allows (shader names already present in pipeline/make.rs and ambient.rs).
  • Code taken from another project: none.

Made with AI assistance (Antigravity / Gemini).

**@⁠mauroalvare** on GitHub · 2026-11-27 01:04 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/472) `mauroalvare:rt/passes/activation-and-gating` → `main` · +1196 −51 · 5 files · 1 commits · open ## Change Fixes three issues along the ray-tracing pass activation and lighting-handoff path in `third_party/victory/crates/victory-gpu`, and adds a synthetic end-to-end D3D12 GPU test and timing harness with a movable occluder (no game files): 1. **Consistent RT pass gating (`pipeline/make.rs`):** - Previously, setting `VICTORY_RT_RESOLVE=1` without `VICTORY_BVH_BUILDER=1` enabled `CS_RaytracingResolve` while still silently skipping `CS_ScreenProbes_ActivateRays` unless `VICTORY_ACTIVATE_RAYS=1` was also set, leaving zero screen-probe rays activated. - Conversely, setting `VICTORY_BVH_BUILDER=1` ignored an explicit `VICTORY_RT_RESOLVE=0` (inconsistent with `VICTORY_ACTIVATE_RAYS=0`). - `make::missing()` now reports `p.left_out` instead of misreporting skipped RT pipelines as `"being made"`. 2. **Eliminate synchronous builder-compilation stalls and early fallback glitches from `ambient::on()` / `builder_runs()` (`pipeline.rs`, `ambient.rs`):** - Previously, `ambient::on()` and `ambient::bounds()` called `pipeline::builder_runs()` on every `CS_CacheScreenSpaceRadiance`, `CS_ScreenProbes_TemporalResolve`, and `CS_AccumulateLocalLightInscatteringVolume` dispatch. - Before any builder pipeline was registered, `b.off == b.pipelines.len()` (`0 == 0`) returned `false`, wrongly enabling the ambient stand-in on early RT frames. - Once builder pipelines existed with `b.whole == false`, calling `ambient::on()` on a lighting recording thread acquired the global `BUILDER` mutex and synchronously compiled all builder pipelines serially on that thread. - Added a lock-free non-blocking `pipeline::builder_active()` query for `ambient`, added lock-free atomic fast paths in `builder_runs()`, and updated `builder_runs()` to release the `BUILDER` mutex and enqueue missing builder pipelines in parallel across `VICTORY_PIPELINE_WORKERS` before joining. 3. **Synthetic movable-occluder GPU integration test & 1080p RT cost benchmark (`rt_passes_tests.rs`):** - Runs `ActivateRays` -> indirect dispatch argument clamp -> `ExecuteIndirect` `RayTrace` against a movable box occluder -> `Resolve` into `R9G9B9E5` (`R32_UINT`) on the host GPU. - Verifies shadowed/lit regions shift accurately when moving the occluder left -> right, and confirms that skipping `ActivateRays` leaves rays unlaunched and loses occlusion. ## Verification Tested locally on Windows x64 with **NVIDIA GeForce RTX 5070 Ti** (driver 621.40, Wave32, SM 6.6): ``` cargo test -p victory-gpu --lib rt_passes_tests:: -> test rt_passes_tests::movable_occluder_changes_rt_lighting_output ... ok (1 passed; 1 ignored) cargo test -p victory-gpu --lib pipeline:: -> 28 passed; 0 failed; 1 ignored cargo test -p victory-gpu --lib ambient:: -> 4 passed; 0 failed cargo test -p victory-gpu --features diagnostics --lib pipeline::make:: -> 8 passed; 0 failed cargo xtask policy -> asset policy: 290 files ok ``` ### Synthetic 1920x1080 RT Enable Cost (RTX 5070 Ti, hardware D3D12 timestamps, 2,073,600 rays/frame, 30 FPS budget = 33.333 ms) ``` cargo test -p victory-gpu --release --lib rt_passes_tests::rt_passes_frame_cost_bench -- --ignored --nocapture --test-threads=1 ``` | Mode | Median Total GPU (ms) | % of 33.3 ms (30 FPS) | Per-Pass Breakdown (ms) | | --- | ---: | ---: | --- | | RT OFF (resolve only) | 0.0187 | 0.06% | resolve=0.0187 | | RT ON (Activate -> Clamp -> Indirect Trace -> Resolve) | 0.3095 | 0.93% | activate=0.2207, clamp=0.0020, trace=0.0689, resolve=0.0176 | | **Delta (RT ON - RT OFF)** | **+0.2908** | **+0.87%** | — | ## Oracle and test data - Synthetic HLSL compute passes and movable AABB occluder constructed in code inside `rt_passes_tests.rs` (no game files or assets). - Failure cases caught without this change: - `pipeline::make::tests::rt_pass_left_out_policy_keeps_activation_and_resolve_consistent` fails on `LeftOutPolicy::from_values(false, Some("1"), None)` and `LeftOutPolicy::from_values(true, Some("0"), None)`. - `pipeline::make::tests::missing_reports_left_out_reason_instead_of_being_made` fails (returned `"being made"`). - `pipeline::tests::builder_active_follows_enable_and_failure_state` and `rt_passes_tests::movable_occluder_changes_rt_lighting_output` verify both activation gating and producer-consumer lighting updates. ## Checklist - [x] The PR covers a single reviewable behaviour. - [x] A test fails without this change and passes with it. - [x] The commands and results of each check are given above. - [x] An unimplemented function returns an error (`E_NOTIMPL`), never a fake success. - [x] README: unchanged (test count did not cross a hundred). - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: limited to what rule 2 of `AGENTS.md` allows (shader names already present in `pipeline/make.rs` and `ambient.rs`). - [x] Code taken from another project: none. Made with AI assistance (Antigravity / Gemini).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:26:04 +00:00
Author
Owner

@⁠mauroalvare on GitHub · 2026-11-27 01:19 UTC · original

Independently verified a40ed684341fbd2cc6d27c171af9ae27bbc56018 on the RTX 5070 Ti, driver 621.40, release. pipeline::make:: passed 7 tests, ambient:: passed 4, and movable_occluder_changes_rt_lighting_output passed. The published benchmark gave 0.0187 ms RT off and 0.2675 ms RT on at the GPU median.

I saved this as the first functional synthetic pass baseline. Using the same HLSL fixture with timing and readback instrumentation, both modes used the same alternating occluder placements at 1920×1080 and 2,073,600 rays. Each mode had 24 warmups and 120 measured frames. Outputs were read in separate verification frames.

RTX 5070 Ti RT off p50 / p95 (ms) RT on p50 / p95 (ms)
Frame 0.116 / 0.367 0.388 / 0.846
GPU total 0.0156 / 0.0175 0.2827 / 0.4775
CPU fence wait 0.066 / 0.313 0.341 / 0.780

The RT-on GPU medians were 0.2124 ms activation, 0.0023 ms clamp, 0.0557 ms tracing and 0.0114 ms resolve. Sampled process-local DXGI peak was 102.7 MiB and CPU peak working set was 83.8 MiB.

The lit and shadowed samples switched from 0.1001 / 2.1016 to 2.1016 / 0.1001 when the occluder moved. Full RT-on output BLAKE3 was 22f8beb01be67227ed63aff7f42ac8a55abc5d741151534fb94cd05c1746fff3 for the left occluder and 50b0cb322893fb71d3e3fd9647dcb2e6720de76cd7e647dcd384a5ea85dab9ec for the right.

cargo test --manifest-path third_party/victory/Cargo.toml --offline --locked --release -p victory-gpu --lib rt_passes_tests::movable_occluder_changes_rt_lighting_output -- --exact --nocapture --test-threads=1
cargo test --manifest-path third_party/victory/Cargo.toml --offline --locked --release -p victory-gpu --lib rt_passes_tests::rt_passes_frame_cost_bench -- --exact --ignored --nocapture --test-threads=1

The local shared registry holds pr472-percentiles.patch and the per-frame pr472-functional-baseline log. After applying that test-only patch to this SHA, the corresponding filter is rt_passes_tests::rt_passes_validation_baseline with --exact --ignored --nocapture --test-threads=1.

**@⁠mauroalvare** on GitHub · 2026-11-27 01:19 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/472#issuecomment-7207192272) Independently verified `a40ed684341fbd2cc6d27c171af9ae27bbc56018` on the RTX 5070 Ti, driver 621.40, release. `pipeline::make::` passed 7 tests, `ambient::` passed 4, and `movable_occluder_changes_rt_lighting_output` passed. The published benchmark gave 0.0187 ms RT off and 0.2675 ms RT on at the GPU median. I saved this as the first functional synthetic pass baseline. Using the same HLSL fixture with timing and readback instrumentation, both modes used the same alternating occluder placements at 1920×1080 and 2,073,600 rays. Each mode had 24 warmups and 120 measured frames. Outputs were read in separate verification frames. | RTX 5070 Ti | RT off p50 / p95 (ms) | RT on p50 / p95 (ms) | | --- | ---: | ---: | | Frame | 0.116 / 0.367 | 0.388 / 0.846 | | GPU total | 0.0156 / 0.0175 | 0.2827 / 0.4775 | | CPU fence wait | 0.066 / 0.313 | 0.341 / 0.780 | The RT-on GPU medians were 0.2124 ms activation, 0.0023 ms clamp, 0.0557 ms tracing and 0.0114 ms resolve. Sampled process-local DXGI peak was 102.7 MiB and CPU peak working set was 83.8 MiB. The lit and shadowed samples switched from 0.1001 / 2.1016 to 2.1016 / 0.1001 when the occluder moved. Full RT-on output BLAKE3 was `22f8beb01be67227ed63aff7f42ac8a55abc5d741151534fb94cd05c1746fff3` for the left occluder and `50b0cb322893fb71d3e3fd9647dcb2e6720de76cd7e647dcd384a5ea85dab9ec` for the right. ```powershell cargo test --manifest-path third_party/victory/Cargo.toml --offline --locked --release -p victory-gpu --lib rt_passes_tests::movable_occluder_changes_rt_lighting_output -- --exact --nocapture --test-threads=1 cargo test --manifest-path third_party/victory/Cargo.toml --offline --locked --release -p victory-gpu --lib rt_passes_tests::rt_passes_frame_cost_bench -- --exact --ignored --nocapture --test-threads=1 ``` The local shared registry holds `pr472-percentiles.patch` and the per-frame `pr472-functional-baseline` log. After applying that test-only patch to this SHA, the corresponding filter is `rt_passes_tests::rt_passes_validation_baseline` with `--exact --ignored --nocapture --test-threads=1`.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/472/head:github-bot/gh-472'
git switch 'github-bot/gh-472'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-472'
git switch 'github-bot/gh-472'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-472'
git switch 'github-bot/gh-472'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-472'
git switch 'main'
git merge --squash 'github-bot/gh-472'
git switch 'main'
git merge --ff-only 'github-bot/gh-472'
git switch 'main'
git merge 'github-bot/gh-472'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.