- Zero ResourceDesc padding words [1,2,3,13], compare non-format words + compatible formats in title_texture_matches(), preserve layout-equal slot-133 textures & mirror_hash_valid on unmap
- Guard refresh_title_texture() touch() against unreadable pending_stream textures while preserving deferred backing & publish_streamed_texture
- Zero-syscall already-armed Cell::restore[] check + table-page backed skip + PAGE_READONLY region cache in TitleTextureCells::arm_batch(); sync_tile_peers() skip in examine_batch()
- Snapshot geometry_writes serial before refresh_page_mirror() to skip redundant page_mirror_check_batch() dirtying on both CPU and GPU views; parallelize Pass 3 range_sum() >= 8 MiB
- Decouple GPU-mirror batching (512 jobs / 128 MiB) from CPU 64-slot limit, single-call vkAllocateDescriptorSets per sub-batch, kMaxScratchSlots=64, 4-part examine_ns telemetry
AI-assisted: Antigravity (Gemini 4 Neon).
Routes page_mirror_check_batch() uploads through note_readback_pieces_uploaded_locked() and console-heap page invalidations through note_readback_frame_invalidated_locked() so unrelated pages never poison readback_invalidated; renames a shadowed parameter in title_texture_watch_test.
AI-assisted: Antigravity (Gemini 4 Neon).
Eliminates false CPU-staged re-uploads, per-texture page_mirror.mutex churn, and unbatched tile re-arming:
- d3d12_vulkan_device.cpp: replaces per-texture page_mirror_texture_chunk/page_mirror_tiles_unchanged with a single-lock page_mirror_check_batch() snapshotting pending xmem remaps under shared feed_lock (rejecting only overlapping textures) and running one batched parallel TitleMirror::upload(); adds TitleJob::previous_mirror_hash check in hash_title_job() so GPU-uploaded textures falling back to CPU skip unchanged re-uploads; separates lock_wait_ns from collect_ns.
- title_texture_watch.h / title_texture_refresh.h: adds examine_batch() + TitleTextureCells::arm_batch() coalescing pins and contiguous VirtualProtect runs, uses direct Tile*/Texture* pointers in watch indices, and merges write/map ranges before iteration.
AI-assisted: Antigravity (Gemini 4 Neon).
Cuts per-submission texture refresh overhead and prevents passive write-back accumulation across overlapping queues:
- title_texture_refresh.h: adds shadow_keep::sum_of-backed mirror_range_sum helpers and PassiveWriteBackTracker with retire_id watermarking so overlapping direct/compute queues promote each passive V# range without re-promoting stale ranges indefinitely.
- title_texture_watch.h: skips hot_tiles() rescans when hot_generation() is unchanged and tracks non_hot_arms to reuse synced shared hot tiles per pass.
- d3d12_title_image_upload.h: reuses detile scratch buffers across sub-batches and skips detile setup when unused.
- d3d12_vulkan_device.cpp: extends TitleMirror range_sum() skip to all 256B-aligned and partially mirrored textures, filters dirty chunk syncs by title_written_ (guarded by !t.stale), caches can_gpu_upload(), pools TitleJob buffers, runs inline single-item reads/hashes, and defers t.pieces commits until upload success.
AI-assisted: Antigravity (Gemini 4 Neon).
Guard GeometryViews retirement with command_list_epochs, defer TitleMirror
freed-home ticket stamping until flush + note_mirror_bind under submit_mutex_
(including TitleImageUpload submits), fix queue lock ordering and lock-free
wait_submitted, remove dead helpers and process labels, and scrub game shader
identifiers from docs/design.md.
AI-assisted: Antigravity (Gemini 4 Neon).
Two trackers guarded the same 64 KiB pages through the same cells: the page mirror's HotColdTracking and the
title texture watch. When the mirror found a page hot it reopened the cell behind the other's back; the texture
watch then armed it again, so the page faulted at every write for one tracker while the other meant it to be
writable (two guards racing on one page), and when the mirror turned a hot page cold for a probe, a write made
while it was hot reached no other tracker at all (the video plane's write of that interval was never uploaded).
One owner of the guard now: the cell. An owner that leaves a page writable holds it hot (geometry_writes::
set_hot); a hot cell is not armed by anyone and hot_tiles() lists it, so the texture watch takes it as written
at every pass; when the last owner lets go, the cell counts as written once more for every subscriber.
HotColdTracking holds its hot pages that way and ignores its own hot-to-cold turn (a cell that has not moved
since it was armed was not written).
Also: the FSDRAW census reset the refresh line's passes, changed and filled counters, which then read 0 uploads.
Test: title_mirror_hot_cold now runs the texture watch over the same cells as the mirror's tracking: the plane
written every interval is named at every interval, probes included, and its page stops faulting once hot.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run 60: 80 % of the looks were whole reads, 89 % of them unchanged. index_texture runs at every Map of a
slot-133 texture, at a layout found by a view and at a first naming, and each call re-tracked the texture:
its tiles were released and acquired again (so not armed) and it was named, so the next pass read it whole
although nothing had been written. Tracking again over the same tiles now changes nothing; a texture that
must be read (never filled, or known changed) is touched instead. Fills made outside the refresh (at a
slot-70 view, on the fill worker) now keep part hashes too, so the next written tile is decided by parts
rather than by a whole read. A line every 10 s counts whole reads by why: never filled, no part hashes,
one tile (its part is all of it), every tile written, no tile written.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Blocks of older frames in run 58: a texture without GPU-write flags placed over the memory of a GPU-written
one (a render target, depth or UAV texture) was filled from the title's pages there. Those pages never hold
what our GPU renders into the target's image, only what the CPU last put there, and every write mark over
them (a write-back of a GPU copy, a neighbour's write in the same tile) re-uploaded those old bytes. The
registry now keeps the CPU-view range of every GPU-written texture (DeviceState::gpu_owned), and a texture
over such a range is not watched or filled by the refresh (index_texture); one already watched stops when the
target is registered. Test: d3d12_existing_heap's "texture over a render target's memory" (fails without
this: the written 64 KiB piece shows in the texture).
Upload at first use: a title texture no descriptor names is not read, uploaded or watched. Its first
descriptor of any kind (a D3D12 view, a slot-70 view, a T# the title wrote into a console heap: all reach
Resource::note_shader_view) queues it, and the refresh before that submission reads it whole and uploads it.
A texture whose descriptors are all gone later stays on the write-driven path (nothing counts them down).
Reads by written tiles: each texture keeps a hash of its part in every 64 KiB tile (TilePieces). When some
of its tiles were written, those parts are hashed in place first; equal, and the texture is unchanged
without a whole read. The watch reports writes per 64 KiB tile (the geometry cells' fault reopens a whole
tile), so a neighbour in a written tile costs its share of that tile, not a read of all of it.
The 10 s line: textures written or new, read whole, found unchanged by their parts, uploaded, named for the
first time, not named by any descriptor (not read), ms a pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run 57 showed 99.9 % of the arms refused, 60,637 tiles not armed and about 8,700 textures looked at per pass
(60-68 ms a pass). The refusals were this watch's own: a tile with any page not committed was refused, so
every streamed texture registered before its memory arrived was named and its arming retried at every pass,
and a texture never filled because its memory was not readable was named again at every pass too.
Now pages not committed are left as they are: xmem's commit or mapping bumps the tile's cell, and the mapping
change makes the textures over it probe their memory again. A texture whose memory is not readable is not
named again until then, except one the title mapped (its pages may be committed under the Map pointer). A tile
pinned for a kernel write is busy: the texture is not read (which uploaded half-written textures at every pass
until the write ended) and is read once the pin is gone. Only a tile whose guard cannot be set is read at every
pass. The log line counts busy looks and arms apart from refusals.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Before every submission (at most every 16 ms, and not at all when a view held the registry), the refresh hashed
every mapped or stale texture and a round robin of the rest (sampled, a full hash every sixth pass), within
byte and time budgets that could split the planes of one video frame over passes.
Now each title texture filled from memory is watched through the geometry watch's cells: its 64 KiB tiles, at
its CPU view and every other address xmem maps them at, are armed read-only; a write faults once per tile, and
the fault, a mapping change or a kernel write's opening queues the tile (geometry_writes::WriteQueue, new). The
refresh, at every submission and with the registry waited for, takes that queue and reads only the textures over
the written tiles (TitleTextureWatch, src/title_texture_watch.h), arming them again before the read; a texture
nobody wrote costs nothing. A tile that cannot be armed (not committed, pinned, no fault handler) names its
textures at every pass: the one fallback. A fill whose full hash equals the last one uploads nothing. A slot-70
view no longer hashes its texture: it fills only one never filled or known changed.
Removed with the hash pass: LEONIDA_TITLE_TEXTURE_PERIOD_MS, _CHECK_KB, _FILL_MB, _FILL_MS,
LEONIDA_TEXTURE_HASH_BUDGET_US, LEONIDA_TEXTURE_SWEEP_BUDGET_US, LEONIDA_TITLE_EVERY_BUDGET_US,
LEONIDA_TITLE_VIEW_REFRESH_MS and the async mode LEONIDA_TEXTURE_REFRESH_ASYNC (its worker pass, first-use
fills, mapped list and range index). A line every 10 s counts passes, textures looked at, uploaded, unchanged,
written tiles and arms.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>