Skip to content

Card steps: serve constant fills behind placed copies from destination shadow (VICTORY_PLACED_FILLS) - #740

Merged
trustno1-coder merged 1 commit into
trustno1-coder:mainfrom
Czer0xx:pr/placed-fills
Nov 28, 2026
Merged

trustno1-coder merged 1 commit into
trustno1-coder:mainfrom
Czer0xx:pr/placed-fills

Conversation

@Czer0xx

@Czer0xx Czer0xx commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an opt-in switch VICTORY_PLACED_FILLS=1 (off by default, exposed in the F1 menu as CONSTANTS AFTER PLACED COPIES) in crates/victory-gpu/src/host/card_steps.rs and crates/victory-gpu/src/host/menu.rs.

When enabled, constant-buffer fills (Step::Fill with a dedicated descriptor slot) that stand behind a placed buffer copy (Step::Placed) and read only bytes written by that copy are pointed directly at the placed copy's destination host shadow on the GPU instead of refusing the submission or copying bytes through the front-of-submission scratch buffer.

With VICTORY_PLACED_FILLS unset, behaviour is unchanged (including VICTORY_PLACED_READS=1).

Where the bytes are and why this differs from VICTORY_PLACED_READS=1

  • The bytes are already written on the card into placed.shadow.buffer by HostList::place_copy, followed by wait_for_all (crates/victory-gpu/src/host/place.rs).
  • VICTORY_PLACED_FILLS=1 adds zero GPU buffer copies: show_placed validates 256-byte CBV alignment, buffer bounds, and that the placed copy is not waiting on flights (!matches!(placed.waits(written), Waits::Yes)), then points the fill's dedicated descriptor slot straight at placed.shadow.buffer.
  • Because it reads from the destination shadow rather than the placed copy's source, it also handles placed copies whose source has no GPU host copy (CPU scratch upload path) or was written earlier in the same submission.
  • If any step behind the placed copy reads the destination on the CPU (including Does::Read, an untaken Does::Copy/Does::Fill, or a later Does::Placed reading from dst), served_fills refuses to serve from that copy so title-memory coherency is preserved.
  • Compared to VICTORY_PLACED_READS=1 on 63b902f: in A/B testing, VICTORY_PLACED_READS=1 still refused 0.40 submissions/frame (waiting for flights median 15.8 ms, peaks 33-47 ms) with a step other than a fill done on the card reads what a copy at its place writes (PLACED_READER), because placed_read_on_cpu checks all steps in does (including steps ahead of the placed copy and fills handled on the card). VICTORY_PLACED_FILLS=1 avoids those false refusals and drops BEHIND_PLACED / PLACED_READER refusals to 0.00/frame.

Relation to existing open PRs

Checked existing open PRs before opening this one:

  • #34 (perf(gpu): snapshot placed-copy constants on GPU and enable VICTORY_PLACED_ORDER): copies constants into a per-list DEFAULT buffer during list recording and enables VICTORY_PLACED_ORDER by default; predates VICTORY_PLACED_READS.
  • #295 (perf(gpu): plan dependent GPU fills behind placed copies...): currently has merge conflicts against main (63b902f), bundles two ports, and does not include in-game A/B numbers.

This PR stays strictly opt-in behind VICTORY_PLACED_FILLS=1, performs no extra GPU copy, applies cleanly on 63b902f alongside VICTORY_PLACED_READS=1, and is measured directly against VICTORY_PLACED_READS=1.

Measured results (in-game A/B on 63b902f)

Hardware: Windows 11, NVIDIA GeForce RTX 3060 12 GB, Series X profile, 2560x1440, DLSS Performance, release build, same opening cutscenes through the prison room (up to ~7,150 draws/frame), pipeline cache warmed before both runs.

Metric (3D scenes) VICTORY_PLACED_READS=1 (main 63b902f) VICTORY_PLACED_FILLS=1 (this PR)
waiting for flights median (mean) 15.8 ms (20.3 ms) 0.1 ms (1.4 ms)
card_steps submissions refused/frame median (max) 0.40 (1.00) 0.00 (0.20)
PLACED_READER / BEHIND_PLACED refusals 37.23 summed rate (PLACED_READER) 0.00
Submitting thread preparing median (mean) 87.9 ms (92.4 ms) 75.2 ms (82.6 ms)
Heavy interior (5,000-7,150 draws) on the GPU wait 13.7-43.5 ms (8.1-9.4 fps) 0.0-12.9 ms (10.5-11.4 fps)
Peak 3D frame rate 14.7 fps (68.0 ms) 15.6 fps (64.2 ms)

Visual check: no corruption or regressions observed across the full opening stretch.

Verification

  • cargo clippy -p victory-gpu --all-targets --locked and --all-features --locked: 0 warnings in modified files (card_steps.rs, menu.rs).
  • cargo test -p victory-gpu --lib --locked: 454 passed, 0 failed, 36 ignored (including new unit test host::card_steps::tests::fills_behind_a_copy_at_its_place_are_shown_its_bytes and existing a_fill_behind_a_copy_at_its_place_reads_where_the_copy_does).
  • cargo xtask policy: asset policy: 294 files ok.
  • cargo build --release --locked -p victory and verified in-game against VICTORY_PLACED_READS=1 on the same build.

Copilot AI balanced review requested due to automatic review settings November 28, 2026 04:42

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@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 Windows (RTX 5090):

  • cargo test -p victory-gpu --lib card_steps:: passed (10/10, including fills_behind_a_copy_at_its_place_are_shown_its_bytes)
  • cargo test -p victory-gpu --lib host::menu:: passed (7/7)
  • 0 new compiler warnings in touched files
  • cargo xtask policy passed (294 files ok)

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

@Yoshi-233

Copy link
Copy Markdown

I tested VICTORY_PLACED_FILLS=0/1 on an RTX 4070 Ti SUPER (16 GB, Windows driver 617.42), with the same executable, checkpoint and cache. This was the only launch-setting change. Four screenshots per run verify the same overhead view of the swimmer and vegetation for 36 seconds. Here are the window medians after allowing the camera to settle:

Placed fills Render FPS Frame time GPU work inside submission timestamps Draws/frame Displayed FPS
Off 18.05 55.35 ms 38.3 ms 1,210 36
On 18.20 55.10 ms 38.5 ms 1,150 36

The destination-shadow path was exercised: 7 of 29 service reports in the enabled window were nonzero, reaching 0.32 served fills per frame. In the three longer route windows the log reported a wait for an upload-memory fill with the placed-copy dependency reason in 3, 13 and 14 reporting intervals with the option off, and in zero intervals with it on. Some of those longer windows faced different shores, so the FPS comparison above uses only the matched overhead view.

This confirms the change in the reported waits on this card. The scene’s median frame time moved by 0.25 ms with a small draw-count difference; it gives me no measurable throughput gain to claim here.

xorpix added a commit to xorpix/VIctory-NVIDIA that referenced this pull request Nov 28, 2026
Reuse upload scratch and filter unchanged graphics copies, reduce descriptor
lock contention, and let safe constant-buffer transfers stay on the GPU.
Keep the optional direct constant-buffer path behind F1. Stabilize static
sampler order for reuse of the driver's shader pipelines. Expose DLSS
Ultra Performance for Series X with the same ultrawide output and HUD.

Ports selected changes from trustno1-coder#548, trustno1-coder#700,
trustno1-coder#814, trustno1-coder#740, trustno1-coder#958 and fxceless/victory-fork@9e90746. The source bundle
preserves the individual commits and credit.
@grosterr

Copy link
Copy Markdown
Contributor

One run here suggests VICTORY_PLACED_FILLS=1 may break the skin of faces, but I have not run it on its own yet, so take this as a lead, not a result.

RTX 3060 12 GB (driver 621.40), Ryzen 7 5700X, 32 GB, Windows 11. Main 63b902f with open PRs on top (among them #501, #635, #641, #799, #807, #857, #875), Series S, 1920x1080, DLSS Quality (preset K), FSR 3 frame generation 2x. Shader cache warmed, no misses.

Run Switches Face in the first cutscene (the woman in glasses, the office)
base none normal
1 VICTORY_PLACED_FILLS=1 + VICTORY_NARROW_BARRIERS=1 the whole skin a magenta-pink dotted pattern, steady (not flickering), the glasses, hair and clothes normal
2 VICTORY_NARROW_BARRIERS=1 alone normal (twice)

(Run 1 and one of the runs 2 also had the water program 5dc3b25986622949 left out, for #739; it is not drawn in that cutscene.) So the face changed only when VICTORY_PLACED_FILLS=1 was added. #799 turns the picture white on this build (I posted that under #799), so run 1 is not a clean test of this switch. A run with VICTORY_PLACED_FILLS=1 alone is next; I will add the result here.

The log showed fills behind a copy at its place shown that copy's bytes on the card, per frame (VICTORY_PLACED_FILLS=1) at about 3.3 a frame, and nothing new among the warnings.

AI-assisted (Claude Code): the runs were judged by eye on my PC, and Claude wrote this text. No game files attached.

🤖 Generated with Claude Code

@grosterr

Copy link
Copy Markdown
Contributor

The run with VICTORY_PLACED_FILLS=1 alone, same build, settings and route: the face in the first cutscene is normal, the cutscene-to-gameplay fade into the boat scene is normal, and nothing else looked wrong. So the magenta skin from my earlier comment came with VICTORY_NARROW_BARRIERS=1 on as well, not from this switch by itself. Sorry for the false alarm.

Cutscene with this switch: 40.1 ms a frame (GPU BUSY 39.3). One run, so I make no claim about speed.

🤖 Generated with Claude Code

@nick0451

Copy link
Copy Markdown

A smoke test only: the scene barely reaches this path.

RTX 3090 24 GB (driver 610.88), i9-14900K, 32 GB, Windows 11. A release build of this PR merged onto main at 63b902f. Series S, DLSS Performance, frame generation off. Every run used the same frozen save, outdoors on a balcony by the water (about 5,900 draws a frame), standing still. One warm-up start per build, then main and four PR builds were run in turn, three rounds each. Each run is 40 s to settle, 60 s measured, then a screenshot. An A/A run of main against itself in this setup differs by 2-3%.

  • With VICTORY_PLACED_FILLS=1: the log line fills behind a copy at its place shown that copy's bytes on the card reads 0.00 a frame in most lines and 0.12 in some. So in this scene the path is reached rarely, and this says little about the gain.
  • Speed: 24.8 fps median against 24.6 for main (runs 19.4, 25.3, 24.8; the first round was slow for every new build).
  • Picture: normal in all end-of-run screenshots. No crash, device loss or ERROR line.
  • cargo test -p victory-gpu --lib: 454 passed.

So nothing broke where it is idle. A real test needs a scene with many placed copies; I'll add one if I get a save there.

Tested with an AI assistant (Claude Code); results are from this PC.

@Czer0xx

Czer0xx commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Thanks everyone (@Dukestar69, @Yoshi-233, @grosterr, @nick0451) for testing and verifying across RTX 3060, 3090, 4070 Ti SUPER, and 5090.

Summarizing where things stand from the independent runs:

The PR remains cleanly mergeable with no changes needed on this side, and is ready for maintainer CI approval and review.

@trustno1-coder
trustno1-coder merged commit 540cd96 into trustno1-coder:main Nov 28, 2026
krolyxon added a commit to krolyxon/VIctory-NVIDIA-proton that referenced this pull request Nov 28, 2026
Conflicts:
- watch.rs: trustno1-coder#933's protect_here/protect_run split kept, upstream's soft
  views parameter passed through both.
- shadow.rs: upstream's has_pending and PageMerge landing loop taken (on
  trustno1-coder#1298's copied tuple); trustno1-coder#1184's lazy landing applied to upstream's
  outside_sorted_into parts.
- pool.rs: trustno1-coder#814's take_from_with (one empty block made ahead) kept; its
  base is the same trustno1-coder#661 change upstream merged.
- card_steps.rs: upstream's taken whole (VICTORY_PLACED_FILLS, trustno1-coder#740);
  trustno1-coder#1298's card_steps part dropped.
- draw.rs: upstream's trustno1-coder#532 values; trustno1-coder#814's cached slot handle kept inside
  upstream's rest() timing.
- descriptor/host.rs: upstream's TextureQueue ordering taken whole; trustno1-coder#814's
  VICTORY_DUE_FRESH_FIRST and its play.rs default dropped. A test module
  both sides added was kept once.
- emit/mod.rs, send.rs: both sides kept.
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.

7 participants