GPU: a submission's texture checks run several at a time (VICTORY_WIDE_TEXTURES=1) #768

Open
github-bot wants to merge 8 commits from github-bot/gh-768 into main AGit
Owner

@⁠KyleS98 on GitHub · 2026-11-25 07:04 UTC · original
KyleS98:perf/wide-texture-refresh → main · +203 −3 · 3 files · 8 commits · open

While the world streams in, a submission checks hundreds of textures one after another on the submitting thread. Each one is read, hashed whole and, if it changed, detiled into its staging buffer. On the opening cutscene and the first world minutes, that's the frame line's "textures" at 100–1,400 ms per frame (250–930 MB), so the cutscene plays at 0.3–2 fps.

Change (opt-in, VICTORY_WIDE_TEXTURES=1)

  • Texture checks that come due in a batch are queued (Batch::textures_due) instead of being run inline.
  • The queue runs at the batch's next flush, which happens before a step that writes title memory and before the lists run. So the order against those steps is unchanged. It runs on the threads already kept for the snapshots (shadow::wide_run).
  • It's safe to parallelize. Each check reads its own texture's title memory and writes its own staging buffer and notes under its own lock. A texture is queued once per batch (Batch::texture_due), so no two threads check the same one. Read buffers are per-thread, and the remap guard is a shared lock.
  • The frame line's "textures" counts the time it took (wall clock), not the threads' sum.
  • Off by default; nothing changes without the switch.

Measurements

RTX 3090 Ti + Ryzen, Windows 11, diag build of this branch on 8dd30ab, retail title, Series X profile. One launch per configuration, average over the frames between the first world frame and the steady state:

configuration frame time "textures" steady state after streaming
default ≈1,030 ms ≈330 ms 4.1 fps
VICTORY_WIDE_TEXTURES=1 ≈826 ms ≈120 ms 4.1–4.3 fps
VICTORY_TEXTURE_NO_WAIT=1 ≈654 ms ≈44 ms 4.1–4.2 fps
both ≈518 ms ≈16 ms 4.0–4.2 fps
  • With this switch alone, the remaining texture time is mostly waiting for the runtime's remap lock ("1,299 of 1,667 ms waiting for title memory to hold still" on the texture-refresh line). That's what VICTORY_TEXTURE_NO_WAIT addresses, and the two complement each other: together the slow phase runs at about twice the default frame rate.
  • No crash or device loss in any of the four runs. Live screen grabs of the combined run show the cutscene and the cell rendering normally; the only white frame is the cutscene's own fade-in.
  • cargo test -p victory-gpu --lib batch: 4 passed (1 ignored benchmark). cargo clippy -p victory-gpu --all-targets: no new warnings.

If these numbers hold on other machines, both switches look like candidates to turn on by default. I've left that to you.

AI-assisted (Claude Code, Claude Opus 5.5). No game data attached.

🤖 Generated with Claude Code

**@⁠KyleS98** on GitHub · 2026-11-25 07:04 UTC · [original](https://github.com/fxceless/victory-fork/pull/768) `KyleS98:perf/wide-texture-refresh` → `main` · +203 −3 · 3 files · 8 commits · open While the world streams in, a submission checks hundreds of textures **one after another on the submitting thread**. Each one is read, hashed whole and, if it changed, detiled into its staging buffer. On the opening cutscene and the first world minutes, that's the frame line's "textures" at 100–1,400 ms per frame (250–930 MB), so the cutscene plays at 0.3–2 fps. ### Change (opt-in, `VICTORY_WIDE_TEXTURES=1`) - Texture checks that come due in a batch are queued (`Batch::textures_due`) instead of being run inline. - The queue runs at the batch's **next flush**, which happens before a step that writes title memory and before the lists run. So the order against those steps is unchanged. It runs on the threads already kept for the snapshots (`shadow::wide_run`). - It's safe to parallelize. Each check reads its own texture's title memory and writes its own staging buffer and notes under its own lock. A texture is queued once per batch (`Batch::texture_due`), so no two threads check the same one. Read buffers are per-thread, and the remap guard is a shared lock. - The frame line's "textures" counts the time it took (wall clock), not the threads' sum. - Off by default; nothing changes without the switch. ### Measurements RTX 3090 Ti + Ryzen, Windows 11, diag build of this branch on 8dd30ab, retail title, Series X profile. One launch per configuration, average over the frames between the first world frame and the steady state: | configuration | frame time | "textures" | steady state after streaming | |---|---|---|---| | default | ≈1,030 ms | ≈330 ms | 4.1 fps | | `VICTORY_WIDE_TEXTURES=1` | ≈826 ms | ≈120 ms | 4.1–4.3 fps | | `VICTORY_TEXTURE_NO_WAIT=1` | ≈654 ms | ≈44 ms | 4.1–4.2 fps | | **both** | **≈518 ms** | **≈16 ms** | 4.0–4.2 fps | - With this switch alone, the remaining texture time is mostly waiting for the runtime's remap lock ("1,299 of 1,667 ms waiting for title memory to hold still" on the texture-refresh line). That's what `VICTORY_TEXTURE_NO_WAIT` addresses, and the two **complement** each other: together the slow phase runs at about twice the default frame rate. - No crash or device loss in any of the four runs. Live screen grabs of the combined run show the cutscene and the cell rendering normally; the only white frame is the cutscene's own fade-in. - `cargo test -p victory-gpu --lib batch`: 4 passed (1 ignored benchmark). `cargo clippy -p victory-gpu --all-targets`: no new warnings. If these numbers hold on other machines, both switches look like candidates to turn on by default. I've left that to you. AI-assisted (Claude Code, Claude Opus 5.5). No game data attached. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
While the world streams in, a submission checks hundreds of textures one
after another on the submitting thread: each is read, hashed whole and,
when it changed, detiled into its staging buffer. With the switch the
checks that come due in a batch are queued (Batch::textures_due) and run
at its next flush, before a step that writes title memory and before the
lists run, so their order against those steps is unchanged, on the
threads kept for the snapshots (shadow::wide_run). Each check reads its
texture's title memory and writes its own staging buffer and notes under
its own lock, and a texture is queued once per batch (texture_due), so no
two threads check the same texture. The frame line's "textures" counts
the time it took, not the threads' sum.

Measured on the opening cutscene and the first world minutes (RTX 3090
Ti, 8dd30ab, same binary, one launch each):

  default                        frame ~1,030 ms, textures ~330 ms
  VICTORY_WIDE_TEXTURES=1         frame   ~826 ms, textures ~120 ms
  VICTORY_TEXTURE_NO_WAIT=1       frame   ~654 ms, textures  ~44 ms
  both                           frame   ~518 ms, textures  ~16 ms

Steady state after streaming: 4.0-4.3 fps in all four.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With levels on demand, a texture's upload records a check (which detiles
into the staging buffer and notes the levels it holds) and then a host step
that maps the tiles for those levels. With VICTORY_WIDE_TEXTURES=1 the check
was queued until the next flush, so the host step ran first and mapped the
tiles of the levels an earlier check held (or none); the copies into tiles
left unmapped were dropped by the card: black or stale textures. A host step
now drains the queue first, which is the order without the switch.

Found, diagnosed and fixed on the pull request by grosterr (with a test) and
SkillIssueXO (from source review).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Extracts HostList::run_deferred's loop into HostList::run_steps(steps,
batch, wide) with no behavior change, and adds
host::batch::queued_textures_refresh_before_host_step to exercise
VICTORY_WIDE_TEXTURES ordering on real placed BC7 textures:
- single queued texture via texture::upload followed by a Step::Host;
- two queued textures before a Step::Host (the wide_run branch).

Fails without 4cb2bc6's refresh_textures() drain before Step::Host and
passes with it.

Co-Authored-By: Antigravity <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:50:42 +00:00
The parallel path adds each worker's duration to the shared texture
counter and later subtracts the difference from elapsed time. The
present thread can drain that counter between the read and the
subtraction, wrapping the unsigned counter and corrupting the frame
timings. Other batches can also contribute to that difference.

Count the bytes read by each worker and add the wall-clock duration
once when the batch finishes. This keeps timing additive across
present intervals without changing refresh ordering or the sequential
path.

Based-on: https://github.com/fxceless/victory-fork/pull/768
Tested-on: Fedora Linux 45, Wine 11.0 (Windows cross-build and four focused batch tests)
Assisted-by: gpt-6.2 sol xhigh
The fix itself was already here (4cb2bc6: queued texture checks are
drained before a host step); this brings the regression test that
observes the staged state inside the callback.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Author
Owner

@⁠SkillIssueXO on GitHub · 2026-11-25 13:15 UTC · original

I reviewed 19546dd on 0b0074e with Claude while preparing a Series X test. There is a submission-order dependency when VICTORY_LEVELS_ON_DEMAND=1 and VICTORY_WIDE_TEXTURES=1.

The texture upload path queues defer_texture(staging) followed by a host closure that passes staging.detiled to OnDemand::uploaded. That mask determines which mip tiles to back before the recorded texture copies run. Step::Host executes immediately, so with the queued refresh it can see the prior mask or zero. The later flush can detile the newly available levels after the tile-backing decision has already been made.

Flushing pending texture refreshes before Step::Host preserves that dependency and keeps buffer refresh ordering intact. I have staged this change locally. This finding is from source review. A matched runtime comparison is pending. No game data attached.

**@⁠SkillIssueXO** on GitHub · 2026-11-25 13:15 UTC · [original](https://github.com/fxceless/victory-fork/pull/768#issuecomment-7163527670) I reviewed `19546dd` on `0b0074e` with Claude while preparing a Series X test. There is a submission-order dependency when `VICTORY_LEVELS_ON_DEMAND=1` and `VICTORY_WIDE_TEXTURES=1`. The [texture upload path](https://github.com/fxceless/victory-fork/blob/0b0074e0b2765e574c622e9a3de566f20f04135b/crates/victory-gpu/src/texture.rs#L763-L784) queues `defer_texture(staging)` followed by a host closure that passes `staging.detiled` to `OnDemand::uploaded`. That mask determines which mip tiles to back before the recorded texture copies run. `Step::Host` executes immediately, so with the queued refresh it can see the prior mask or zero. The later flush can detile the newly available levels after the tile-backing decision has already been made. Flushing pending texture refreshes before `Step::Host` preserves that dependency and keeps buffer refresh ordering intact. I have staged this change locally. This finding is from source review. A matched runtime comparison is pending. No game data attached.
Author
Owner

@⁠grosterr on GitHub · 2026-11-25 13:25 UTC · original

Bug report with a fix: VICTORY_WIDE_TEXTURES=1 together with VICTORY_LEVELS_ON_DEMAND=1 leaves some textures black or stale, because a queued texture check runs after the host step that maps its tiles.

Setup: RTX 3060 12 GB (driver 621.40), Ryzen 7 5700X, 32 GB, Windows 11, release build. Tree: #770's stack d034ac1 (which carries this PR) + main a253706. AI-assisted (Claude Code); the runs and observations are mine.

A/B, same save, prologue bedroom:

run switches picture
F0 LEVELS_ON_DEMAND=1 EARLY_TEXTURES_MS=40 TEXTURE_NO_WAIT=1 WIDE_TEXTURES=1 white blotches over the blue table and stools, white patches on arms, a black towel, a black sheet of paper
F0w the same without WIDE_TEXTURES clean
F0x the same as F0, with the fix below clean

VICTORY_STAGING_POOL=0 did not change F0's picture, so the staging pool is not involved.

Cause. For a texture with levels on demand, texture::upload records two steps in a row (texture.rs, end of upload; line 704 on this PR's head):

  1. list.defer_texture(staging.clone()) → Step::Texture: the check that detiles into the staging buffer (and records which levels it holds);
  2. list.defer_host(...) → Step::Host: maps the tiles for those levels (on_demand.uploaded(...) with the levels just detiled).

With this PR, run_deferred no longer refreshes on Step::Texture but pushes it to batch.textures_due, which is drained at the next flush (before Step::Run, before copies, at the end). Step::Host does not flush. So step 2 runs before step 1: it sees no detiled levels or those of an earlier check, the tiles are not mapped (or mapped for the wrong levels), and the list's CopyTextureRegion into unmapped tiles is dropped by the card.

Fix (in HostList::run_deferred): drain the queue before a host step, which gives the same order as without the switch:

Step::Run(work) | Step::Host(work) => {
    if matches!(step, Step::Run(_)) {
        batch.title_written();
    } else if !batch.textures_due.is_empty() {
        // A host step may read what a queued texture check writes (levels on
        // demand map the levels `detile` has just held): the queue goes first,
        // in the order the steps were recorded, as without VICTORY_WIDE_TEXTURES.
        batch.refresh_textures();
    }
    work();
  • To test it, the loop body moved into fn run_steps(steps: &[Step], batch: &mut Batch, wide: bool), with run_deferred calling it with wide_textures().
  • The test queued_textures_refresh_before_host_step does the following:
    • makes real placed BC7 textures over committed memory;
    • records texture::upload followed by a host step that reads the texture-refresh byte counter;
    • runs the steps with wide = true;
    • covers one queued texture and two queued textures (the wide_run branch).
  • It fails without the fix ("saw 0 bytes, expected >= 16384") and passes with it.
  • Without WIDE_TEXTURES nothing changes: the queue is always empty then.

I have it as a commit with the test and can open it as a PR against this branch or against main, whichever you prefer. F0x (10 minutes): no device loss; steady 330 ms a frame (3.0 fps, p90 380 ms) on this card, against 380 ms (p90 479 ms) for F0 with the broken textures.

**@⁠grosterr** on GitHub · 2026-11-25 13:25 UTC · [original](https://github.com/fxceless/victory-fork/pull/768#issuecomment-7163763533) Bug report with a fix: **`VICTORY_WIDE_TEXTURES=1` together with `VICTORY_LEVELS_ON_DEMAND=1` leaves some textures black or stale**, because a queued texture check runs after the host step that maps its tiles. **Setup:** RTX 3060 12 GB (driver 621.40), Ryzen 7 5700X, 32 GB, Windows 11, release build. Tree: #770's stack `d034ac1` (which carries this PR) + main `a253706`. AI-assisted (Claude Code); the runs and observations are mine. **A/B, same save, prologue bedroom:** | run | switches | picture | |---|---|---| | F0 | `LEVELS_ON_DEMAND=1 EARLY_TEXTURES_MS=40 TEXTURE_NO_WAIT=1 WIDE_TEXTURES=1` | white blotches over the blue table and stools, white patches on arms, a black towel, a black sheet of paper | | F0w | the same without `WIDE_TEXTURES` | clean | | F0x | the same as F0, with the fix below | clean | `VICTORY_STAGING_POOL=0` did not change F0's picture, so the staging pool is not involved. **Cause.** For a texture with levels on demand, `texture::upload` records two steps in a row (`texture.rs`, end of `upload`; line 704 on this PR's head): 1. `list.defer_texture(staging.clone())` → `Step::Texture`: the check that detiles into the staging buffer (and records which levels it holds); 2. `list.defer_host(...)` → `Step::Host`: maps the tiles for those levels (`on_demand.uploaded(...)` with the levels just detiled). With this PR, `run_deferred` no longer refreshes on `Step::Texture` but pushes it to `batch.textures_due`, which is drained at the next flush (before `Step::Run`, before copies, at the end). `Step::Host` does not flush. So step 2 runs **before** step 1: it sees no detiled levels or those of an earlier check, the tiles are not mapped (or mapped for the wrong levels), and the list's `CopyTextureRegion` into unmapped tiles is dropped by the card. **Fix** (in `HostList::run_deferred`): drain the queue before a host step, which gives the same order as without the switch: ```rust Step::Run(work) | Step::Host(work) => { if matches!(step, Step::Run(_)) { batch.title_written(); } else if !batch.textures_due.is_empty() { // A host step may read what a queued texture check writes (levels on // demand map the levels `detile` has just held): the queue goes first, // in the order the steps were recorded, as without VICTORY_WIDE_TEXTURES. batch.refresh_textures(); } work(); ``` - To test it, the loop body moved into `fn run_steps(steps: &[Step], batch: &mut Batch, wide: bool)`, with `run_deferred` calling it with `wide_textures()`. - The test `queued_textures_refresh_before_host_step` does the following: - makes real placed BC7 textures over committed memory; - records `texture::upload` followed by a host step that reads the texture-refresh byte counter; - runs the steps with `wide = true`; - covers one queued texture and two queued textures (the `wide_run` branch). - It fails without the fix ("saw 0 bytes, expected >= 16384") and passes with it. - Without `WIDE_TEXTURES` nothing changes: the queue is always empty then. I have it as a commit with the test and can open it as a PR against this branch or against main, whichever you prefer. F0x (10 minutes): no device loss; steady 330 ms a frame (3.0 fps, p90 380 ms) on this card, against 380 ms (p90 479 ms) for F0 with the broken textures.
Author
Owner

@⁠tikD1337 on GitHub · 2026-11-25 13:41 UTC · original

We tried an almost identical change before seeing this PR (texture refreshes due in a row queued and run on shadow::wide_run, wall-clock accounting), and on our machine it measured worse and showed artifacts. Sharing in case it helps, with the caveats below.

Setup: RTX 4070 Ti SUPER (driver 621.01), Ryzen 5 7600 (6 cores / 12 threads), 32 GB, Windows 11. Base 2119b0e + a803c87, plus a local patch of ours that hashed recently changed view-memory textures every frame, with 9 pipeline workers. Release build, warm cache, VICTORY_RELAY=2 VICTORY_WIDE_REFRESH=1. Opening cutscene, one launch per configuration, medians over frames with more than 1000 draws:

switch off switch on
frame 554 ms 971 ms
"textures" 157 ms 347 ms
texture MB / frame 118 294
dropped draws 410 482

With the switch on, the player saw texture artifacts that did not appear without it: a character's face turning black, hair drawn in the wrong place, a building missing near the end of the cutscene.

Caveats: an older base than yours, our own texture-hash patch on top (its "hash every check while recently changed" rule may interact with the queueing), and a 6-core CPU that was also running 9 pipeline workers. We did not find the cause. The write-watch journal is a global mutex, so per-thread state is not it. The texture MB per frame rising 2.5× suggests more textures were re-read with the switch on. It might be worth checking that metric on your side too.

**@⁠tikD1337** on GitHub · 2026-11-25 13:41 UTC · [original](https://github.com/fxceless/victory-fork/pull/768#issuecomment-7164143961) We tried an almost identical change before seeing this PR (texture refreshes due in a row queued and run on `shadow::wide_run`, wall-clock accounting), and on our machine it measured **worse and showed artifacts**. Sharing in case it helps, with the caveats below. Setup: RTX 4070 Ti SUPER (driver 621.01), Ryzen 5 7600 (6 cores / 12 threads), 32 GB, Windows 11. Base `2119b0e` + `a803c87`, plus a local patch of ours that hashed recently changed view-memory textures every frame, with 9 pipeline workers. Release build, warm cache, `VICTORY_RELAY=2 VICTORY_WIDE_REFRESH=1`. Opening cutscene, one launch per configuration, medians over frames with more than 1000 draws: | | switch off | switch on | |---|---|---| | frame | 554 ms | 971 ms | | "textures" | 157 ms | 347 ms | | texture MB / frame | 118 | 294 | | dropped draws | 410 | 482 | With the switch on, the player saw texture artifacts that did not appear without it: a character's face turning black, hair drawn in the wrong place, a building missing near the end of the cutscene. Caveats: an older base than yours, our own texture-hash patch on top (its "hash every check while recently changed" rule may interact with the queueing), and a 6-core CPU that was also running 9 pipeline workers. We did not find the cause. The write-watch journal is a global mutex, so per-thread state is not it. The texture MB per frame rising 2.5× suggests more textures were re-read with the switch on. It might be worth checking that metric on your side too.
Author
Owner

@⁠KyleS98 on GitHub · 2026-11-25 18:09 UTC · original

Thanks @⁠grosterr and @⁠SkillIssueXO, that's a real ordering bug and your diagnosis is right: the host step that maps the tiles ran before the queued check that records which levels it detiled.

I've pushed your fix as 4cb2bc6: run_deferred drains textures_due before a Step::Host, so with VICTORY_WIDE_TEXTURES=1 the steps run in recorded order, as they do without the switch. I didn't take the run_steps split or the test. @⁠grosterr, if you'd like your test in, a PR against perf/wide-texture-refresh is welcome and I'll merge it.

Checked on an RTX 3090 Ti with your F0 switches (LEVELS_ON_DEMAND=1 EARLY_TEXTURES_MS=40 TEXTURE_NO_WAIT=1 WIDE_TEXTURES=1), Series X profile, warm cache, one 7-minute run from boot into the cell:

  • The loading screens, the opening cutscene and the cell all came out clean. There were no white blotches and no black or stale textures in any grab.
  • It settled at 4.3 fps (233 ms a frame) in the cell. This was only one run, so I'm not making a timing claim.

@⁠tikD1337, thanks for the numbers. Your setup differs in ways that matter here (a per-frame texture-hash patch of your own and 9 pipeline workers on 6 cores), so I can't tell from it whether the queue itself costs time on your machine. The bug above could also explain the black face you saw. If you try again on 4cb2bc6 without your hash patch, the "texture MB / frame" line with and without the switch would show whether more textures get re-read.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠KyleS98** on GitHub · 2026-11-25 18:09 UTC · [original](https://github.com/fxceless/victory-fork/pull/768#issuecomment-7170512496) Thanks @⁠grosterr and @⁠SkillIssueXO, that's a real ordering bug and your diagnosis is right: the host step that maps the tiles ran before the queued check that records which levels it detiled. I've pushed your fix as `4cb2bc6`: `run_deferred` drains `textures_due` before a `Step::Host`, so with `VICTORY_WIDE_TEXTURES=1` the steps run in recorded order, as they do without the switch. I didn't take the `run_steps` split or the test. @⁠grosterr, if you'd like your test in, a PR against `perf/wide-texture-refresh` is welcome and I'll merge it. Checked on an RTX 3090 Ti with your F0 switches (`LEVELS_ON_DEMAND=1 EARLY_TEXTURES_MS=40 TEXTURE_NO_WAIT=1 WIDE_TEXTURES=1`), Series X profile, warm cache, one 7-minute run from boot into the cell: - The loading screens, the opening cutscene and the cell all came out clean. There were no white blotches and no black or stale textures in any grab. - It settled at 4.3 fps (233 ms a frame) in the cell. This was only one run, so I'm not making a timing claim. @⁠tikD1337, thanks for the numbers. Your setup differs in ways that matter here (a per-frame texture-hash patch of your own and 9 pipeline workers on 6 cores), so I can't tell from it whether the queue itself costs time on your machine. The bug above could also explain the black face you saw. If you try again on `4cb2bc6` without your hash patch, the "texture MB / frame" line with and without the switch would show whether more textures get re-read. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠Ahmet-Dedeler on GitHub · 2026-11-25 18:46 UTC · original

Numbers from a very different host, since tikD1337 saw it get worse. I tried nearly the same idea on an M5 Max under CrossOver + D3DMetal (all CPU work goes through Wine and Rosetta): one job per due texture on shadow::wide_run, 8 workers, pending jobs flushed before every step that writes title memory. One run against a baseline run with the same switches, frame lines from 120-330 s of the opening:

  • textures per frame, median: 384 -> 48 ms (mean 408 -> 55)
  • whole frame, median: 1216 -> 1155 ms (-5%), mean slightly up, so basically no change
  • copies got about 40% slower per MB (0.51 -> 0.73 ms/MB, same ~210 MB), probably memory bandwidth with 8 workers hashing and detiling at the same time

No visual problems in the captured frames. So on this host it takes the texture time out of the way, but the frame is limited by something else. Copy-back and GPU time went up in the same window (+152 and +46 ms median), though those are noisy with two different playthroughs and one run each.

**@⁠Ahmet-Dedeler** on GitHub · 2026-11-25 18:46 UTC · [original](https://github.com/fxceless/victory-fork/pull/768#issuecomment-7171381753) Numbers from a very different host, since tikD1337 saw it get worse. I tried nearly the same idea on an M5 Max under CrossOver + D3DMetal (all CPU work goes through Wine and Rosetta): one job per due texture on `shadow::wide_run`, 8 workers, pending jobs flushed before every step that writes title memory. One run against a baseline run with the same switches, frame lines from 120-330 s of the opening: - textures per frame, median: 384 -> 48 ms (mean 408 -> 55) - whole frame, median: 1216 -> 1155 ms (-5%), mean slightly up, so basically no change - copies got about 40% slower per MB (0.51 -> 0.73 ms/MB, same ~210 MB), probably memory bandwidth with 8 workers hashing and detiling at the same time No visual problems in the captured frames. So on this host it takes the texture time out of the way, but the frame is limited by something else. Copy-back and GPU time went up in the same window (+152 and +46 ms median), though those are noisy with two different playthroughs and one run each.
Author
Owner

@⁠tikD1337 on GitHub · 2026-11-25 20:51 UTC · original

Re-tested on your head 4cb2bc6, merged onto origin/main d510ee4 with no local patches of ours.

  • Machine: native Windows 11, RTX 4070 Ti SUPER (driver 621.01), Ryzen 5 7600, Series X profile.
  • Build and run: diagnostics build, warm cache. A scripted run: menus, the opening cutscene, then about 60 s standing in the prison after control is handed over.
  • Switches: ASYNC_SUBMIT QUEUE2 TEXTURE_NO_WAIT WIDE_REFRESH JOIN_PARTS BACK_OWN_VIEW.
  • Runs: one run with VICTORY_WIDE_TEXTURES=1 and one without. VICTORY_LEVELS_ON_DEMAND was never set, here or in our earlier test.

Means of the frame line's readings (world readings only, more than 1,000 draws a frame); median frame from the frame log's per-frame times:

WIDE_TEXTURES=1 off
cutscene: textures 40.0 ms, 128.8 MB/frame 27.9 ms, 87.4 MB/frame
cutscene: copies 43.1 ms, 155 MB 42.5 ms, 144 MB
cutscene: GPU 44.0 ms 49.5 ms
cutscene: median / mean frame 94 / 623 ms 142 / 430 ms
prison, standing: textures 5.5 ms, 19.0 MB/frame 5.8 ms, 19.7 MB/frame
prison: median frame 172 ms 176 ms
dropped draws/frame (cutscene / prison) 680 / 347 630 / 347
  • Texture traffic: with the switch it is up about 47% in the cutscene and 38% over the world. In the static prison scene it is the same.
  • Frame time: the cutscene's median frame is better, but its mean is worse. The run with the switch had a loading stall of about a minute in the middle of the cutscene. The first launch with the switch loaded so badly that I stopped it; its partial cutscene had 72.5 MB/frame of textures.
  • Picture: prison frames match the run without the switch (picture difference 1.4–1.6, same as run-to-run noise), about 1 unit darker on a 0–255 scale. No black faces in either run. The café looked darker by eye with the switch, but the café building also popped in and out without it, so that is not a measured difference.

Since VICTORY_LEVELS_ON_DEMAND was never on in our runs, the Step::Host ordering bug fixed in 4cb2bc6 cannot explain the black face we reported earlier. One run each, so treat the frame times as indicative only.

**@⁠tikD1337** on GitHub · 2026-11-25 20:51 UTC · [original](https://github.com/fxceless/victory-fork/pull/768#issuecomment-7174278104) Re-tested on your head 4cb2bc6, merged onto `origin/main` d510ee4 with no local patches of ours. - **Machine:** native Windows 11, RTX 4070 Ti SUPER (driver 621.01), Ryzen 5 7600, Series X profile. - **Build and run:** diagnostics build, warm cache. A scripted run: menus, the opening cutscene, then about 60 s standing in the prison after control is handed over. - **Switches:** `ASYNC_SUBMIT QUEUE2 TEXTURE_NO_WAIT WIDE_REFRESH JOIN_PARTS BACK_OWN_VIEW`. - **Runs:** one run with `VICTORY_WIDE_TEXTURES=1` and one without. `VICTORY_LEVELS_ON_DEMAND` was never set, here or in our earlier test. Means of the frame line's readings (world readings only, more than 1,000 draws a frame); median frame from the frame log's per-frame times: | | `WIDE_TEXTURES=1` | off | |---|---|---| | **cutscene:** textures | 40.0 ms, 128.8 MB/frame | 27.9 ms, 87.4 MB/frame | | cutscene: copies | 43.1 ms, 155 MB | 42.5 ms, 144 MB | | cutscene: GPU | 44.0 ms | 49.5 ms | | cutscene: median / mean frame | 94 / 623 ms | 142 / 430 ms | | **prison, standing:** textures | 5.5 ms, 19.0 MB/frame | 5.8 ms, 19.7 MB/frame | | prison: median frame | 172 ms | 176 ms | | dropped draws/frame (cutscene / prison) | 680 / 347 | 630 / 347 | - **Texture traffic:** with the switch it is up about 47% in the cutscene and 38% over the world. In the static prison scene it is the same. - **Frame time:** the cutscene's median frame is better, but its mean is worse. The run with the switch had a loading stall of about a minute in the middle of the cutscene. The first launch with the switch loaded so badly that I stopped it; its partial cutscene had 72.5 MB/frame of textures. - **Picture:** prison frames match the run without the switch (picture difference 1.4–1.6, same as run-to-run noise), about 1 unit darker on a 0–255 scale. No black faces in either run. The café looked darker by eye with the switch, but the café building also popped in and out without it, so that is not a measured difference. Since `VICTORY_LEVELS_ON_DEMAND` was never on in our runs, the `Step::Host` ordering bug fixed in 4cb2bc6 cannot explain the black face we reported earlier. One run each, so treat the frame times as indicative only.
Author
Owner

@⁠KyleS98 on GitHub · 2026-11-26 01:27 UTC · original

@⁠grosterr your regression test is merged into this branch (b842aa5, from your PR against my fork). queued_textures_refresh_before_host_step passes here on the RTX 3090 Ti, and it carries the run_steps split it needs. Thanks for following through on it.

AI-assisted (Claude Code, Claude Fable 5.2).

**@⁠KyleS98** on GitHub · 2026-11-26 01:27 UTC · [original](https://github.com/fxceless/victory-fork/pull/768#issuecomment-7179799266) @⁠grosterr your regression test is merged into this branch (`b842aa5`, from your PR against my fork). `queued_textures_refresh_before_host_step` passes here on the RTX 3090 Ti, and it carries the `run_steps` split it needs. Thanks for following through on it. AI-assisted (Claude Code, Claude Fable 5.2).
Author
Owner

@⁠KyleS98 on GitHub · 2026-11-26 07:11 UTC · original

@⁠DoubleD17 you are right: the workers added their own time to the shared counter and the batch subtracted the excess afterwards, so a drain between the two could wrap it. @⁠gmankab had sent the fix against my fork and it is merged here (7521f3a): the workers only count bytes now, and the batch adds its wall-clock time once after wide_run returns. Nothing is subtracted any more.

Also merged: @⁠Lilith133T's regression test host_callback_sees_the_preceding_texture_refresh (the fix it guards was already here as 4cb2bc6). The branch is merged up to main 46bf535; head is 4c234f4.

Checked on an RTX 3090 Ti: both ordering tests pass with VICTORY_WIDE_TEXTURES=1, and a 270 s Series S run with the switch, from boot into the prologue, ended without a crash or device loss.

@⁠tikD1337 thanks for running it again without your patches. I cannot explain the extra texture megabytes you measured in the cutscene (+47%): the queue should refresh the same textures as before, only on other threads. Until that is understood this should stay what it is, an opt-in switch, and I am not claiming a frame-time gain from it on other machines. Agreed too that the host-step ordering cannot be behind the black face you saw, since levels on demand were off in your runs.

AI-assisted (Claude Code, Claude Fable 5.2).

**@⁠KyleS98** on GitHub · 2026-11-26 07:11 UTC · [original](https://github.com/fxceless/victory-fork/pull/768#issuecomment-7185183747) @⁠DoubleD17 you are right: the workers added their own time to the shared counter and the batch subtracted the excess afterwards, so a drain between the two could wrap it. @⁠gmankab had sent the fix against my fork and it is merged here (`7521f3a`): the workers only count bytes now, and the batch adds its wall-clock time once after `wide_run` returns. Nothing is subtracted any more. Also merged: @⁠Lilith133T's regression test `host_callback_sees_the_preceding_texture_refresh` (the fix it guards was already here as `4cb2bc6`). The branch is merged up to `main` `46bf535`; head is `4c234f4`. Checked on an RTX 3090 Ti: both ordering tests pass with `VICTORY_WIDE_TEXTURES=1`, and a 270 s Series S run with the switch, from boot into the prologue, ended without a crash or device loss. @⁠tikD1337 thanks for running it again without your patches. I cannot explain the extra texture megabytes you measured in the cutscene (+47%): the queue should refresh the same textures as before, only on other threads. Until that is understood this should stay what it is, an opt-in switch, and I am not claiming a frame-time gain from it on other machines. Agreed too that the host-step ordering cannot be behind the black face you saw, since levels on demand were off in your runs. AI-assisted (Claude Code, Claude Fable 5.2).
Author
Owner

@⁠DoubleD17 on GitHub · 2026-11-25 20:50 UTC · original · reviewed

The new wall-clock accounting can wrap the frame's texture-time counter. In Batch::refresh_textures, the workers add their individual durations to PREPARING[2], and the submission later subtracts the excess after loading the sum. The presenter's meter independently drains this same atomic with swap(0). If the drain lands between the final load and fetch_sub, the latter subtracts a positive correction from the reset counter and can wrap u64. The saturating_sub bounds the correction, while the atomic subtraction still wraps. This can corrupt the textures metric used to assess this PR. Batch accounting ┬╖ Frame counter drain

Please keep the worker timing out of the shared texture-time counter and add one elapsed wall-clock contribution after wide_run joins. The worker jobs can still report bytes separately. This is a static review of 4cb2bc6631d6691a8d511839c0ba4f99e229115a. No runtime timing was measured. Per-texture accounting

AI-assisted.

**@⁠DoubleD17** on GitHub · 2026-11-25 20:50 UTC · [original](https://github.com/fxceless/victory-fork/pull/768#pullrequestreview-6064808416) · **reviewed** The new wall-clock accounting can wrap the frame's texture-time counter. In `Batch::refresh_textures`, the workers add their individual durations to `PREPARING[2]`, and the submission later subtracts the excess after loading the sum. The presenter's meter independently drains this same atomic with `swap(0)`. If the drain lands between the final load and `fetch_sub`, the latter subtracts a positive correction from the reset counter and can wrap `u64`. The `saturating_sub` bounds the correction, while the atomic subtraction still wraps. This can corrupt the `textures` metric used to assess this PR. [Batch accounting](https://github.com/fxceless/victory-fork/blob/4cb2bc6631d6691a8d511839c0ba4f99e229115a/crates/victory-gpu/src/host.rs#L5423-L5443) ┬╖ [Frame counter drain](https://github.com/fxceless/victory-fork/blob/4cb2bc6631d6691a8d511839c0ba4f99e229115a/crates/victory-gpu/src/host.rs#L5846-L5853) Please keep the worker timing out of the shared texture-time counter and add one elapsed wall-clock contribution after `wide_run` joins. The worker jobs can still report bytes separately. This is a static review of `4cb2bc6631d6691a8d511839c0ba4f99e229115a`. No runtime timing was measured. [Per-texture accounting](https://github.com/fxceless/victory-fork/blob/4cb2bc6631d6691a8d511839c0ba4f99e229115a/crates/victory-gpu/src/texture.rs#L898-L907) AI-assisted.
Author
Owner

@⁠KyleS98 on GitHub · 2026-11-26 09:03 UTC · original

A correction to my comment above: the 270 s game run I cited there was made with a stale binary that did not contain this branch (several worktrees of mine share one build folder, and the last one built did not relink). The two unit tests were real. I have repeated the game run with a binary checked to be head 4c234f4 (RTX 3090 Ti, Series S profile, VICTORY_WIDE_TEXTURES=1, 290 s from boot into the prologue): it ran to the end, no crash, no device loss. The Series S world is black in that run as it is on plain main without #798, so this run says nothing about the picture.

AI-assisted (Claude Code, Claude Fable 5.2).

**@⁠KyleS98** on GitHub · 2026-11-26 09:03 UTC · [original](https://github.com/fxceless/victory-fork/pull/768#issuecomment-7187353394) A correction to my comment above: the 270 s game run I cited there was made with a stale binary that did not contain this branch (several worktrees of mine share one build folder, and the last one built did not relink). The two unit tests were real. I have repeated the game run with a binary checked to be head `4c234f4` (RTX 3090 Ti, Series S profile, `VICTORY_WIDE_TEXTURES=1`, 290 s from boot into the prologue): it ran to the end, no crash, no device loss. The Series S world is black in that run as it is on plain `main` without #798, so this run says nothing about the picture. AI-assisted (Claude Code, Claude Fable 5.2).
Author
Owner

@⁠tikD1337 on GitHub · 2026-11-26 10:11 UTC · original

Re-tested your head 4c234f4 (it contains main 46bf535). It is a fresh build folder, and I checked that the exe is built from that commit.

  • Machine: native Windows 11, RTX 4070 Ti SUPER (driver 621.01), Ryzen 5 7600, Series X profile, warm cache.
  • Switches: the same as before, ASYNC_SUBMIT QUEUE2 TEXTURE_NO_WAIT WIDE_REFRESH JOIN_PARTS BACK_OWN_VIEW, nothing else, no LEVELS_ON_DEMAND.
  • Runs: 3 runs with VICTORY_WIDE_TEXTURES=1 and 3 without, alternating: menus, the opening cutscene, then about 40 s standing in the prison.

The +47% was mostly my averaging, sorry. I had averaged the frame line's per-reading "MB/frame" over 5 s readings without weighting, so a reading of a few stalled frames counted as much as one of many fast frames. Weighted by frames (total MB over total frames):

with the switch without
cutscene textures 40.8 MB/frame, 15.0 ms 38.8 MB/frame, 12.9 ms
prison textures 20.6 MB/frame 19.5 MB/frame
cutscene median frame 145 ms 161 ms
cutscene mean frame 249 ms 253 ms
prison median frame 172 ms 171 ms
  • Cutscene, per run: with the switch 33.4 / 50.0 / 38.9 MB/frame, without 39.4 / 36.6 / 40.5.
  • The median frame is better with the switch in all 3 pairs.
  • Recounted the same way, last night's pair is +13%, not +47%.

Where the texture bytes come from. I added counters by branch of refresh_timed (diagnostics only, one run each way):

  • The biggest share is refresh_unlocked: with TEXTURE_NO_WAIT=1, a check that meets the runtime remapping reads the whole texture through the kernel, and on failure it forgets its writes. That is 25.0 MB/frame with the queue vs 20.5 without in the cutscene. In the prison the queued checks hit remap windows that the inline ones did not: 6.9 vs 0.0 MB/frame.
  • About 10.5 MB a frame are textures read again within the same frame, in both modes: Batch::textures is cleared at each title write and each batch. So it is not something the queue adds.
  • In the cutscene the counted totals are equal, 34.8 vs 34.1 MB/frame.

Picture. Face faults show up with the switch and without it, and are not caused by #768:

  • in both modes: the waitress's face as multicoloured garbage in the café;
  • without the switch: Lucia's facial skin black in one run, garbage patches on her neck in another.

Prison frames match between the modes within run-to-run noise.

So on this machine VICTORY_WIDE_TEXTURES=1 gives a somewhat better cutscene median frame and about the same traffic. Keeping it opt-in seems right. refresh_unlocked, which reads whole textures through the kernel, is worth a look, independently of this PR.

**@⁠tikD1337** on GitHub · 2026-11-26 10:11 UTC · [original](https://github.com/fxceless/victory-fork/pull/768#issuecomment-7189033195) Re-tested your head 4c234f4 (it contains main 46bf535). It is a fresh build folder, and I checked that the exe is built from that commit. - **Machine:** native Windows 11, RTX 4070 Ti SUPER (driver 621.01), Ryzen 5 7600, Series X profile, warm cache. - **Switches:** the same as before, `ASYNC_SUBMIT QUEUE2 TEXTURE_NO_WAIT WIDE_REFRESH JOIN_PARTS BACK_OWN_VIEW`, nothing else, no `LEVELS_ON_DEMAND`. - **Runs:** 3 runs with `VICTORY_WIDE_TEXTURES=1` and 3 without, alternating: menus, the opening cutscene, then about 40 s standing in the prison. **The +47% was mostly my averaging, sorry.** I had averaged the frame line's per-reading "MB/frame" over 5 s readings without weighting, so a reading of a few stalled frames counted as much as one of many fast frames. Weighted by frames (total MB over total frames): | | with the switch | without | |---|---|---| | cutscene textures | 40.8 MB/frame, 15.0 ms | 38.8 MB/frame, 12.9 ms | | prison textures | 20.6 MB/frame | 19.5 MB/frame | | cutscene median frame | 145 ms | 161 ms | | cutscene mean frame | 249 ms | 253 ms | | prison median frame | 172 ms | 171 ms | - **Cutscene, per run:** with the switch 33.4 / 50.0 / 38.9 MB/frame, without 39.4 / 36.6 / 40.5. - **The median frame is better with the switch** in all 3 pairs. - **Recounted the same way,** last night's pair is +13%, not +47%. **Where the texture bytes come from.** I added counters by branch of `refresh_timed` (diagnostics only, one run each way): - **The biggest share is `refresh_unlocked`:** with `TEXTURE_NO_WAIT=1`, a check that meets the runtime remapping reads the whole texture through the kernel, and on failure it forgets its writes. That is 25.0 MB/frame with the queue vs 20.5 without in the cutscene. In the prison the queued checks hit remap windows that the inline ones did not: 6.9 vs 0.0 MB/frame. - **About 10.5 MB a frame are textures read again within the same frame,** in both modes: `Batch::textures` is cleared at each title write and each batch. So it is not something the queue adds. - **In the cutscene the counted totals are equal,** 34.8 vs 34.1 MB/frame. **Picture.** Face faults show up with the switch and without it, and are not caused by #768: - **in both modes:** the waitress's face as multicoloured garbage in the café; - **without the switch:** Lucia's facial skin black in one run, garbage patches on her neck in another. Prison frames match between the modes within run-to-run noise. So on this machine `VICTORY_WIDE_TEXTURES=1` gives a somewhat better cutscene median frame and about the same traffic. Keeping it opt-in seems right. `refresh_unlocked`, which reads whole textures through the kernel, is worth a look, independently of this PR.
This pull request has changes conflicting with the target branch.
  • crates/victory-gpu/src/host.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/768/head:github-bot/gh-768'
git switch 'github-bot/gh-768'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-768'
git switch 'github-bot/gh-768'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-768'
git switch 'github-bot/gh-768'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-768'
git switch 'main'
git merge --squash 'github-bot/gh-768'
git switch 'main'
git merge --ff-only 'github-bot/gh-768'
git switch 'main'
git merge 'github-bot/gh-768'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.