Skip to content

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

Open
KyleS98 wants to merge 8 commits into
fxceless:mainfrom
KyleS98:perf/wide-texture-refresh
Open

KyleS98 wants to merge 8 commits into
fxceless:mainfrom
KyleS98:perf/wide-texture-refresh

Conversation

@KyleS98

@KyleS98 KyleS98 commented Nov 25, 2026

Copy link
Copy Markdown

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

…E_TEXTURES=1)

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 <noreply@anthropic.com>
KyleS98 added a commit to KyleS98/VIctory-Neo that referenced this pull request Nov 25, 2026
…0 turns each off)

Measured together on the opening cutscene and first world minutes: ~518 ms a frame against ~1,030 by default (textures ~16 ms against ~330), steady state unchanged (fxceless/victory-fork#768).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017rHNfuPpCyeMjHxWTEyhiQ
oceansde012 pushed a commit to oceansde012/victory-gta6 that referenced this pull request Nov 25, 2026
…E_TEXTURES=1)

Upstream: fxceless#768 (opt-in)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FLuVRkAEvF29hMbrBJw8os
oceansde012 pushed a commit to oceansde012/victory-gta6 that referenced this pull request Nov 25, 2026
…E_TEXTURES=1)

Upstream: fxceless#768 (opt-in)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FLuVRkAEvF29hMbrBJw8os
(cherry picked from commit c308a49)
oceansde012 pushed a commit to oceansde012/victory-gta6 that referenced this pull request Nov 25, 2026
…E_TEXTURES=1)

Upstream: fxceless#768 (opt-in)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FLuVRkAEvF29hMbrBJw8os
(cherry picked from commit c308a49)
(cherry picked from commit ef79c7b)
@KyleS98
KyleS98 force-pushed the perf/wide-texture-refresh branch from f51aae3 to 19546dd Compare November 25, 2026 08:47
KyleS98 added a commit to KyleS98/VIctory-Neo that referenced this pull request Nov 25, 2026
…0 turns each off)

Measured together on the opening cutscene and first world minutes: ~518 ms a frame against ~1,030 by default (textures ~16 ms against ~330), steady state unchanged (fxceless/victory-fork#768).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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: fxceless#768
Tested-on: Fedora Linux 45, Wine 11.0 (Windows cross-build and four focused batch tests)
Assisted-by: gpt-6.2 sol xhigh
ExoCalibra added a commit to ExoCalibra/victory-exo that referenced this pull request Nov 25, 2026
gmankab added a commit to gmankab/victory that referenced this pull request Nov 25, 2026
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: fxceless/victory-fork#768
Tested-on: Fedora Linux 45, Wine 11.0 (Windows cross-build and four focused batch tests)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 25, 2026
Parallel texture checks may leave a refresh queued when a prelude
reads the upload's dirty flag. If an earlier submission cleared
that flag, the prelude can skip the GPU copy and use the old
texture for this submission.

Drain queued texture refreshes before examining prelude uploads.
Verify that a host callback observes the dirty staging buffer and
that the GPU sees a title write in the same submission.

Based-on: fxceless/victory-fork#768
Based-on: KyleS98/victory-fork#1
Tested-on: AMD Radeon RX 6800, Fedora Linux 45, Wine 11.0 with vkd3d-proton (both texture tests with VICTORY_WIDE_TEXTURES=1)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 25, 2026
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: fxceless/victory-fork#768
Tested-on: Fedora Linux 45, Wine 11.0 (Windows cross-build and four focused batch tests)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 25, 2026
Parallel texture checks may leave a refresh queued when a prelude
reads the upload's dirty flag. If an earlier submission cleared
that flag, the prelude can skip the GPU copy and use the old
texture for this submission.

Drain queued texture refreshes before examining prelude uploads.
Verify that a host callback observes the dirty staging buffer and
that the GPU sees a title write in the same submission.

Based-on: fxceless/victory-fork#768
Based-on: KyleS98/victory-fork#1
Tested-on: AMD Radeon RX 6800, Fedora Linux 45, Wine 11.0 with vkd3d-proton (both texture tests with VICTORY_WIDE_TEXTURES=1)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 25, 2026
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: fxceless/victory-fork#768
Tested-on: Fedora Linux 45, Wine 11.0 (Windows cross-build and four focused batch tests)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 25, 2026
Parallel texture checks may leave a refresh queued when a prelude
reads the upload's dirty flag. If an earlier submission cleared
that flag, the prelude can skip the GPU copy and use the old
texture for this submission.

Drain queued texture refreshes before examining prelude uploads.
Verify that a host callback observes the dirty staging buffer and
that the GPU sees a title write in the same submission.

Based-on: fxceless/victory-fork#768
Based-on: KyleS98/victory-fork#1
Tested-on: AMD Radeon RX 6800, Fedora Linux 45, Wine 11.0 with vkd3d-proton (both texture tests with VICTORY_WIDE_TEXTURES=1)
Assisted-by: gpt-6.2 sol xhigh
@SkillIssueXO

Copy link
Copy Markdown

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.

@grosterr

Copy link
Copy Markdown

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.

@tikD1337

Copy link
Copy Markdown

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.

AlexMiu2083 added a commit to AlexMiu2083/victory-MBT that referenced this pull request Nov 25, 2026
…r runs across the cursor, snapshots flushed before a copy goes, changed runs reused, texture checks side by side, the card-copy census and its write-combining experiment

From fxceless/victory-fork's open pull requests:

- fxceless#911 (douline): a constant buffer view is at most 64 KiB; the title names
  larger ones and NVIDIA removes the device for them.
- fxceless#932 (avt0m4t48): the search for free dynamic descriptor slots finds a run
  that lies across its starting point.
- fxceless#936 (faycalbaklouti): queued snapshots are taken before a host copy is
  dropped (a use after free); its test's imports added for this tree.
- fxceless#925 (alpz1000): changed-byte runs are found into one buffer reused across
  pages, the merge gap joined in the same pass.
- fxceless#768 (KyleS98): a submission's texture checks run several at a time
  (`VICTORY_WIDE_TEXTURES=1`, off by default).
- fxceless#868 (Chipsraine): a census of the card copies (`VICTORY_CENSUS=1`) and an
  EXPERIMENT, off by default: `VICTORY_SKIP_WC_COMPARE=1` leaves copies of
  write-combining title memory out of the compare and the copy-back. Here
  (RTX 4070, first gameplay scene) it took the median from 213 to 186 ms a
  frame, best 150 ms; not exact (the title must never read that memory
  after the card wrote it).

With them gameplay went from a median of 233 to 213 ms a frame here.

Tried and left off: `VICTORY_CARD_REHASH_RUNS=1` (1,735 passes a frame
joined to about 220, no gain).

victory-gpu: 174 tests pass (`inplace::...shows_its_bytes_at_its_offset`
fails now and then, as before these); victory-hle: 99 pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gmankab added a commit to gmankab/victory that referenced this pull request Nov 25, 2026
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: fxceless/victory-fork#768
Tested-on: Fedora Linux 45, Wine 11.0 (Windows cross-build and four focused batch tests)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 25, 2026
Parallel texture checks may leave a refresh queued when a prelude
reads the upload's dirty flag. If an earlier submission cleared
that flag, the prelude can skip the GPU copy and use the old
texture for this submission.

Drain queued texture refreshes before examining prelude uploads.
Verify that a host callback observes the dirty staging buffer and
that the GPU sees a title write in the same submission.

Based-on: fxceless/victory-fork#768
Based-on: KyleS98/victory-fork#1
Tested-on: AMD Radeon RX 6800, Fedora Linux 45, Wine 11.0 with vkd3d-proton (both texture tests with VICTORY_WIDE_TEXTURES=1)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 25, 2026
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: fxceless/victory-fork#768
Tested-on: Fedora Linux 45, Wine 11.0 (Windows cross-build and four focused batch tests)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 25, 2026
Parallel texture checks may leave a refresh queued when a prelude
reads the upload's dirty flag. If an earlier submission cleared
that flag, the prelude can skip the GPU copy and use the old
texture for this submission.

Drain queued texture refreshes before examining prelude uploads.
Verify that a host callback observes the dirty staging buffer and
that the GPU sees a title write in the same submission.

Based-on: fxceless/victory-fork#768
Based-on: KyleS98/victory-fork#1
Tested-on: AMD Radeon RX 6800, Fedora Linux 45, Wine 11.0 with vkd3d-proton (both texture tests with VICTORY_WIDE_TEXTURES=1)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 25, 2026
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: fxceless/victory-fork#768
Tested-on: Fedora Linux 45, Wine 11.0 (Windows cross-build and four focused batch tests)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 25, 2026
Parallel texture checks may leave a refresh queued when a prelude
reads the upload's dirty flag. If an earlier submission cleared
that flag, the prelude can skip the GPU copy and use the old
texture for this submission.

Drain queued texture refreshes before examining prelude uploads.
Verify that a host callback observes the dirty staging buffer and
that the GPU sees a title write in the same submission.

Based-on: fxceless/victory-fork#768
Based-on: KyleS98/victory-fork#1
Tested-on: AMD Radeon RX 6800, Fedora Linux 45, Wine 11.0 with vkd3d-proton (both texture tests with VICTORY_WIDE_TEXTURES=1)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 25, 2026
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: fxceless/victory-fork#768
Tested-on: Fedora Linux 45, Wine 11.0 (Windows cross-build and four focused batch tests)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 25, 2026
Parallel texture checks may leave a refresh queued when a prelude
reads the upload's dirty flag. If an earlier submission cleared
that flag, the prelude can skip the GPU copy and use the old
texture for this submission.

Drain queued texture refreshes before examining prelude uploads.
Verify that a host callback observes the dirty staging buffer and
that the GPU sees a title write in the same submission.

Based-on: fxceless/victory-fork#768
Based-on: KyleS98/victory-fork#1
Tested-on: AMD Radeon RX 6800, Fedora Linux 45, Wine 11.0 with vkd3d-proton (both texture tests with VICTORY_WIDE_TEXTURES=1)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 25, 2026
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: fxceless/victory-fork#768
Tested-on: Fedora Linux 45, Wine 11.0 (Windows cross-build and four focused batch tests)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 25, 2026
Parallel texture checks may leave a refresh queued when a prelude
reads the upload's dirty flag. If an earlier submission cleared
that flag, the prelude can skip the GPU copy and use the old
texture for this submission.

Drain queued texture refreshes before examining prelude uploads.
Verify that a host callback observes the dirty staging buffer and
that the GPU sees a title write in the same submission.

Based-on: fxceless/victory-fork#768
Based-on: KyleS98/victory-fork#1
Tested-on: AMD Radeon RX 6800, Fedora Linux 45, Wine 11.0 with vkd3d-proton (both texture tests with VICTORY_WIDE_TEXTURES=1)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 26, 2026
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: fxceless/victory-fork#768
Tested-on: Fedora Linux 45, Wine 11.0 (Windows cross-build and four focused batch tests)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 26, 2026
Parallel texture checks may leave a refresh queued when a prelude
reads the upload's dirty flag. If an earlier submission cleared
that flag, the prelude can skip the GPU copy and use the old
texture for this submission.

Drain queued texture refreshes before examining prelude uploads.
Verify that a host callback observes the dirty staging buffer and
that the GPU sees a title write in the same submission.

Based-on: fxceless/victory-fork#768
Based-on: KyleS98/victory-fork#1
Tested-on: AMD Radeon RX 6800, Fedora Linux 45, Wine 11.0 with vkd3d-proton (both texture tests with VICTORY_WIDE_TEXTURES=1)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 26, 2026
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: fxceless/victory-fork#768
Tested-on: Fedora Linux 45, Wine 11.0 (Windows cross-build and four focused batch tests)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 26, 2026
Parallel texture checks may leave a refresh queued when a prelude
reads the upload's dirty flag. If an earlier submission cleared
that flag, the prelude can skip the GPU copy and use the old
texture for this submission.

Drain queued texture refreshes before examining prelude uploads.
Verify that a host callback observes the dirty staging buffer and
that the GPU sees a title write in the same submission.

Based-on: fxceless/victory-fork#768
Based-on: KyleS98/victory-fork#1
Tested-on: AMD Radeon RX 6800, Fedora Linux 45, Wine 11.0 with vkd3d-proton (both texture tests with VICTORY_WIDE_TEXTURES=1)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 26, 2026
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: fxceless/victory-fork#768
Tested-on: Fedora Linux 45, Wine 11.0 (Windows cross-build and four focused batch tests)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 26, 2026
Parallel texture checks may leave a refresh queued when a prelude
reads the upload's dirty flag. If an earlier submission cleared
that flag, the prelude can skip the GPU copy and use the old
texture for this submission.

Drain queued texture refreshes before examining prelude uploads.
Verify that a host callback observes the dirty staging buffer and
that the GPU sees a title write in the same submission.

Based-on: fxceless/victory-fork#768
Based-on: KyleS98/victory-fork#1
Tested-on: AMD Radeon RX 6800, Fedora Linux 45, Wine 11.0 with vkd3d-proton (both texture tests with VICTORY_WIDE_TEXTURES=1)
Assisted-by: gpt-6.2 sol xhigh
@KyleS98

KyleS98 commented Nov 26, 2026

Copy link
Copy Markdown
Author

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

gmankab added a commit to gmankab/victory that referenced this pull request Nov 26, 2026
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: fxceless/victory-fork#768
Tested-on: Fedora Linux 45, Wine 11.0 (Windows cross-build and four focused batch tests)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 26, 2026
Parallel texture checks may leave a refresh queued when a prelude
reads the upload's dirty flag. If an earlier submission cleared
that flag, the prelude can skip the GPU copy and use the old
texture for this submission.

Drain queued texture refreshes before examining prelude uploads.
Verify that a host callback observes the dirty staging buffer and
that the GPU sees a title write in the same submission.

Based-on: fxceless/victory-fork#768
Based-on: KyleS98/victory-fork#1
Tested-on: AMD Radeon RX 6800, Fedora Linux 45, Wine 11.0 with vkd3d-proton (both texture tests with VICTORY_WIDE_TEXTURES=1)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 26, 2026
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: fxceless/victory-fork#768
Tested-on: Fedora Linux 45, Wine 11.0 (Windows cross-build and four focused batch tests)
Assisted-by: gpt-6.2 sol xhigh
gmankab added a commit to gmankab/victory that referenced this pull request Nov 26, 2026
Parallel texture checks may leave a refresh queued when a prelude
reads the upload's dirty flag. If an earlier submission cleared
that flag, the prelude can skip the GPU copy and use the old
texture for this submission.

Drain queued texture refreshes before examining prelude uploads.
Verify that a host callback observes the dirty staging buffer and
that the GPU sees a title write in the same submission.

Based-on: fxceless/victory-fork#768
Based-on: KyleS98/victory-fork#1
Tested-on: AMD Radeon RX 6800, Fedora Linux 45, Wine 11.0 with vkd3d-proton (both texture tests with VICTORY_WIDE_TEXTURES=1)
Assisted-by: gpt-6.2 sol xhigh
KyleS98 and others added 3 commits November 26, 2026 01:46
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 <noreply@anthropic.com>
@KyleS98

KyleS98 commented Nov 26, 2026

Copy link
Copy Markdown
Author

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

grosterr added a commit to grosterr/victory-fork that referenced this pull request Nov 26, 2026
Conflicts resolved with both sides kept:
- descriptor/host.rs: main's constant_view_size (CBV cap, fxceless#1206/fxceless#1260) and made_now
  records; the stack's tiled-slot bookkeeping (5181f96: record_tiled, forget_tiled,
  tiled_stale) with made_now stored after the slot is made and kept.
- drvwatch.rs: fxceless#1101's query (every driver entry, the Display source from warning up)
  kept with its test; main's QUERY (fxceless#1255) dropped as the same filter; its Auto HDR
  note moved into the comment.
- host.rs: main's batched hash passes (CARD_SYNC_BATCH) with the stack's census::sent;
  the view-set line beside main's video memory line.
- pipeline/host.rs: the stack's host_blend and main's integer_targets_do_not_blend both
  stay (main's clears blending when the state is read, the stack's at creation).
- texture.rs: Last keeps fxceless#768's motion and main's ahead; the hash turn honours both.
- watch.rs: known_view asks main's light-refresh bits first, then the stack's view set;
  one title_memory_committed doing both (parked/absent blocks back to unclean, and
  ABSENT_ONCE notes and their hole bits forgotten).
- xmem.rs: main's on_commit with fxceless#1185's caller address.
- tiles.rs: the stack's kept-by-a-list test and main's resident-view LOD test (fxceless#1210).
- emit/mod.rs: the stack's paired-form-first closure and main's WAVE_WIDE=last; its
  result keeps the stack's (shader, groups) return type.
- indirect.rs, resource.rs, lib.rs: main's.
- README.md ours; README-upstream.md from main with fxceless#1057's wording.
Two main watch tests assumed no view set (fxceless#812 parks placeholder holes until the
runtime tells): the ABSENT_ONCE test's silent-mapping expectations depend on view_set(),
and the light-refresh hole test runs with VICTORY_VIEW_SET=0; both pass unchanged there.

NB: fxceless#1014's 64-thread hash is opt-in now (VICTORY_CARD_HASH_WIDE=1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KyleS98

KyleS98 commented Nov 26, 2026

Copy link
Copy Markdown
Author

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

@tikD1337

Copy link
Copy Markdown

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.

@Filip722

Copy link
Copy Markdown
Contributor

I tested the parallel checks on a physical RTX 5060 Laptop 8 GB with Bazzite 44, NVIDIA 615.78.08, GE-Proton11-14 and vkd3d-proton 3.2.0. The local port retained the host-callback ordering fix. Both callback-ordering tests executed on the RTX and passed.

The same 40% Series S executable and warm seed were used for both runs. The enabled log confirmed a simultaneous texture batch. The shared heavy transition into the prison doorway showed these frame-group results:

Serial Parallel
Heavy transition to matched doorway 165.1 s 164.2 s
Median texture time per frame group 602.1 ms 606.6 ms
p95 texture time per frame group 1,685.3 ms 2,635.2 ms
Stationary throughput, same 54 s window 6.555 FPS 6.035 FPS
Stationary p95 Present interval 174 ms 192 ms

Storage activity and draw counts differed. Both runs rendered the same doorway and stopped cleanly. This single comparison did not reproduce the transition speedup reported on Windows.

Assisted by Codex (GPT-6.2-Sol High).

grosterr added a commit to grosterr/victory-fork that referenced this pull request Nov 26, 2026
…to exp/rtx3060-m

Combines exp/rtx3060-l (L1 wave, fxceless#854 paired form, fxceless#864, fxceless#812, fxceless#768, LEVELS_ON_DEMAND, RAM_SAFE) with fxceless main e4245f3 (fxceless#927, fxceless#646, DIRTY_4K, GATHER_SEGMENTS, PAGE_WRITES, group-budget indirect clamp, WAVE_WIDE_ONLY) and PR fxceless#1352 SPREAD_LEAN (bit 32, LEAN_RECORDS=64, spread budget counters 3-5).

Co-Authored-By: Antigravity <noreply@anthropic.com>
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.

9 participants