Skip to content

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

Open
legayclightning22 wants to merge 1 commit into
Marvisak:mainfrom
legayclightning22:feat/second-plane-compose-and-ambient-fallback
Open

legayclightning22 wants to merge 1 commit into
Marvisak:mainfrom
legayclightning22:feat/second-plane-compose-and-ambient-fallback

Conversation

@legayclightning22

Copy link
Copy Markdown

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.

@Dukestar69 Dukestar69 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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).

@Jackster

Copy link
Copy Markdown

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.

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

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 <andrewpozdnakov7-jpg@users.noreply.github.com>.

@fuzeofficlal fuzeofficlal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@moe-miau

Copy link
Copy Markdown

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants