Skip to content

GPU: alias copies before a list's first touch go to its prelude, once per source write (VICTORY_ALIAS_ONCE=1) - #1015

Open
shawshanker18 wants to merge 2 commits into
fxceless:mainfrom
shawshanker18:alias-copies-once
Open

shawshanker18 wants to merge 2 commits into
fxceless:mainfrom
shawshanker18:alias-copies-once

Conversation

@shawshanker18

Copy link
Copy Markdown

What

VICTORY_ALIAS_ONCE=1 (off by default). The title writes R9G9B9E5 targets as R32_UINT and reads them through views placed in the same memory (crate::texture::alias). Every host list that read such a view copied the texture again through a buffer, even when nothing had written the source since the last copy.

With the switch:

  • A list that needs an alias copy before it touches the source or the placed texture leaves the copy to its prelude. Preludes are recorded at submission, in the queue's order, with both textures already in the copy states the list starts with.
  • Each submission gets a number. Lists note the host copies they put in a writing state (render target, UAV, depth write, stream out, copy or resolve destination).
  • A prelude leaves a copy out if it already ran in a submission after the source's last write.
  • Copies later in a list (after the list wrote or read the source itself) stay inline, exactly as before.

Assumption: only these copies write the placed texture's host copy (aliased views are never uploaded from title memory, see crate::draw::readable).

Measured

RTX 4050 Laptop (6 GB), Ryzen 7 7735HS, Series X, lit world, on 9376fd6 plus the window, 1080p display mode, copy-queue fetch and rehash-runs switches:

ms/frame fps
without 358 2.8
VICTORY_ALIAS_ONCE=1 333 3.0

Before the switch the timing run showed 78 alias copies a frame (26-31 ms of the card's time). With it: 26 made and 20 left out a frame in preludes, the rest inline. The picture looked the same (lit prison yard, same lighting in recordings with and without).

Checks

  • Rebased onto current main (3973179): cherry-picks cleanly, builds (--profile diag --features diagnostics).
  • cargo test -p victory-gpu --lib: 175 passed, 1 failed (indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields), which fails the same way on unmodified 3973179.
  • cargo clippy reports only lints in files this PR does not touch (also on main).

No game data.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eb0d6489d8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/victory-gpu/src/host.rs Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T16:23:20.804174Z eb0d648 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Proudnoob4

Copy link
Copy Markdown

Tested in-game on Windows 10 Pro (22H2), Intel i5-13600K (6P+8E), RTX 4080 16 GB (driver 621.01, Series X profile), 420 s run in the prison cell scene (ca8829f + #1014 + #1015 + #1016 + #1029 + #1032 stacked, compared against our 600 s 465b94f run with the same base switches VICTORY_ASYNC_SUBMIT=1 VICTORY_QUEUE2=1 VICTORY_COPY_PLAIN=1 VICTORY_INDIRECT_WINDOW=1 VICTORY_JOIN_PARTS=1 VICTORY_BACK_OWN_VIEW=1 VICTORY_INDIRECT_GATHER=1 plus VICTORY_RELAY=2 VICTORY_LATE_WAIT=3 VICTORY_GROUP_SYNC=2 VICTORY_WIDE_BACK=1 VICTORY_CARD_BUFFERS_MIN_MB=1 VICTORY_CARD_BUFFERS_MB=1024).

VICTORY_ALIAS_ONCE=1 tail steady state in the cell scene:

  • �lias copies in preludes per frame (VICTORY_ALIAS_ONCE=1): 26.0 made, 20.0-20.2 left out (source not written since) (~44% of prelude alias copies skipped cleanly).
  • Clean visual match ( rame-2048.png), stacked run hit 8.50 fps / 117.0 ms median (mean 8.31, max 9.80).

AI-assisted (Gemini 4 Hydrogen).

… per source write

VICTORY_ALIAS_ONCE=1 (off by default). The title writes R9G9B9E5 targets as
R32_UINT and reads them through views placed in the same memory, and every
list that read one copied it again through a buffer: 78 copies a frame,
26-31 ms of the card's time on an RTX 4050 Laptop. A copy a list needs
before it touches the source or the placed texture is now recorded in the
list's prelude at submission (preludes are recorded in the queue's order,
with both textures already in the copy states the list starts with). Each
submission gets a number; lists mark the host copies they put in a writing
state; a prelude leaves a copy out if it ran in a submission after the
source's last write. Copies later in a list stay where they were.

Series X, lit world, with the window, 1080p, copy-queue fetch and rehash
runs switches: 358 -> 333 ms a frame (2.8 -> 3.0 fps); 26 alias copies made
and 20 left out a frame in preludes. The picture looked the same.
The marks were keyed by the host copies' addresses only, so a source and
placed texture made at the addresses of freed ones could inherit an old
pair's mark and skip their first copy (review on fxceless#1015). Each mark now holds
a weak reference to its copies: while it lives, the allocation behind its
address cannot be reused. Marks of copies that are gone are swept once
there are more than 4,096.
@shawshanker18

Copy link
Copy Markdown
Author

Rebased onto d510ee4 (the conflict was in HostList::prelude; the gather records and the alias copies now both run there), and the Codex finding is fixed. Each alias mark now holds weak references to its source and placed host copies. While a mark lives, the allocation behind its address can't be freed and handed to a new copy, so a new pair can't inherit an old pair's mark. Marks of copies that are gone are swept once there are more than 4,096.

cargo test -p victory-gpu --lib: 181 passed. The one failure, warp_budget_saturates_without_wraparound_and_preserves_draw_fields, fails the same way on main.

@Proudnoob4 thanks for the in-game run on the 4080: the 26 made / 20 left out per frame matches what I measured on a 4050.

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.

2 participants