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

Open
opened 2026-11-25 17:43:25 +00:00 by KOLESNiii · 1 comment
KOLESNiii commented 2026-11-25 17:43:25 +00:00 (Migrated from github.com)
Contributor

Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-25T17:43:25Z.


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.

<!-- greyfinch-sync:ivall/xcl:issue:6610267733 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/2397). Originally posted by [KOLESNiii](https://github.com/KOLESNiii) on 2026-11-25T17:43:25Z. --- 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.*
itsSio commented 2026-11-25 23:09:22 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by itsSio on 2026-11-25T23:03:50Z.


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.
<!-- greyfinch-sync:ivall/xcl:comment:7177103601 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/2397#issuecomment-7177103601). Originally posted by [itsSio](https://github.com/itsSio) on 2026-11-25T23:03:50Z. --- 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.
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
xcl-dev/xcl#2387
No description provided.