D3D12.X: one written page makes a title texture hashed, detiled and uploaded whole #2390

Open
opened 2026-11-26 05:29:49 +00:00 by github-bot · 1 comment
Owner

@⁠KOLESNiii on GitHub · 2026-11-25 17:43 UTC · original

A title texture kept in step with the title's memory is handled whole whenever the write watch reports any page of it (crates/xcl/src/hle/d3d12x/title_textures.rs on main 3f4495a):

  • upload_all hashes the entire texture to see if it changed (:1099-1107), however few of its pages were written;
  • if it did change, every subresource is detiled and uploaded (:1116). The comment at :1095 already measured this: "~25 MB a presented frame where ~3 MB had changed";
  • to find those textures, refresh_once walks every registered texture under the TEXTURES lock on each submit with written pages (:791-815).

Seen: in my title's menus (RTX 2070 SUPER, Ryzen 5 3600XT, Windows 11 26300, main 3f4495a release), the "uploads left out" count (full-texture hashes that found nothing changed) reached 1,024 at 39 s, 2,048 at 43 s and 4,096 at 52 s.

#486 skips uploads where nothing changed. #504 / #508 cover the skip hash's correctness, #1511 / #1513 the speed of detiling, and #449 the cost analysis. None of them makes the work proportional to what was written.

Parts:

  • #2395 – per-page hashes; hash only the written pages
  • #2396 – upload only the subresources the changed pages touch (needs #2395)
  • #2397 – find the textures from the written pages, not by walking all of them

Found by code reading with Claude Code (Claude Opus 5.5).

**@⁠KOLESNiii** on GitHub · 2026-11-25 17:43 UTC · [original](https://github.com/xcl-dev/xcl/issues/2390) A title texture kept in step with the title's memory is handled whole whenever the write watch reports any page of it (`crates/xcl/src/hle/d3d12x/title_textures.rs` on `main` 3f4495a): - `upload_all` hashes the **entire** texture to see if it changed (`:1099-1107`), however few of its pages were written; - if it did change, every subresource is detiled and uploaded (`:1116`). The comment at `:1095` already measured this: "~25 MB a presented frame where ~3 MB had changed"; - to find those textures, `refresh_once` walks **every** registered texture under the `TEXTURES` lock on each submit with written pages (`:791-815`). **Seen:** in my title's menus (RTX 2070 SUPER, Ryzen 5 3600XT, Windows 11 26300, `main` 3f4495a release), the "uploads left out" count (full-texture hashes that found nothing changed) reached 1,024 at 39 s, 2,048 at 43 s and 4,096 at 52 s. #486 skips uploads where nothing changed. #504 / #508 cover the skip hash's correctness, #1511 / #1513 the speed of detiling, and #449 the cost analysis. None of them makes the work proportional to what was written. **Parts:** - [ ] #2395 – per-page hashes; hash only the written pages - [ ] #2396 – upload only the subresources the changed pages touch (needs #2395) - [ ] #2397 – find the textures from the written pages, not by walking all of them *Found by code reading with Claude Code (Claude Opus 5.5).*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:29:49 +00:00
Author
Owner

@⁠KOLESNiii on GitHub · 2026-11-25 17:54 UTC · original

Measured: negligible in steady menus, large in two phases. In one, uploads of partly written textures take ~35 % of the submitting thread; in the other, first uploads are hashed for nothing.

Setup: my title; main 3f4495a plus local timers and counters (not committed); release; RTX 2070 SUPER (32.0.16.2140), Ryzen 5 3600XT, Windows 11 26300. One scripts/smoke.ps1 run of 120 s with the learned coherent window. Every 2 s I logged the refresh walk, the "unchanged" hashes, the written pages inside the textures picked for a hash against those textures' total pages, and the detile and upload times in upload_all. "Upload total" includes detiling.

phase (time in run) hashes / 2 s hashed hash time unchanged written pages of picked textures uploaded detile upload total
steady menus (42–62 s, 70–82 s) 230–480 0–4 MiB 0.03–0.3 ms ~all 1 page of 1-page textures 0–8 MiB ≤1.7 ms ≤7 ms
menus with video playing (26–38 s, 360 submits/2 s) ~600 ~1.46 GB ~113 ms ~250 (40 %) 193 k of 373 k (52 %) ~1.45 GB ~360 ms ~700 ms (35 % of the thread)
streaming loads (84–114 s) 500–1,700 135–954 MiB 47–266 ms 9–36 (≤ 5 %) few: almost all are new textures 133–952 MiB 48–357 ms 240–1,094 ms

What this means for each part:

  • #2395 (per-page hashes): in steady menus there is nothing to save, since the hashed textures are one page each. With the video playing, ~113 ms per 2 s (5.6 %) goes to hashing 1.46 GB of textures that are ~half written. During loads, the hash is almost pure overhead for a different reason: a texture's first upload is hashed too, and with nothing to compare against it can never be "unchanged". That is 195 ms of hashing 825 MiB in one 2-s window with only 9 hits. Computing the hash for the next comparison during the detile, instead of before it, would remove this whatever the per-page design. That may be the cheapest win in this issue.
  • #2396 (upload only touched subresources): the biggest number here. With the video playing, picked textures had 52 % of their pages written, and their full detile and upload took ~700 ms per 2 s. What that saves depends on whether the written pages cluster in a few subresources. Video planes are likely rewritten whole, so ~half is the upper bound, not an expectation.
  • #2397 (walk all textures): after loading, ~16 k textures are registered. A walk costs 0.34 ms in steady menus (40 ms per 2 s at 116 walks, 2 %) and up to 1.2 ms while streaming (179 ms per 2 s, ~9 %). It is real, and it grows with the texture count.

Not measured: the world (never reached), and how the written pages of the video-phase textures spread across their subresources (that needs a per-subresource count).

Measured and written with Claude Code (Claude Opus 5.5).

**@⁠KOLESNiii** on GitHub · 2026-11-25 17:54 UTC · [original](https://github.com/xcl-dev/xcl/issues/2390#issuecomment-7170173780) **Measured: negligible in steady menus, large in two phases. In one, uploads of partly written textures take ~35 % of the submitting thread; in the other, first uploads are hashed for nothing.** **Setup:** my title; `main` 3f4495a plus local timers and counters (not committed); release; RTX 2070 SUPER (32.0.16.2140), Ryzen 5 3600XT, Windows 11 26300. One `scripts/smoke.ps1` run of 120 s with the learned coherent window. Every 2 s I logged the refresh walk, the "unchanged" hashes, the written pages inside the textures picked for a hash against those textures' total pages, and the detile and upload times in `upload_all`. "Upload total" includes detiling. | phase (time in run) | hashes / 2 s | hashed | hash time | unchanged | written pages of picked textures | uploaded | detile | upload total | |---|---|---|---|---|---|---|---|---| | steady menus (42–62 s, 70–82 s) | 230–480 | 0–4 MiB | 0.03–0.3 ms | ~all | 1 page of 1-page textures | 0–8 MiB | ≤1.7 ms | ≤7 ms | | menus with video playing (26–38 s, 360 submits/2 s) | ~600 | **~1.46 GB** | **~113 ms** | ~250 (40 %) | **193 k of 373 k (52 %)** | ~1.45 GB | ~360 ms | **~700 ms (35 % of the thread)** | | streaming loads (84–114 s) | 500–1,700 | 135–954 MiB | 47–266 ms | 9–36 (≤ 5 %) | few: almost all are new textures | 133–952 MiB | 48–357 ms | 240–1,094 ms | What this means for each part: - **#2395 (per-page hashes):** in steady menus there is nothing to save, since the hashed textures are one page each. With the video playing, ~113 ms per 2 s (5.6 %) goes to hashing 1.46 GB of textures that are ~half written. During loads, the hash is almost pure overhead for a different reason: **a texture's first upload is hashed too**, and with nothing to compare against it can never be "unchanged". That is 195 ms of hashing 825 MiB in one 2-s window with only 9 hits. Computing the hash for the *next* comparison during the detile, instead of before it, would remove this whatever the per-page design. That may be the cheapest win in this issue. - **#2396 (upload only touched subresources):** the biggest number here. With the video playing, picked textures had **52 %** of their pages written, and their full detile and upload took ~700 ms per 2 s. What that saves depends on whether the written pages cluster in a few subresources. Video planes are likely rewritten whole, so ~half is the upper bound, not an expectation. - **#2397 (walk all textures):** after loading, ~16 k textures are registered. A walk costs **0.34 ms** in steady menus (40 ms per 2 s at 116 walks, 2 %) and up to **1.2 ms** while streaming (179 ms per 2 s, ~9 %). It is real, and it grows with the texture count. **Not measured:** the world (never reached), and how the written pages of the video-phase textures spread across their subresources (that needs a per-subresource count). *Measured and written with Claude Code (Claude Opus 5.5).*
This discussion has been locked. Commenting is limited to contributors.
No description provided.