GPU: add Series S second-plane composition and opt-in screen-probe ambient fallback #3414

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

@⁠legayclightning22 on GitHub · 2026-11-26 23:18 UTC · original
legayclightning22:feat/second-plane-compose-and-ambient-fallback → main · +1128 −16 · 9 files · 1 commits · open

Ports B10 and B11: opt-in compute composition for the Series S second plane (VICTORY_COMPOSE, VICTORY_PLANE_PREMULTIPLIED) and an off-by-default screen-probe ambient fallback (VICTORY_AMBIENT and tint/shade/sky/file settings), with unit tests for plane dispatch setup and env parsing.

**@⁠legayclightning22** on GitHub · 2026-11-26 23:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/3414) `legayclightning22:feat/second-plane-compose-and-ambient-fallback` → `main` · +1128 −16 · 9 files · 1 commits · open Ports B10 and B11: opt-in compute composition for the Series S second plane (VICTORY_COMPOSE, VICTORY_PLANE_PREMULTIPLIED) and an off-by-default screen-probe ambient fallback (VICTORY_AMBIENT and tint/shade/sky/file settings), with unit tests for plane dispatch setup and env parsing.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:07:01 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 23:27 UTC · original · approved these changes

LGTM — verified on RTX 5090 (Windows / D3D12) against origin/main (63bcca4).

  • Opt-in Series S second-plane composition and screen-probe ambient fallback remain off by default and pass all unit and GPU draw tests cleanly.
  • cargo test -p victory-gpu --lib ambient:: -- --test-threads=1: 2 passed, 0 failed.
  • cargo test -p victory-gpu --lib compose:: -- --test-threads=1: 2 passed, 0 failed.
  • cargo test -p victory-gpu --lib draw:: -- --test-threads=1: 20 passed, 0 failed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 193 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 23:27 UTC · [original](https://github.com/Marvisak/VIctory/pull/3414#pullrequestreview-6081455695) · **approved these changes** LGTM — verified on RTX 5090 (Windows / D3D12) against `origin/main` (`63bcca4`). - Opt-in Series S second-plane composition and screen-probe ambient fallback remain off by default and pass all unit and GPU draw tests cleanly. - `cargo test -p victory-gpu --lib ambient:: -- --test-threads=1`: 2 passed, 0 failed. - `cargo test -p victory-gpu --lib compose:: -- --test-threads=1`: 2 passed, 0 failed. - `cargo test -p victory-gpu --lib draw:: -- --test-threads=1`: 20 passed, 0 failed. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 193 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠Jackster on GitHub · 2026-11-26 23:46 UTC · original

Windows 11, 63bcca4 + this PR, Radeon RX 7900 XTX:

  • cargo test -p victory-gpu --lib: 235 passed / 0 failed / 1 ignored (unpatched 63bcca4 here: 231 passed; +4).
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.

The added tests are ambient_gate_is_off_unless_set, ambient_tint_sky_and_shade_settings_parse, plane_composition_setup_is_straight_or_premultiplied and plane_gates_are_off_unless_one; all pass, and the existing draw/placed-UAV tests are unchanged. The screen-probe fallback and the Series S plane composition are both opt-in, so nothing changes for a run with the gates off. Synthetic only. AI-assisted.

**@⁠Jackster** on GitHub · 2026-11-26 23:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/3414#issuecomment-7205847544) Windows 11, `63bcca4` + this PR, Radeon RX 7900 XTX: - `cargo test -p victory-gpu --lib`: 235 passed / 0 failed / 1 ignored (unpatched `63bcca4` here: 231 passed; +4). - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. The added tests are `ambient_gate_is_off_unless_set`, `ambient_tint_sky_and_shade_settings_parse`, `plane_composition_setup_is_straight_or_premultiplied` and `plane_gates_are_off_unless_one`; all pass, and the existing draw/placed-UAV tests are unchanged. The screen-probe fallback and the Series S plane composition are both opt-in, so nothing changes for a run with the gates off. Synthetic only. AI-assisted.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-27 00:05 UTC · original

At ed1d879, present_with_compositor invokes the compute pass before it moves the primary texture to copy-source. The pass still declares that transition's starting state as COPY_SOURCE. The new fixture records an input in RENDER_TARGET and replays the barriers before submitting. On the exact PR, the primary's first barrier declares 0x800 while its actual state is 0x4.

Follow-up 5d3b298 passes the primary's incoming state into the compute pass and restores both inputs. When both planes refer to the same texture, it transitions that texture once in each direction. The copy and diagnostics use the selected output.

On app-local WARP, the 9×7 readback passed twice in each alpha mode. All 63 texels matched the filtered 2×1 overlay within one UNORM8 unit. All 63 texels also matched exactly when both planes used the same input. Strict GPU Clippy in both configurations and asset policy passed. The full suite hit the known frame timer assertion in the unchanged frame.rs. With that test excluded, it passed 250 with one ignored.

@⁠legayclightning22, could you take the state fix and repeat the opt-in Series S present path? If you fold it in, please retain the Git author or use Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-27 00:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/3414#issuecomment-7206166832) At `ed1d879`, `present_with_compositor` invokes the compute pass before it moves the primary texture to copy-source. The pass still declares that transition's starting state as `COPY_SOURCE`. The new fixture records an input in `RENDER_TARGET` and replays the barriers before submitting. On the exact PR, the primary's first barrier declares `0x800` while its actual state is `0x4`. [Follow-up `5d3b298`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/5d3b298259196b8329157b1256e8e133170c8c11) passes the primary's incoming state into the compute pass and restores both inputs. When both planes refer to the same texture, it transitions that texture once in each direction. The copy and diagnostics use the selected output. On app-local WARP, the 9×7 readback passed twice in each alpha mode. All 63 texels matched the filtered 2×1 overlay within one UNORM8 unit. All 63 texels also matched exactly when both planes used the same input. Strict GPU Clippy in both configurations and asset policy passed. The full suite hit the known frame timer assertion in the unchanged `frame.rs`. With that test excluded, it passed 250 with one ignored. @⁠legayclightning22, could you take the state fix and repeat the opt-in Series S present path? If you fold it in, please retain the Git author or use `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-27 01:21 UTC · original · requested changes

Tested on RTX 5090 and WARP with VICTORY_D3D12_DEBUG=1 and VICTORY_D3D12_GBV=1. While default builds (both flags off) and VICTORY_AMBIENT=1 ran cleanly in the probe, enabling VICTORY_COMPOSE=1 reproduces three concrete D3D12 state-tracking / validation errors on both RTX 5090 and WARP:

  1. compose::record assumes game is already in COPY_SOURCE and leaves it stuck in COPY_SOURCE after present (crates/victory-gpu/src/host.rs:3298-3318, crates/victory-gpu/src/compose.rs:265, 273):

    • host.rs:3298-3306 calls compose::record(&self.device, list, game, ui, ui_state) before transitioning game out of shown[0].1 (typically D3D12_RESOURCE_STATE_RENDER_TARGET), while compose.rs:265 unconditionally transitions game from D3D12_RESOURCE_STATE_COPY_SOURCE to NON_PIXEL_SHADER_RESOURCE. Live D3D12 debug layer output on both RTX 5090 and WARP:
      D3D12_MESSAGE_ID_RESOURCE_BARRIER_BEFORE_AFTER_MISMATCH (527):
      Before state (0x800: D3D12_RESOURCE_STATE_COPY_SOURCE) of resource (subresource: 0)
      specified by transition barrier does not match with the state
      (0x4: D3D12_RESOURCE_STATE_RENDER_TARGET)
      
    • compose.rs:273 then transitions game to COPY_SOURCE, and host.rs:3313 overwrites state = D3D12_RESOURCE_STATE_COPY_SOURCE, causing the post-present restore barrier (if state != COPY_SOURCE) to be skipped. game is left in COPY_SOURCE even though Host::present promises to keep presented textures in their original state, triggering a second D3D12 error on the next render-target use of game:
      D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_STATE (538):
      Using ClearRenderTargetView: Resource state (0x800: D3D12_RESOURCE_STATE_COPY_SOURCE)
      is invalid for use as a render target. Expected: 0x4: D3D12_RESOURCE_STATE_RENDER_TARGET
      
    • Fix: pass game's actual game_state into compose::record, transition game game_state -> NON_PIXEL_SHADER_RESOURCE -> game_state (preserving its state), leave out in COPY_SOURCE, and when laid.is_some() skip transitioning texture (game) altogether around CopyResource.
  2. Duplicate conflicting barriers when game and ui refer to the same resource (crates/victory-gpu/src/compose.rs:264-283):
    Unlike the multi-plane Compositor path (host.rs:3411-3414), compose::record does not check game.as_raw() == ui.as_raw(). Passing the same texture in both planes triggers D3D12 validation errors 1008 (duplicate barrier on the same subresource) and 527 (mismatched before/after states) on both RTX 5090 and WARP.

  3. Diagnostics capture and black-frame probe read uncomposed texture instead of laid (crates/victory-gpu/src/host.rs:3345, 3348):
    Line 3326 copies laid.as_ref().unwrap_or(texture) into &back, but lines 3345 (capture::read_back) and 3348 (capture::probe) still pass texture. That drops the composed overlay from captures/probes and also causes CopyTextureRegion state error 538 once game is properly restored to game_state instead of left in COPY_SOURCE. Passing let source = laid.as_ref().unwrap_or(texture); to CopyResource, read_back, and probe keeps all three consistent.

(Design note): ambient.rs matches specific shader-name substrings (CS_ScreenProbes_TemporalResolve, CS_UpdateHistory, ps_sky_paraboloid_reflection) and hardcoded root table offsets ((1, 176), (1, 40), (0, 464)). Worth double-checking whether maintainers want title-specific shader/table hooks in victory-gpu even behind an opt-in switch.

**@⁠fuzeofficlal** on GitHub · 2026-11-27 01:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/3414#pullrequestreview-6082243190) · **requested changes** Tested on RTX 5090 and WARP with `VICTORY_D3D12_DEBUG=1` and `VICTORY_D3D12_GBV=1`. While default builds (both flags off) and `VICTORY_AMBIENT=1` ran cleanly in the probe, enabling `VICTORY_COMPOSE=1` reproduces three concrete D3D12 state-tracking / validation errors on both RTX 5090 and WARP: 1. **`compose::record` assumes `game` is already in `COPY_SOURCE` and leaves it stuck in `COPY_SOURCE` after `present` (`crates/victory-gpu/src/host.rs:3298-3318`, `crates/victory-gpu/src/compose.rs:265, 273`)**: - `host.rs:3298-3306` calls `compose::record(&self.device, list, game, ui, ui_state)` *before* transitioning `game` out of `shown[0].1` (typically `D3D12_RESOURCE_STATE_RENDER_TARGET`), while `compose.rs:265` unconditionally transitions `game` from `D3D12_RESOURCE_STATE_COPY_SOURCE` to `NON_PIXEL_SHADER_RESOURCE`. Live D3D12 debug layer output on both RTX 5090 and WARP: ```text D3D12_MESSAGE_ID_RESOURCE_BARRIER_BEFORE_AFTER_MISMATCH (527): Before state (0x800: D3D12_RESOURCE_STATE_COPY_SOURCE) of resource (subresource: 0) specified by transition barrier does not match with the state (0x4: D3D12_RESOURCE_STATE_RENDER_TARGET) ``` - `compose.rs:273` then transitions `game` to `COPY_SOURCE`, and `host.rs:3313` overwrites `state = D3D12_RESOURCE_STATE_COPY_SOURCE`, causing the post-present restore barrier (`if state != COPY_SOURCE`) to be skipped. `game` is left in `COPY_SOURCE` even though `Host::present` promises to keep presented textures in their original state, triggering a second D3D12 error on the next render-target use of `game`: ```text D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_STATE (538): Using ClearRenderTargetView: Resource state (0x800: D3D12_RESOURCE_STATE_COPY_SOURCE) is invalid for use as a render target. Expected: 0x4: D3D12_RESOURCE_STATE_RENDER_TARGET ``` - Fix: pass `game`'s actual `game_state` into `compose::record`, transition `game` `game_state -> NON_PIXEL_SHADER_RESOURCE -> game_state` (preserving its state), leave `out` in `COPY_SOURCE`, and when `laid.is_some()` skip transitioning `texture` (`game`) altogether around `CopyResource`. 2. **Duplicate conflicting barriers when `game` and `ui` refer to the same resource (`crates/victory-gpu/src/compose.rs:264-283`)**: Unlike the multi-plane `Compositor` path (`host.rs:3411-3414`), `compose::record` does not check `game.as_raw() == ui.as_raw()`. Passing the same texture in both planes triggers D3D12 validation errors `1008` (duplicate barrier on the same subresource) and `527` (mismatched before/after states) on both RTX 5090 and WARP. 3. **Diagnostics capture and black-frame probe read uncomposed `texture` instead of `laid` (`crates/victory-gpu/src/host.rs:3345, 3348`)**: Line `3326` copies `laid.as_ref().unwrap_or(texture)` into `&back`, but lines `3345` (`capture::read_back`) and `3348` (`capture::probe`) still pass `texture`. That drops the composed overlay from captures/probes and also causes `CopyTextureRegion` state error `538` once `game` is properly restored to `game_state` instead of left in `COPY_SOURCE`. Passing `let source = laid.as_ref().unwrap_or(texture);` to `CopyResource`, `read_back`, and `probe` keeps all three consistent. *(Design note)*: `ambient.rs` matches specific shader-name substrings (`CS_ScreenProbes_TemporalResolve`, `CS_UpdateHistory`, `ps_sky_paraboloid_reflection`) and hardcoded root table offsets (`(1, 176)`, `(1, 40)`, `(0, 464)`). Worth double-checking whether maintainers want title-specific shader/table hooks in `victory-gpu` even behind an opt-in switch.
Author
Owner

@⁠moe-miau on GitHub · 2026-11-27 03:44 UTC · original

NVIDIA result for the ambient fallback in this PR (VICTORY_AMBIENT=0.8), RTX 4070 SUPER (32-lane waves), driver 32.0.16.1742, Windows 11. The title was used locally; only numbers and a description of the picture are reported here.

Tree: main f3578e3 + #2464, #2098, #2626, #2628, #2711, #2851, #2705 (VICTORY_CARD_COPIES=1), #2176/#2925 (VICTORY_WAVE32_APPROX=1), #2958, #3069, then this PR (ed1d879b, clean cherry-pick). diag build, Series X profile, the BVH builder held back as on the base. Same save and scripted input for every run, prison cell after the opening.

VICTORY_AMBIENT=off VICTORY_AMBIENT=0.8
walls and floor green and purple blocks over most of the room (stale probe memory) clean, lit and textured
frame (last 3 minutes) (run cut at world entry) 265 ms (3.8 fps), steady
device removal in 8 minutes no no

So on NVIDIA the green patches the indirect-light probes leave without the BVH builder are covered by this fallback. I didn't see a frame-time cost I could separate from run-to-run noise. Another NVIDIA observation, not about this PR: on the Series S profile the world stays black in the same tree, because the title's own FSR4 passes don't translate (the known gap in the README), so I tested Series X.

Two notes on the PR itself: the plane composition (VICTORY_COMPOSE) and the ambient fallback are separate features, and they might review faster as two PRs. And VICTORY_AMBIENT is also the switch name in #2619, with a different syntax.

AI-assisted (Claude Code). Runs done on my machine.

**@⁠moe-miau** on GitHub · 2026-11-27 03:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/3414#issuecomment-7209234641) NVIDIA result for the ambient fallback in this PR (`VICTORY_AMBIENT=0.8`), RTX 4070 SUPER (32-lane waves), driver 32.0.16.1742, Windows 11. The title was used locally; only numbers and a description of the picture are reported here. **Tree:** `main` `f3578e3` + #2464, #2098, #2626, #2628, #2711, #2851, #2705 (`VICTORY_CARD_COPIES=1`), #2176/#2925 (`VICTORY_WAVE32_APPROX=1`), #2958, #3069, then this PR (`ed1d879b`, clean cherry-pick). `diag` build, Series X profile, the BVH builder held back as on the base. Same save and scripted input for every run, prison cell after the opening. | | `VICTORY_AMBIENT=off` | `VICTORY_AMBIENT=0.8` | |---|---|---| | walls and floor | green and purple blocks over most of the room (stale probe memory) | clean, lit and textured | | frame (last 3 minutes) | (run cut at world entry) | 265 ms (3.8 fps), steady | | device removal in 8 minutes | no | no | So on NVIDIA the green patches the indirect-light probes leave without the BVH builder are covered by this fallback. I didn't see a frame-time cost I could separate from run-to-run noise. Another NVIDIA observation, not about this PR: on the Series S profile the world stays black in the same tree, because the title's own FSR4 passes don't translate (the known gap in the README), so I tested Series X. Two notes on the PR itself: the plane composition (`VICTORY_COMPOSE`) and the ambient fallback are separate features, and they might review faster as two PRs. And `VICTORY_AMBIENT` is also the switch name in #2619, with a different syntax. AI-assisted (Claude Code). Runs done on my machine.
This pull request can be merged automatically.
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/3414/head:github-bot/gh-3414'
git switch 'github-bot/gh-3414'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3414'
git switch 'github-bot/gh-3414'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3414'
git switch 'github-bot/gh-3414'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3414'
git switch 'main'
git merge --squash 'github-bot/gh-3414'
git switch 'main'
git merge --ff-only 'github-bot/gh-3414'
git switch 'main'
git merge 'github-bot/gh-3414'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3414
No description provided.