D3D12.X: title texture refresh walks the written pages, not every texture #2397

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

Part of #2390.

On every submit that has written pages, title_textures::refresh_once (crates/xcl/src/hle/d3d12x/title_textures.rs:791-815 on main 3f4495a) holds the TEXTURES lock and walks every registered texture (t.by_res.iter_mut()). For each one it binary-searches the sorted dirty list. The cost grows with the number of textures times the number of submits, about 120 a second in my title's menus, even when only a few pages were written.

Proposal: keep an index of the textures by source address (a BTreeMap<src, res> next to by_res) and walk the dirty pages instead. For each run of dirty pages, take the textures whose [src, src + size) overlaps it. The pending textures are already counted in PENDING, and could be kept in their own list.

Smaller than the other parts. It is worth doing once a title keeps thousands of textures in step.

Found by code reading with Claude Code (Claude Opus 5.5); not measured yet.

**@⁠KOLESNiii** on GitHub · 2026-11-25 17:43 UTC · [original](https://github.com/xcl-dev/xcl/issues/2397) Part of #2390. On every submit that has written pages, `title_textures::refresh_once` (`crates/xcl/src/hle/d3d12x/title_textures.rs:791-815` on `main` 3f4495a) holds the `TEXTURES` lock and walks **every** registered texture (`t.by_res.iter_mut()`). For each one it binary-searches the sorted dirty list. The cost grows with the number of textures times the number of submits, about 120 a second in my title's menus, even when only a few pages were written. **Proposal:** keep an index of the textures by source address (a `BTreeMap<src, res>` next to `by_res`) and walk the dirty pages instead. For each run of dirty pages, take the textures whose `[src, src + size)` overlaps it. The pending textures are already counted in `PENDING`, and could be kept in their own list. Smaller than the other parts. It is worth doing once a title keeps thousands of textures in step. *Found by code reading with Claude Code (Claude Opus 5.5); not measured yet.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:29:49 +00:00
Author
Owner

@⁠itsSio on GitHub · 2026-11-25 23:03 UTC · original · edited 2026-11-25 23:51 UTC

Completed #2397 on my fork (itsSio/xcl#5, branch d3d12x/title-textures-dirty-index, commit 7a7b3acf), staged as a fork draft PR pending paired retail scripts/smoke.ps1 runs before upstream submission.

Update: xcl-dev/xcl:amd-dev (1286a94 by @⁠raylitebull) and xcl-dev/xcl:nvidia-dev (9acc031 by @⁠theaustinayers) already implement dirty-page range indexing for title_textures.rs, so itsSio/xcl#5 is kept as a draft reference only.

Implemented (7a7b3acf)

  • crates/xcl/src/hle/d3d12x/title_textures.rs (+312/-40): added by_src ((src, res) -> src + size), max_active_src_size, and pending_res to Table (kept in sync across insert, remove, retire_range, recheck_gpu_view_sources, and recheck_streamed_unwatched_at), extracted Table::collect_dirty_and_pending for coalesced dirty-page span lookups + pending_res drains, and added 3 pure-CPU unit tests (exact boundaries/coalesced runs, mirror/shadow/retire/pending transitions, and randomized + 16k-texture parity against a full scan).

Tested (debug build, clean commit 7a7b3acf1ef687ddaeff13189e225c2e84aa3d1a)

  • Main PC — NVIDIA GeForce RTX 5080 (Win11 26200, Ryzen 7 9800X3D, driver 32.0.16.1088, rustc 1.97.0, DXC 1.9.2609.5):
    • cargo test --workspace -- --test-threads=4: 1426 passed, 0 failed, 46 ignored (26 SKIPPED: 21 no wave64, 3 #1426 f16/cvt per-lane refused, 1 Windows Developer Mode required for driver-cache disable, 1 no heap windows).
    • cargo test -p xcl --lib title_textures -- --test-threads=1: 22 passed, 0 failed, 0 ignored (0 SKIPPED).
  • Build PC — NVIDIA GeForce RTX 2080 SUPER (Win11 26200, Ryzen 5 5600X, 15.91 GB RAM, driver 32.0.16.1088, rustc 1.99.1, SDK DXC 1.8.2502.11):
    • cargo test --workspace -- --test-threads=4: 1426 passed, 0 failed, 46 ignored (29 SKIPPED: same 26 as Main PC + 3 no d3d12SDKLayers.dll / D3D12 debug layer).
    • cargo test -p xcl --lib title_textures -- --test-threads=1: 22 passed, 0 failed, 0 ignored (0 SKIPPED).

Not tested

  • AMD GPUs (discrete or iGPU), wave64-only GPU tests, XCL_SAMPLE_* tests (unset), retail title scripts/smoke.ps1 regression runs, and release builds.

AI use
Ran via Samaritan:

  • Antigravity (Gemini 4 Neon (High)): coordination, task scoping, and review/release oversight.
  • Antigravity (Gemini 4 Hydrogen (High)): roadmap scouting, implementation and CPU parity tests, independent code review, dual-PC verification, and reporting.
**@⁠itsSio** on GitHub · 2026-11-25 23:03 UTC · [original](https://github.com/xcl-dev/xcl/issues/2397#issuecomment-7177103601) · edited 2026-11-25 23:51 UTC Completed #2397 on my fork ([itsSio/xcl#5](https://github.com/itsSio/xcl/pull/5), branch `d3d12x/title-textures-dirty-index`, commit `7a7b3acf`), staged as a fork draft PR pending paired retail `scripts/smoke.ps1` runs before upstream submission. **Update:** `xcl-dev/xcl:amd-dev` (`1286a94` by @⁠raylitebull) and `xcl-dev/xcl:nvidia-dev` (`9acc031` by @⁠theaustinayers) already implement dirty-page range indexing for `title_textures.rs`, so [itsSio/xcl#5](https://github.com/itsSio/xcl/pull/5) is kept as a draft reference only. **Implemented (`7a7b3acf`)** - `crates/xcl/src/hle/d3d12x/title_textures.rs` (`+312/-40`): added `by_src` (`(src, res) -> src + size`), `max_active_src_size`, and `pending_res` to `Table` (kept in sync across `insert`, `remove`, `retire_range`, `recheck_gpu_view_sources`, and `recheck_streamed_unwatched_at`), extracted `Table::collect_dirty_and_pending` for coalesced dirty-page span lookups + `pending_res` drains, and added 3 pure-CPU unit tests (exact boundaries/coalesced runs, mirror/shadow/retire/`pending` transitions, and randomized + 16k-texture parity against a full scan). **Tested (debug build, clean commit `7a7b3acf1ef687ddaeff13189e225c2e84aa3d1a`)** - **Main PC — NVIDIA GeForce RTX 5080** (Win11 26200, Ryzen 7 9800X3D, driver `32.0.16.1088`, rustc 1.97.0, DXC 1.9.2609.5): - `cargo test --workspace -- --test-threads=4`: **1426 passed, 0 failed, 46 ignored** (26 `SKIPPED`: 21 `no wave64`, 3 `#1426` f16/cvt per-lane refused, 1 Windows Developer Mode required for driver-cache disable, 1 no heap windows). - `cargo test -p xcl --lib title_textures -- --test-threads=1`: **22 passed, 0 failed, 0 ignored** (0 `SKIPPED`). - **Build PC — NVIDIA GeForce RTX 2080 SUPER** (Win11 26200, Ryzen 5 5600X, 15.91 GB RAM, driver `32.0.16.1088`, rustc 1.99.1, SDK DXC 1.8.2502.11): - `cargo test --workspace -- --test-threads=4`: **1426 passed, 0 failed, 46 ignored** (29 `SKIPPED`: same 26 as Main PC + 3 `no d3d12SDKLayers.dll` / D3D12 debug layer). - `cargo test -p xcl --lib title_textures -- --test-threads=1`: **22 passed, 0 failed, 0 ignored** (0 `SKIPPED`). **Not tested** - AMD GPUs (discrete or iGPU), wave64-only GPU tests, `XCL_SAMPLE_*` tests (unset), retail title `scripts/smoke.ps1` regression runs, and release builds. **AI use** Ran via Samaritan: - Antigravity (Gemini 4 Neon (High)): coordination, task scoping, and review/release oversight. - Antigravity (Gemini 4 Hydrogen (High)): roadmap scouting, implementation and CPU parity tests, independent code review, dual-PC verification, and reporting.
This discussion has been locked. Commenting is limited to contributors.
No description provided.