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

Closed
A6thGraderFr wants to merge 2 commits from upstream-pr/1500 into main
A6thGraderFr commented 2026-11-24 18:33:04 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by A6thGraderFr on 2026-11-24T18:33:04Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:issue:6588741514 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1500). Originally posted by [A6thGraderFr](https://github.com/A6thGraderFr) on 2026-11-24T18:33:04Z. --- ### 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 #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).
BitWuehler commented 2026-11-24 21:03:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by BitWuehler on 2026-11-24T20:24:43Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7143506758 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1500#issuecomment-7143506758). Originally posted by [BitWuehler](https://github.com/BitWuehler) on 2026-11-24T20:24:43Z. --- 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.*
upstream-sync closed this pull request 2026-11-25 01:06:44 +00:00
Marvisak commented 2026-11-25 01:08:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:41:35Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148777512 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1500#issuecomment-7148777512). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:41:35Z. --- 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.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1499
No description provided.