D3D12.X: title_textures LAST_CONTENT is not cleared on shadow unmap/remap, leaving uncovered textures permanently unmapped under XCL_TEXTURE_LEVEL_PAGES=1 #2460

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

@⁠microwave805 on GitHub · 2026-11-25 19:30 UTC · original

Static audit on main @ c7e1799 found that LAST_CONTENT in crates/xcl/src/hle/d3d12x/title_textures.rs is not cleared when a shadowed placed texture is unmapped or remapped — leaving uncovered textures permanently unmapped (all black) under XCL_TEXTURE_LEVEL_PAGES=1 (#2306) or sampling stale/corrupted tiles without it. Part of #1773, Part of #1833.

Where

  • crates/xcl/src/hle/d3d12x/title_textures.rs:392-401 (register), 539-558 (forget), 845-847 (same_as_last_upload), 1112-1138 (upload_all)
  • crates/xcl/src/hle/d3d12x/vram.rs:1036-1089 (unmap_superseded, remap_if_unmapped)

Root cause

  1. Placed texture A is uploaded once; its CPU content hash is cached in LAST_CONTENT[A].
  2. Overlapping different-range placed texture B is created: register(B) calls vram::unmap_superseded(A) (title_textures.rs:400), which unmaps all of A's tiles, sets every lazy level group's mapped flag to false (vram.rs:1051), and releases A's tiles to cooling. LAST_CONTENT[A] is not removed.
  3. B is later released: title_textures::forget(B) removes only B (not remap_ptrs) from LAST_CONTENT (title_textures.rs:540). Table::remove marks A.pending = true, and vram::remap_if_unmapped(A) runs (title_textures.rs:551):
    • Under XCL_TEXTURE_LEVEL_PAGES=1: remap_if_unmapped sets t.mapped = true while leaving all level groups unmapped (vram.rs:1076-1079), relying on the pending upload in upload_all to call map_levels_with_texels(&A, &subs) (title_textures.rs:1137).
    • Without XCL_TEXTURE_LEVEL_PAGES=1: remap_if_unmapped binds fresh/recycled pool tiles (stale VRAM / overwritten by B), relying on the pending upload to restore A's texels.
  4. On the next submit, upload_all (title_textures.rs:1112-1121) runs unchanged_skip() (default ON). Because A's CPU memory still hashes to LAST_CONTENT[A], same_as_last_upload(A, h) returns true and executes continue, skipping both map_levels_with_texels and texture::upload_batch.

Trigger

Upload placed texture A → create overlapping different-range placed texture B → release B → submit GPU work sampling A (default XCL_TEXTURE_SKIP_UNCHANGED=1). Under XCL_TEXTURE_LEVEL_PAGES=1, A stays permanently unmapped (samples all black/zeros) until its CPU bytes change; without XCL_TEXTURE_LEVEL_PAGES=1, A samples stale/corrupted tiles.

Fix direction

Remove every pointer in unmap_ptrs (in register / retire_overlapping) and remap_ptrs (in forget, before remap_if_unmapped) from LAST_CONTENT.

AI use

  • Antigravity (Gemini 4 Neon): static code audit on main @ c7e1799 and issue drafting.
**@⁠microwave805** on GitHub · 2026-11-25 19:30 UTC · [original](https://github.com/xcl-dev/xcl/issues/2460) Static audit on `main @ c7e1799` found that `LAST_CONTENT` in `crates/xcl/src/hle/d3d12x/title_textures.rs` is not cleared when a shadowed placed texture is unmapped or remapped — leaving uncovered textures permanently unmapped (all black) under `XCL_TEXTURE_LEVEL_PAGES=1` (#2306) or sampling stale/corrupted tiles without it. Part of #1773, Part of #1833. ### Where - `crates/xcl/src/hle/d3d12x/title_textures.rs:392-401` (`register`), `539-558` (`forget`), `845-847` (`same_as_last_upload`), `1112-1138` (`upload_all`) - `crates/xcl/src/hle/d3d12x/vram.rs:1036-1089` (`unmap_superseded`, `remap_if_unmapped`) ### Root cause 1. Placed texture `A` is uploaded once; its CPU content hash is cached in `LAST_CONTENT[A]`. 2. Overlapping different-range placed texture `B` is created: `register(B)` calls `vram::unmap_superseded(A)` (`title_textures.rs:400`), which unmaps all of `A`'s tiles, sets every lazy level group's mapped flag to `false` (`vram.rs:1051`), and releases `A`'s tiles to `cooling`. `LAST_CONTENT[A]` is **not** removed. 3. `B` is later released: `title_textures::forget(B)` removes only `B` (not `remap_ptrs`) from `LAST_CONTENT` (`title_textures.rs:540`). `Table::remove` marks `A.pending = true`, and `vram::remap_if_unmapped(A)` runs (`title_textures.rs:551`): - Under `XCL_TEXTURE_LEVEL_PAGES=1`: `remap_if_unmapped` sets `t.mapped = true` while leaving **all level groups unmapped** (`vram.rs:1076-1079`), relying on the pending upload in `upload_all` to call `map_levels_with_texels(&A, &subs)` (`title_textures.rs:1137`). - Without `XCL_TEXTURE_LEVEL_PAGES=1`: `remap_if_unmapped` binds fresh/recycled pool tiles (stale VRAM / overwritten by `B`), relying on the pending upload to restore `A`'s texels. 4. On the next submit, `upload_all` (`title_textures.rs:1112-1121`) runs `unchanged_skip()` (default ON). Because `A`'s CPU memory still hashes to `LAST_CONTENT[A]`, `same_as_last_upload(A, h)` returns `true` and executes `continue`, skipping **both** `map_levels_with_texels` and `texture::upload_batch`. ### Trigger Upload placed texture `A` → create overlapping different-range placed texture `B` → release `B` → submit GPU work sampling `A` (default `XCL_TEXTURE_SKIP_UNCHANGED=1`). Under `XCL_TEXTURE_LEVEL_PAGES=1`, `A` stays permanently unmapped (samples all black/zeros) until its CPU bytes change; without `XCL_TEXTURE_LEVEL_PAGES=1`, `A` samples stale/corrupted tiles. ### Fix direction Remove every pointer in `unmap_ptrs` (in `register` / `retire_overlapping`) and `remap_ptrs` (in `forget`, before `remap_if_unmapped`) from `LAST_CONTENT`. ### AI use - Antigravity (Gemini 4 Neon): static code audit on `main @ c7e1799` and issue drafting.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:31:21 +00:00
Author
Owner

@⁠AngeloMaiale on GitHub · 2026-11-25 22:57 UTC · original

Working on this: clearing LAST_CONTENT for superseded/uncovered textures on unmap and remap in title_textures.rs, with a GPU regression test.

**@⁠AngeloMaiale** on GitHub · 2026-11-25 22:57 UTC · [original](https://github.com/xcl-dev/xcl/issues/2460#issuecomment-7176975939) Working on this: clearing LAST_CONTENT for superseded/uncovered textures on unmap and remap in title_textures.rs, with a GPU regression test.
This discussion has been locked. Commenting is limited to contributors.
No description provided.