Textures: unchanged textures re-uploaded every frame (measured 344-444 MB/frame in world streaming) #3267

Open
opened 2026-11-26 15:12:34 +00:00 by Moonwolf711 · 1 comment
Moonwolf711 commented 2026-11-26 15:12:34 +00:00 (Migrated from github.com)
Contributor

Imported from Marvisak/VIctory. Originally posted by Moonwolf711 on 2026-11-26T15:12:34Z.


Measured on RX 6600 XT, current tip with #3252's VICTORY_NO_TDR=1 (so the run survives long enough to measure)

In the world-streaming phase, the per-frame host line shows texture uploads that dwarf everything else:

1.6 fps, 616.7 ms/frame (234.5 preparing: copies 33.3 ms 101.8 MB, textures 492.0 ms 343.9 MB; 301.3 on the GPU; 79.6 copying back 0.2 MB), 812 draws/frame
0.8 fps, 1262.5 ms/frame (553.6 preparing: copies 141.2 ms 517.0 MB, textures 597.6 ms 444.6 MB; 542.5 on the GPU; 162.9 copying back), 1308 draws/frame

Textures alone account for 380-600 ms of CPU time per frame. The GPU is executing 300-540 ms — heavy but not the primary wall; the upload path is.

crates/victory-gpu/src/texture.rs uploads texture memory each time it is picked, with no record of whether the bytes changed. An 8 GB card streaming a ~5 GB working set then re-uploads textures continuously.

Fix direction (validated by the same scene running at 5-6 fps on the same hardware with these implemented)

  1. Content-version dirty tracking. Keep a digest (a 128-bit hash is enough) of each texture's title memory per subresource; re-detile and re-upload a level only when its bytes changed. Binding a texture again with unchanged memory should cost nothing. An address is not a sufficient cache key — track content, not location.
  2. Per-level granularity. The title holds only the smaller mips of streamed textures; judge levels individually rather than re-uploading whole chains.
  3. Upload prefetch off the frame path. First uploads of textures picked by index can be read, detiled and copied on background threads with their own copy queue, recorded into the frame's list only for ordering. The frame then waits for streaming data instead of doing the detile inline.
  4. Write-watch where the memory allows it. Title memory that is write-watched reveals its changed pages; only those need refreshing.

With all four, the same world-streaming phase on the same card moves from 1 fps with ~344-444 MB of per-frame texture traffic to 5-6 fps with single-digit MB on steady frames and a 167 MB spike only at world entry. The remaining per-frame cost is then dominated by unwatched-shadow whole copies (~30 ms) and the GPU itself.

Happy to share the full per-frame logs from both runs if useful.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6629628043 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/3269). Originally posted by [Moonwolf711](https://github.com/Moonwolf711) on 2026-11-26T15:12:34Z. --- ## Measured on RX 6600 XT, current tip with #3252's VICTORY_NO_TDR=1 (so the run survives long enough to measure) In the world-streaming phase, the per-frame host line shows texture uploads that dwarf everything else: ``` 1.6 fps, 616.7 ms/frame (234.5 preparing: copies 33.3 ms 101.8 MB, textures 492.0 ms 343.9 MB; 301.3 on the GPU; 79.6 copying back 0.2 MB), 812 draws/frame 0.8 fps, 1262.5 ms/frame (553.6 preparing: copies 141.2 ms 517.0 MB, textures 597.6 ms 444.6 MB; 542.5 on the GPU; 162.9 copying back), 1308 draws/frame ``` Textures alone account for 380-600 ms of CPU time per frame. The GPU is executing 300-540 ms — heavy but not the primary wall; the upload path is. `crates/victory-gpu/src/texture.rs` uploads texture memory each time it is picked, with no record of whether the bytes changed. An 8 GB card streaming a ~5 GB working set then re-uploads textures continuously. ## Fix direction (validated by the same scene running at 5-6 fps on the same hardware with these implemented) 1. **Content-version dirty tracking.** Keep a digest (a 128-bit hash is enough) of each texture's title memory per subresource; re-detile and re-upload a level only when its bytes changed. Binding a texture again with unchanged memory should cost nothing. An address is not a sufficient cache key — track content, not location. 2. **Per-level granularity.** The title holds only the smaller mips of streamed textures; judge levels individually rather than re-uploading whole chains. 3. **Upload prefetch off the frame path.** First uploads of textures picked by index can be read, detiled and copied on background threads with their own copy queue, recorded into the frame's list only for ordering. The frame then waits for streaming data instead of doing the detile inline. 4. **Write-watch where the memory allows it.** Title memory that is write-watched reveals its changed pages; only those need refreshing. With all four, the same world-streaming phase on the same card moves from 1 fps with ~344-444 MB of per-frame texture traffic to 5-6 fps with single-digit MB on steady frames and a 167 MB spike only at world entry. The remaining per-frame cost is then dominated by unwatched-shadow whole copies (~30 ms) and the GPU itself. Happy to share the full per-frame logs from both runs if useful.
andrewpozdnakov7-jpg commented 2026-11-26 16:05:08 +00:00 (Migrated from github.com)
Author
Contributor

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T15:41:34Z.


On current main 63bcca4, the frame line's textures … MB counts bytes read by Staging::refresh_now, including bytes read for an unchanged texture's digest. It can grow even when the refresh returns no staging upload. Counter at the refresh call, unchanged digest check

I checked a synthetic 64×64 RGBA8 texture on app-local WARP 1.0.22. The first refresh read 16,384 bytes and staged one subresource in both cases. On the next refresh with identical content, the tracked case read 0 bytes and staged 0, and the untracked case read 16,384 bytes and staged 0. Both existing heap-texture tests passed. Current main also already selects changed subresources for tracked textures. Tracked subresource selection

Could you share the exact source commit and the copies per frame texture counters from matching runs? The diagnostic line splits watched-and-changed, hashed, and hashed-bytes-that-changed. Comparing those would show how much of the 344–444 MB figure was spent checking unchanged content. Diagnostic counters

AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7196619774 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/issues/3269#issuecomment-7196619774). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T15:41:34Z. --- On current main `63bcca4`, the frame line's `textures … MB` counts bytes read by `Staging::refresh_now`, including bytes read for an unchanged texture's digest. It can grow even when the refresh returns no staging upload. [Counter at the refresh call](https://github.com/Marvisak/VIctory/blob/63bcca43c6a00a758510398fa43096ce7e4f7df0/crates/victory-gpu/src/texture.rs#L542-L551), [unchanged digest check](https://github.com/Marvisak/VIctory/blob/63bcca43c6a00a758510398fa43096ce7e4f7df0/crates/victory-gpu/src/texture.rs#L651-L664) I checked a synthetic 64×64 RGBA8 texture on app-local WARP 1.0.22. The first refresh read 16,384 bytes and staged one subresource in both cases. On the next refresh with identical content, the tracked case read **0 bytes** and staged **0**, and the untracked case read **16,384 bytes** and staged **0**. Both existing heap-texture tests passed. Current main also already selects changed subresources for tracked textures. [Tracked subresource selection](https://github.com/Marvisak/VIctory/blob/63bcca43c6a00a758510398fa43096ce7e4f7df0/crates/victory-gpu/src/texture.rs#L562-L630) Could you share the exact source commit and the `copies per frame` texture counters from matching runs? The diagnostic line splits watched-and-changed, hashed, and hashed-bytes-that-changed. Comparing those would show how much of the 344–444 MB figure was spent checking unchanged content. [Diagnostic counters](https://github.com/Marvisak/VIctory/blob/63bcca43c6a00a758510398fa43096ce7e4f7df0/crates/victory-gpu/src/copystat.rs#L225-L233) AI-assisted with Codex.
Sign in to join this conversation.
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#3267
No description provided.