Skip to content

D3D12.X: small render targets in unwatched memory keep being re-checked (glyph caches) - #3537

Closed
throny wants to merge 1 commit into
xcl-dev:mainfrom
throny:glyph-unwatched-recheck-pr
Closed

throny wants to merge 1 commit into
xcl-dev:mainfrom
throny:glyph-unwatched-recheck-pr

Conversation

@throny

@throny throny commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

Small CPU-filled render targets in memory that write-watch does not cover (the GPU_UPLOAD part of the unified-memory window with XCL_UMA_DRIVER=mixed:<a>:<b>) are caught only by the unwatched re-check in title_textures.rs. That re-check fingerprints three 16 KiB slices (start, middle, end) at 4, 12, 40, 120 and 400 frames after the last whole upload, and drops the texture after five unchanged checks. A glyph cache that the title fills letter by letter is written later than that and outside those slices, so the new glyphs never reach the PC texture and the on-screen control hints in a retail title's world show only a few letters. In that run's log, 4 of the 7 logged glyph-cache textures were in that range and no "streamed unwatched re-uploads triggered" line appeared.

Part of #1049 (letters missing from glyph text; that issue's RDNA4 flicker may have another cause).

What is in it

  • D3D12.X: keep re-checking small CPU-filled targets in unwatched memory, in crates/xcl/src/hle/d3d12x/title_textures.rs:
    • A render target / UAV texture kept in step with the CPU (Entry::target) of up to 4 MiB is no longer retired after the last milestone. After an unchanged check it is checked again every 16 frames for as long as it lives. A change still resets it to the first milestone.
    • Up to 512 KiB, its fingerprint hashes the whole contents instead of three slices, so a glyph written anywhere is seen. The baseline and the check use the same function (stream_fingerprint).
    • Unchanged: watched memory, paged textures, and non-target (streamed) textures, which keep the five milestones and the sampled fingerprint.
    • Stagger: the first steady check of a texture is moved by 0..15 frames from its address (steady_offset), so textures seeded on the same frame do not stay due together.
    • Budget: the steady checks of one frame read at most 4 MiB (STREAM_STEADY_BUDGET); a check over it waits for the next frame, oldest due first, and the first check of a frame is always made. The milestones (4, 12, 40, 120, 400) are not limited.
    • Cost: the steady schedule covers every render target / UAV texture of 4 MiB or less that the GPU has not written, in unwatched memory. Worst case per frame = the budget (4 MiB copied and hashed on the submitting thread); with the title's 7 glyph caches, at most 3.5 MiB on a frame where all are due, about 224 KiB per frame on average.
    • Tests: stream_recheck_keeps_checking_small_targets_and_hashes_all_of_them (an unchanged target is still scheduled after 900 frames, and a write outside the three slices queues it; fails on main), steady_recheck_is_only_for_small_targets, steady_rechecks_are_staggered_and_kept_to_a_byte_budget (300 targets of 256 KiB seeded on one frame: no frame over the budget, each checked again within 40 frames; pins the 16-frame interval).

Tested

  • Hardware: NVIDIA GeForce RTX 4080 16 GB, driver 621.40, Intel i9-12900K, Windows 11, rustc 1.100.0 (0ef1bc386 2026-11-09), debug. Head commit cd0a688, no uncommitted changes.
  • cargo test -p xcl --lib -j 8 -- title_textures --test-threads=2: 68 passed, 0 failed, 1 ignored.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 2888 passed, 1 failed, 51 ignored. The failure, gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, also fails on main (9dfbe3e), run alone.
  • 24 SKIPPED lines: 22 no wave64 (this GPU is wave32 only: gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole, the gpu::recomp::lower* and gpu::recomp::tests::*wave* tests), heap_window_out_of_memory_falls_back_to_the_switch_form and hle::d3d12x::bind::tests::two_pass_binds_set_the_shared_view_heap (no heap windows), shaders::tests::pso_measurement_compiles_an_exact_synthetic_record (cannot disable the driver cache: Windows Developer Mode is required).

Regression run (scripts/smoke.ps1 -Game <title folder>, same title, 60 s)

main (9dfbe3e):

xcl-smoke v1
commit: 9dfbe3ea6653a9c76ef3ea0d66187a4b5407483b
gpu: NVIDIA GeForce RTX 4080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1620 (PresentX 1620)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15685 MB

this PR's head (cd0a688):

xcl-smoke v1
commit: cd0a6883ee53540e1743b75778c93b1c9aca1cca
gpu: NVIDIA GeForce RTX 4080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1688 (PresentX 1688)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14953 MB

An earlier pair of runs was discarded because other GPU work ran at the same time.

Not tested

  • The retail title's own glyph text in its world: whether the control hints are complete with this change is not shown on screen yet. The 60 s smoke run does not reach the world.
  • is_small_cpu_filled_target still rejects a 4096x64 R8 target (wider than 2048). That is a separate change and is not in this PR.
  • AMD / wave64 hardware.

AI use

  • Claude Code: Claude Opus 5.5 wrote the code, the tests and the description draft; Claude Sonnet 5.5 rebased it onto main, ran the test suite and the smoke runs, and prepared this PR.

🤖 Generated with Claude Code

Small CPU-filled render targets in memory that write-watch does not cover
(the GPU_UPLOAD part of the unified-memory window with
XCL_UMA_DRIVER=mixed:<a>:<b>) are caught only by the unwatched re-check in
title_textures.rs. It fingerprinted three 16 KiB slices (start, middle,
end) at 4, 12, 40, 120 and 400 frames after the last whole upload and
dropped the texture after five unchanged checks. A glyph cache the title
fills letter by letter is written later than that and outside those
slices, so new glyphs never reached the PC texture and a retail title's
on-screen control hints showed only a few letters (4 of its 7 logged
glyph-cache textures were in that range).

A target of up to 4 MiB is no longer retired after the last milestone: it
is checked every 16 frames while it lives, and a change resets it to the
first milestone. Up to 512 KiB its fingerprint hashes the whole contents
(stream_fingerprint, used for both baseline and check). Watched memory,
paged textures and non-target textures are unchanged.

Cost is bounded: the first steady check of a texture is moved by 0..15
frames from its address (steady_offset), so textures seeded on the same
frame do not stay due together, and the steady checks of one frame read
at most 4 MiB (STREAM_STEADY_BUDGET); checks over it wait for the next
frame, oldest due first, and the first one of a frame is always made.
The milestones (4, 12, 40, 120, 400) are not limited.

Tests: stream_recheck_keeps_checking_small_targets_and_hashes_all_of_them
fails on main; steady_rechecks_are_staggered_and_kept_to_a_byte_budget
(300 targets of 256 KiB seeded on one frame: never over the budget in a
frame, each checked again within 40 frames).

Part of xcl-dev#1049.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:amd Code is specific to AMD / RDNA / wave64 GPUs (scope tag; see needs:amd-test) labels Nov 30, 2026
@Aniseto

Aniseto commented Nov 30, 2026

Copy link
Copy Markdown

Ran the title_textures group from the description at cd0a6883 on an NVIDIA Blackwell desktop part with 16 GB of VRAM, then repeated the same command on main 9dfbe3ea built in a separate target directory.

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.98.1 (48a229cea 2026-09-01), MSVC 14.44.35207, DXC 1.9.2609.5, debug build, XCL_ADAPTER=NVIDIA, detached worktree at the exact PR head, no local patches.

XCL_ADAPTER=NVIDIA cargo test -p xcl --lib -j 8 -- title_textures --test-threads=2        (cd0a6883)
63 passed; 5 failed; 1 ignored; 2703 filtered out      (exit 101)

XCL_ADAPTER=NVIDIA cargo test -q -p xcl --lib title_textures -- --test-threads=1           (cd0a6883, serial)
63 passed; 5 failed; 1 ignored; 2703 filtered out      (exit 101)

same first command on main 9dfbe3ea (own CARGO_TARGET_DIR, rebuilt)
61 passed; 4 failed; 1 ignored; 2703 filtered out      (exit 101)

The description records 68 passed, 0 failed, 1 ignored for the first command; on this host it is 63/5/1 over the same 69 selected tests (the filter selects 66 on main, 69 here, so this head adds 3 tests).

The first failure is the root: hle::d3d12x::title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels panics with assertion left == right failed: row 5: stale shadowed texture corrupted B at title_textures.rs:6396 at the PR head and at title_textures.rs:6321 on main (a second main run stopped earlier in the same test at title_textures.rs:6297, the row 3 assertion), with stdout 512 unreleased 1 MiB textures over 16 MiB. The other four at the PR head (stream_recheck_keeps_checking_small_targets_and_hashes_all_of_them, stream_recheck_keeps_the_whole_upload_baseline_over_partial_uploads, stream_recheck_partial_upload_without_an_entry_queues_a_whole_upload, stream_recheck_schedule_catches_late_writes_and_resets_milestones) panic with PoisonError on a lock, consistent with it having been poisoned by that first panic (in the serial run it failed first, at 36/69, and the other four after it). On main the same three pre-existing stream_recheck_* tests fail the same way; stream_recheck_keeps_checking_small_targets_and_hashes_all_of_them is new in this PR, which is why the totals are 5 failures here and 4 there.

Run alone at cd0a6883, each of the five passes (1 passed, 0 failed, 0 ignored each), and so do the two steady_recheck_* tests of the description (1/0/0 each). The same test also passes alone on main. So the group failure reproduces on main on this host and is not introduced by this head.

Not tested: the full workspace suite, a title that fills a glyph cache letter by letter (the #1049 scenario), XCL_UMA_DRIVER=mixed:<a>:<b> in a real title, native wave64 hosts, AMD and Intel GPUs, Wine, release profile, game data.

AI-assisted (OpenCode), model: MiMo-V2.6-Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

@Gevroska

Copy link
Copy Markdown

@throny I tested the late texture refresh on my RTX 3080 (driver 616.92). I used the same 256×256 R8 texture fixture on main at 9dfbe3ea and on the PR at cd0a6883. I verified that the texture backing was in the unwatched GPU_UPLOAD segment, advanced the fixture to frame 800, then wrote 0xB6 across the backing and checked the native texture by GPU readback.

Revision Result after the late CPU write
main No refresh was queued over the next 32 synthetic frames. 0 of 65,536 texels contained 0xB6.
PR head A refresh was queued 13 synthetic frames after the write. All 65,536 texels contained 0xB6.

The watched control texture updated on both revisions. This confirms that the PR picks up a late write after stock has retired the texture. I used a whole-backing write, so localized glyph writes and visible text in the retail game remain untested.

I used Codex GPT-6.2 Sol to adapt and run the fixture. A separate GPT-6.2 Sol agent reviewed the source and original GPU results. Codex GPT-6.2 Astra drafted this comment.

I reviewed and approved this comment before posting.

@throny

throny commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator Author

In-world check running: this PR's head cd0a6883 vs its base 9dfbe3ea, RTX 4080, four alternating 600 s runs, same save and inputs, judging whether the in-world text (control hints, HUD) is complete. Results here when done.

AI use: Claude Code (Claude Opus 5.5).

@throny

throny commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator Author

Update on the in-world check: the two runs of this PR were invalid on our side (our local input-timing patch was missing from the PR build, so the scripted presses never reached the game and it stayed in the account-select menu; the menu text there was complete). The base runs reached the world. Rerunning the PR build with the patch after the runs now on the GPU. @Gevroska thanks for your RTX 3080 report; I'll answer with the world result.

AI use: Claude Code (Claude Opus 5.5).

@throny

throny commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator Author

World result, and it is negative: this PR does not bring the missing letters back. RTX 4080 16 GB (621.40), this PR's head cd0a6883 (plus our local input-timing patch) vs its base 9dfbe3ea, same save and inputs, XCL_SPLIT_INDIRECT_ROUNDS=1, frames saved every few seconds.

  • PR run 343 (full 600 s): right after the loading screen the left-side control hint box shows its button icons, but its two labels render only a few letters each, the rest missing — the same symptom reported on main. No subtitles appeared in the sampled frames. Menu text (account select) is complete in both builds.
  • PR run 342 ended at 190 s with an access violation, before that phase; base run 344 lost the device (0x887a0006) at 97 s, before the world. So stability does not separate the two builds here (one failure each), and there is no base frame of the same phase; but the PR frame alone shows the fix does not cover this text.

Turning this into a draft. The glyphs are probably not CPU-filled small targets in unwatched memory, which is what this PR re-checks. @Gevroska, thanks for your RTX 3080 report above.

AI use: Claude Code (Claude Opus 5.5) checked the frames; runs and frame sampling by Claude Sonnet 5.5 / Haiku 5.5 sub-agents.

@throny
throny marked this pull request as draft December 1, 2026 02:28
@thehollowedone

thehollowedone commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Correction to my earlier review: I misread the state transition. An eligible small target enters the steady schedule after its first unchanged milestone, including the +4 check after a change. The 280-frame delay I claimed does not occur; I withdraw that finding.

There is a shorter, concrete deadline regression in that transition. Seed a 256 KiB target at frame 0 with an address whose steady_offset is 15. Let the +4 check find it unchanged, then write a byte at frame 5. With rechecks each frame and no budget contention, the base checks at frame 12; this head moves base_frame to 19 and next checks at frame 35. The write therefore waits 23 more frames than on the base. Please retain the +12 milestone before switching to the staggered steady schedule, and test this sequence through recheck_streamed_unwatched_at, including the queued upload. This is a source-derived schedule, not a measured glyph or frame-time result; the author's world replay did not restore the missing text.

Separately, the budget filter does quadratic ID searches on the submission thread. With 1,024 overdue 512 KiB targets, eight fit 4 MiB and 1,016 are deferred. check.retain(|c| !skipped.contains(&c.0)) makes 524,764 ID comparisons before any hashing. A set of deferred IDs, or constructing the check list from accepted entries, keeps that partition linear. A regression can exercise the production partition with a large overdue batch and a milestone entry, checking classification and bounded lookup counts without a timing assertion. No hitch was measured here.

AI use: Codex (GPT-6.2 Sol) rechecked the source and arithmetic; Codex (GPT-6.2 Astra) identified the state-transition misread and the backlog path.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Review (head cd0a688, diff read, not a merge-check; draft, so not built or run):

  • The worst case per frame is not the 4 MiB budget. stream_fingerprint now hashes a steady target of up to 512 KiB in full, and it is also used when a texture is recorded and at the milestone checks (4, 12, 40, …), which have no limit. So a level load that creates ~200 small RT/UAV textures in unwatched memory that the GPU hasn't written means ~100 MiB copied and hashed on the submitting thread four frames later. Main reads ~9.6 MiB there (48 KiB sampled each). Either sample at seed/milestones and hash in full only on steady checks, or correct the cost line in the description.
  • steady_rechecks_are_staggered_and_kept_to_a_byte_budget doesn't run the real scheduling. It builds its own due list and only uses steady_checks_over_budget. It would still pass if recheck_streamed_unwatched_at dropped a check pushed back by the budget or used the offset wrongly. assert_eq!(STREAM_RECHECK_STEADY, 16) only pins the constant.
  • Targets between 512 KiB and 4 MiB are checked every 16 frames for as long as they live, but still with the three-slice sample, so a write outside those slices is still missed (e.g. a 1 MiB R8 glyph atlas). The 256 KiB caches the description targets are covered.
  • Note: D3D12.X: drop retired textures from STREAM_RECHECK #2578 also changes how STREAM_RECHECK entries are removed in this file. They look complementary, but expect a small conflict in the tests.

Fine: a check pushed back by the budget keeps its state and goes first the next frame, a change sends the texture back to the first check, and GPU-written textures still leave the re-check. stream_recheck_keeps_checking_small_targets_and_hashes_all_of_them fails on main as claimed.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@thehollowedone

Copy link
Copy Markdown
Contributor

Correction to my earlier #3537 review: the claimed 280-frame wait was wrong. I edited that comment to withdraw it and document the verified shorter deadline case and an independent quadratic backlog cost. Please use the corrected version.

@throny

throny commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator Author

Closing: the world run above shows it does not fix the missing letters, which was its purpose. Branch kept on throny/xcl.

AI use: Claude Code (Claude Opus 5.5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:amd Code is specific to AMD / RDNA / wave64 GPUs (scope tag; see needs:amd-test)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants