Skip to content

GPU: copy title textures to the host once per change, and check them on several threads - #1500

Closed
A6thGraderFr wants to merge 2 commits into
Marvisak:mainfrom
A6thGraderFr:claude/jolly-pascal-e2l2rq
Closed

A6thGraderFr wants to merge 2 commits into
Marvisak:mainfrom
A6thGraderFr:claude/jolly-pascal-e2l2rq

Conversation

@A6thGraderFr

Copy link
Copy Markdown

What

Two changes to how textures the title writes through memory reach the host GPU.

  1. Upload once per change. Every list that sampled such a texture recorded a copy of all its subresources from the staging buffer into the host texture, at every submission, even when the memory had not changed. A texture read by ten lists of a submission crossed the bus ten times, and went to the copy-destination state and back in each list. All those copies read the same staging buffer, which the submission's steps fill before any list runs (see GPU: check a sampled texture once per submission, not once per list #79). Now a texture is copied only when its contents changed, once, before the submission's lists run.
  2. Check textures on several threads. Textures in physical-page memory cannot be write-watched, so each is hashed whole at every submission that samples it, one after another on the submitting thread. These checks now run together on up to 8 threads.

How

  • Each staging buffer counts its detilings and remembers the one its host copy was last given (Copies in texture.rs).
  • At submission, after the refreshes, textures whose host copies lack the staging buffer's contents are copied in one list that runs before the submission's lists (Host::record_uploads). Unchanged textures are not copied and keep the state the lists left them in. Diagnostics markers and timestamps for the copies are kept.
  • Texture checks wait in the submission's Batch with the buffer refreshes and run at the same points (before a title-memory write, before a range goes to shaders, before the lists run), so each still reads memory as its step saw it. One thread per 4 MiB to hash, at most one per texture, per core and 8; write-watched memory counts as no work.
  • The frame-rate line now gives the MB uploaded per frame.

Benchmark (synthetic)

cargo test --release -p victory-gpu -- --ignored --nocapture texture_hashing: 48 textures of 4 MiB hashed in about 42 ms on one thread and 14 ms on four (3.0x; 4-core VM, median of 7 runs). Gains in the world are not measured; the new "MB uploaded" figure and the "on the GPU" time in the frame-rate line should show them.

Tests

  • cargo clippy --workspace --all-targets -- -D warnings, with and without --all-features (target x86_64-pc-windows-msvc): clean.
  • cargo xtask policy: ok. rustfmt: no new differences.
  • New: resource::tests::title_textures_reach_the_host_once_per_change (end to end through the queue, lists and CopyResource, read back from the host GPU; it fails with the upload copy left out), and texture::tests for the copy bookkeeping and the thread split.
  • cargo test -p victory-gpu under Wine on software Vulkan, with a local, uncommitted fallback to feature level 11_0 (that stack refuses 12_0): 52 passed, 55 with diagnostics. argument_clamp_builds and a_rejected_blob_gives_an_empty_library fail the same way on unmodified main there.
  • Not run on Windows, on a real GPU or against the game.

#230 attempts the first change too. This one tracks whether the host copy holds the latest contents (not only whether they were detiled in this submission), copes with a submission that names a list twice, and keeps the diagnostics notes.

No game data was used.

AI-assisted (Claude Code).

Every list that read a texture the title writes through memory recorded
a copy of all its subresources from the staging buffer into the host
texture, at every submission, whether or not the memory had changed: a
texture read by ten lists of a submission crossed the bus ten times, and
went to the copy destination state and back in each of those lists. All
of those copies read the same staging buffer, which the submission's
steps fill before any list runs.

A texture's staging buffer now counts its detilings, and remembers the
one its host copy was last given. At submission, after the refreshes,
each texture whose host copy lacks the staging buffer's contents is
copied once, in a list that runs before the submission's lists; with
diagnostics, its copies carry markers and timestamps as before. A
texture whose memory did not change is not copied at all, and stays in
the state the lists that read it leave it in. The frame-rate line now
gives the megabytes uploaded per frame.

Tested end to end on the host device (resource::tests): a title texture
copied by one list, and by two lists of one submission, reaches its host
copy once per change of its memory over several submissions, read back
from the host GPU; with the copy left out, the read-back finds zeros.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Un9eWGTSggLRDdpjft9Gjd
A texture in physical-page memory, which cannot be write-watched, is
hashed whole at every submission that samples it, and a submission's
textures were checked one after another on the submitting thread, while
the title's render thread waited for it.

Texture checks now wait in the submission's batch with the buffer
refreshes and are done together at the same points: before a step that
writes title memory, before a range goes to shaders, and before the
lists run, so each still reads the memory as its step saw it. They run
on up to eight threads, one per 4 MiB of memory to hash, the calling one
among them; memory known to be write-watched counts for nothing, as it
is only read when its pages were written. The frame-rate line's texture
time is the time the submission waited for them.

A benchmark (ignored test, release build) hashing 48 textures of 4 MiB:
about 42 ms on one thread, 14 ms on four (3.0x; a 4-core VM, median of
seven runs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Un9eWGTSggLRDdpjft9Gjd
@BitWuehler

Copy link
Copy Markdown

First real-GPU / in-game A/B data point on Linux + Proton + NVIDIA RTX 5080 (driver 620.73.04, CachyOS 7.3.6-1-cachyos, Ryzen 7 9800X3D, GE-Proton11-14 via umu-run, VKD3D_DISABLE_EXTENSIONS=VK_NV_raw_access_chains, retail 1.0.2.1, --console series-x, diag build).

Integration note: #1500 was merged cleanly alongside #1180, #585, and #1067 on top of our previous #994 + #177 + #454 + #1260 + #1267 + MIN_DYNAMIC = 1 << 18 (#747) stack. Because #585 + #1067 cleared 107 untranslated shaders, the new run executes ~47% more draws/frame, so textures time and uploaded MB below are measured under substantially heavier draw load:

Metric (world >= 100 draws intervals) Before (n = 30) With #1500 (+ #585/#1067/#1180, n = 28)
Untranslated shaders / draws per frame (med) 415 / 2,076 (max 5,662) 308 / 3,051 (max 8,073)
textures time (median / mean) 94.4 ms / 129.9 ms 82.8 ms / 120.1 ms (−12.3% despite +47% draws)
Texture staging checked (tex_mb med / mean) 117.2 MB / 113.7 MB 122.2 MB / 126.8 MB
New MB uploaded (#1500) (all checked copies uploaded) 14.7 MB med / 17.5 MB mean (~88% upload reduction)
on the GPU (median) 154.5 ms 181.5 ms (likely higher draw count: 2,076 → 3,051)
GPU faults / device removals / Xids 0 / 0 / 0 0 / 0 / 0 (up to frame=1523)

No regressions or texture glitches observed in the debug world view; MB uploaded confirms most checked staging textures are unchanged and skipped for GPU upload in-game.

AI-assisted log analysis and write-up; built and run locally on my own retail copy, no game files or raw logs attached.

Jarrrk pushed a commit to Jarrrk/VIctory that referenced this pull request Nov 24, 2026
Changed title textures are now copied into their host copies once per
submission on a dedicated upload list, instead of once per sampling list;
texture refresh hashing is also split across threads.

Ported from Marvisak/VIctory Marvisak#1500.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@Marvisak

Copy link
Copy Markdown
Owner

Automated triage for the maintainers. Closing because another open pull request covers the same change.

See #230. Same goal as #230 (copy a title texture once per change, not per list) with a second change on top (checking textures on several threads).

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

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.

4 participants