Title textures: small render targets the CPU fills are kept in step (retail game's menu text is complete) #211
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!211
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/211/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@theaustinayers on GitHub · 2026-11-23 21:05 UTC · original
theaustinayers:glyph-cache-targets→main· +23 −2 · 1 files · 1 commits · merged 2026-11-23 21:24 UTCWhat this does
On
main(2abc562) the newer retail game's menus show their headings and button prompts, but the body text is missing most of its letters: digits, capitals and tall lowercase letters draw, the short lowercase ones (a c e m n o r s u …) do not. With this change the body text is complete (legal terms, settings descriptions, option values).Cause
The title's glyph caches are small textures it places with
ALLOW_RENDER_TARGETand fills from the CPU: 256×256R8_UNORM(format 61), flags0x300001, layout0x100, whichxglays out with two planes.title_textures::registerrefuses anything that is not single-plane ("a render target / depth buffer"), so these were never uploaded after creation and stayed as they were made. The log line onmain:Change
One function,
title_textures::register: a small single-sample colour target that has texels is kept in step with the title's memory like any other texture, even with more than one plane. "Small" is 64×64 up to 1024×1024, not a depth buffer (flag0x2), one sample. Everything else is refused as before.XCL_SYNC_SMALL_TARGETS=0turns it off.Uploads still only happen when the write watch reports CPU writes on the texture's pages, so a target the title only renders to is not uploaded over.
Tested
Ryzen 9 9950X3D, RTX 5090, Windows 11, release build of
2abc562+ this change, the retail game withXCL_NETWORK=0:2abc562without the change have the missing letters.cargo build --release -p xclpasses. I did not run the test suite.What I am not sure about
gpu_writtenonly covers copies, not draws.AI-assisted (Claude Code); every run above was on my machine and I can re-run anything.
🤖 Generated with Claude Code
@mastrr9 on GitHub · 2026-11-23 21:11 UTC · original
Independent static code audit of
f17a5eeb9(code inspection only —cargo testnot run on macOS; no game files):Summary
Clean, minimal fix for CPU-filled 256×256
ALLOW_RENDER_TARGETglyph caches (R8_UNORMwith 2 planes: texels + CMASK).w <= 1024 && h <= 1024 && w * h as u64 >= 64 * 64avoids overflow and excludes 1D textures (h == 1), and plane 0 (tex.texels()) starts at offset 0 whenever!depth_bufferinxg.rs.Edge cases worth tightening
ALLOW_DEPTH_STENCIL(flags & 0x2 == 0): Inxg.rs, formats19..=22(D32_S8X24),44..=47(D24_S8), and118/120(D16_S8) produce 2 planes (depth + stencil) even whenflags & 0x2 == 0(e.g. SRV-only). Becausesmall_targetdoes not checkflags & 0x1 != 0(ALLOW_RENDER_TARGET) or that the second plane is CMASK (tex.planes.len() == 2 && tex.planes[1].usage == 2), a 64×64–1024×1024 planar depth/stencil texture withflags == 0would also passsmall_targetand entertitle_textures. Requiringflags & 0x1 != 0 && tex.planes.len() == 2 && tex.planes[1].usage == 2restricts this strictly to color render targets with CMASK.refresh_oncechecks dirty pages across[e.va, e.va + e.tex.size()), which includes the trailing CMASK plane; combined withnote_gpu_writenot yet firing onOMSetRenderTargets/ClearRenderTargetView, a neighbouring CPU write sharing a 4 KiB page with the CMASK tail could also trigger a re-upload over a GPU-rendered target.title_textures.rs:78-82: when combining both, keeping #210's116 | 117rejection abovesmall_targetensures small 32-bit console float render targets aren't uploaded into 64-bit PCR16G16B16A16_FLOATresources.(AI-assisted)
@Kalmarv on GitHub · 2026-11-23 21:21 UTC · original
This fixes the text, and it can also wipe what the GPU drew into such a target. The write watch covers the whole console resource, including its CMASK plane (
title_textures.rs:311), but the upload is built from the texel plane alone (line 554). So a CPU write to CMASK alone re-uploads the texels and replaces every drawn pixel. Two narrowings would keep the fix and drop the risk: watch only the texel plane's pages, and admit only a colour surface (plus its CMASK), not depth/stencil or large arrays (a 1024×1024×65 RGBA8 array passes the size gate today, 260 MiB).Tested
A CPU write to the CMASK plane alone replaces previously drawn pixels. On a synthetic 256×256 R8_UNORM target (layout
0x100, flags0x300001), I initialized both copies to0x22, drew a full-screen triangle producing0xff, waited for the fence, and read back all 65,536 texels. Refresh with no CPU write preserved them all.6da33fa9ebbfbb0x100000x77Direct head
f17a5eeshowed the same results.XCL_SYNC_SMALL_TARGETS=0preserved the draw in both cases and suppressed the CPU texel update. The reproducer used the production registration, write-watch and upload code with a native D3D12 draw and fenced readback. Atcrates/xcl/src/hle/d3d12x/title_textures.rs:311, the watch covers the entire console resource, including CMASK, while line 554 builds the upload from the main texel plane alone.Two registration cases extend the scope beyond small color targets. At line 92, the lower limit is area:
4×1024and64×64pass,63×64and1025×64fail. A 1024×1024 RGBA8 array of 65 slices also passes, with 260 MiB of texels before metadata. A flagless 256×256R24G8_TYPELESSpasses with XG plane usages 5 and 6 (depth and stencil). Changing the stencil bytes leaves the sole upload payload identical. Restricting the exception to a color surface followed by CMASK would exclude that case.RTX 5070 Ti, 610.74, Windows x64.
cargo test -p xcl --lib --no-run -j 2, then the library binary with--test-threads=1. Direct head 547/0,eaa36b6548/0, and #211 merged ontoeaa36b6(9bf1b74) 548/0, each with 19 ignored. On6da33faand the local merge9ebbfbb, the repository library tests returned 582/0/20 ignored on each. Two native-wave64 tests and sample-gated cases returned early. The separate draw-preservation probe failed on both PR builds and passed on both controls.Not tested
Retail text, AMD, large-array upload performance, or GPU stencil sampling. The array and depth/stencil checks exercised descriptor admission and upload construction.
AI use — Codex, GPT-6.2 Astra.
@ivall on GitHub · 2026-11-23 21:24 UTC · original
Merged (main
d4f17ca). Checked on an RX 9070 (RDNA4) with 11 PRs merged together on mainaf20b4b:cargo build --workspace && cargo test --workspace -- --test-threads=4- 605 unit tests passed, 0 failed (20 ignored), the integration and e2e tests passed; and the retail game still reaches its first menu at 30 fps (720 draws per 2 s). Note: on main a GPU-owned texture at a 64 KiB-aligned address is placed on video-memory pages (vram::place) beforeregisteris reached, so this applies to the glyph caches that land elsewhere (not 64 KiB aligned) - if the letters are still missing for you, that routing is the place to look.