- Move title_memory_map::changed() into TitleHeap::hooks.commit/decommit and !from_mirror_heap in free_title_block()
- Share Cell::known_* across CellGuard & TitleTextureCells (no PAGE_READONLY no-guard cache; MEM_RESERVE intra-pass in TitleTextureCells, cross-pass in CellGuard; seed on xmem::map_view)
- Persist TitleTextureCells VQ cache across outer batches; bridge across run_already_armed_ tiles with uniform restore[0..15] up to kMaxBridgeGap=64
- Persist 1024-entry local_mirror per ConsoleHeap*, flush Phase A/B disjointly, handle !base V#s in Phase A, skip redundant WC BAR writes for waiting T#s
- Fused SEH-safe AVX2/SSE2 guarded::copy_and_sum_256(), kMaxWorkers=8, single-reader title_write_watch::ask() fast path preserving mark() entries
AI-assisted: Antigravity (Gemini 4 Neon).
Eliminates the async readback page_mirror.mutex convoy and serial fallback, and reduces page-mirror refresh cost:
- title_mirror.h / d3d12_vulkan_device.cpp: lifts WorkerPool for lock-free Phase 1 prehash_readback_slice() outside page_mirror.mutex and single-call Phase 2 write_back_prehashed() under lock (256-page slice: 0.11 ms unlocked, 0.03 ms locked), eliminating the 256x serial single-page fallback and merge_ranges() storm.
- Scopes readback invalidation to readback_slice_frames with per-frame 256-bit readback_slice_skip_masks populated from TitleMirror::upload(on_changed), preventing hot-page retry loops while preserving CPU-wins conflict semantics.
- Coalesces contiguous GPU write-back runs, batches deferred map() initial fills in parallel upload(), and replaces fed_now unordered_set with a flat sorted vector.
- title_mirror_hot_cold.h: consolidates CellGuard maps into a single TrackedCell map and adds a changes_since()-invalidated known_protect cache to halve cold re-arm VirtualQuery syscalls.
AI-assisted: Antigravity (Gemini 4 Neon).
Promoting 1x/frame pages to unguarded hot caused HotColdTracking to copy
~5,000+ pages on every submission (~50 GiB/10 s) and dirtied all textures
sharing those tiles (~119 ms/sub). Restore the submission-hot (6/8)
policy where unguarded copies beat fault+copy cost, and accumulate actual
CPU+wait time in AsyncReadback::cpu_ms instead of async wall-clock span.
AI-assisted: Antigravity (Gemini 4 Neon).
Cache bound pipelines, descriptor sets, dynamic graphics state, and dirty
push-constant sub-ranges across command lists in emit_commands() (with
invalidation across internal compute helpers and rendering boundaries),
and restore the two-tier submission-hot + presented-frame-hot policy in
TitleWritePolicy/HotColdTracking wired to present_serial.
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).
Root-cause fixes for four audited bugs in console heap in-place filtering
and TitleMirror:
1. finish_in_place() not_tsharp zeroing & record clear:
Check gfx10::is_image(words) and TitleImage::not_tsharp in
finish_in_place(), zeroing w[0..3] and clearing heap.records on
(w[3] >> 30) slots with d.texture == Records::none (matching
fix_console_slot) so non-T# overwrites of deferred slots never leak
raw words into home[slot] or leave stale texture records.
2. Record-answered / batch_answers mirror write-back tracking:
Call note_title_write(base, span) outside page_mirror.mutex when
apply_answer() (in finish_in_place) or answered_by_record() (in
fix_vsharp) returns a mirror-resolved identity target
(to == base && base >= arena.size), matching vsharp_address path 6.
3. reachable_as_written() & filter_slot_locked() semantic parity:
- Reject base == 0 in reachable_as_written(), check encodable() +
gpu_backings + geometry.lookup, and accept bit-47 base | ~mask
direct backings even when signed_vsharp_offsets() is off (matching
vsharp_address:4367, 4392). Track non-sparse direct backings as
Records::resolved so target_gone re-filters them if freed.
- Keep O(1) permanent rejection (Records::none) only for null base,
unbacked bit-47, and out-of-arena-span offsets (base < arena.size
not in title_memory, aliases, or stream-pool GPU views).
- For unresolvable base >= arena.size halves (not in title_memory
within span, no alias, no stream-pool GPU view), null in O(1) and
record Records::waiting directly without deferring so a later
SlotChange::source_added still wakes and re-filters them.
4. TitleMirror single-snapshot home/sums/copy sync:
Unify home, home.sums[], and filtered copy updates through a single
fill_scratch_ snapshot across map() (initial aliased fill & alias
handoff), make_copy(), and finish_write_back(), preserving GPU-only
pieces on existing homes so A -> B -> A writes never leave stale
filtered copies and avoiding duplicate guarded copies.
Tests:
- title_mirror_hooks_test: added make_copy_aba_staleness (make_copy,
alias handoff, finish_write_back A->B->A) and updated
filter_pieces_mask_and_scratch for unified single-copy initial map.
- console_heap_slot_records_test: added waiting_source_added_and_tsharp_clear.
- d3d12_heap_in_place_test: added deterministic finish_in_place not_tsharp
zeroing and late-alias wake-up regressions.
AI-assisted: Antigravity (Gemini 4 Neon).
- TitleWritePolicy (runtime/src/title_write_policy.h): lower submission-hot
threshold (kPromote 6 -> 3 of 8), add O(active) present_frame() frame-hot
tier (kFramePromote = 3 of 4, kFrameProbe = 16, unguarded on low-sub frames
<= 4 subs/frame and guarded on high-sub frames so mid-frame CPU writes are
never missed and 1-write/frame pages never copy 30x/frame), and sort/batch
page arms via optional Guard::arm_batch().
- HotColdTracking (runtime/src/title_mirror_hot_cold.h): expose on_present(),
coalesce contiguous 64 KiB VirtualProtect re-arms in CellGuard::arm_batch(),
and route MEM_WRITE_WATCH pages through title_write_watch::ask() with zero
guard faults or hot_tiles conflicts.
- TitleMirror (runtime/src/title_mirror.h): add optional TitleMirrorHooks::
filter_pieces hook passing fill_scratch_ and the 256-bit changed-piece mask
from fill() (eliminating duplicate 64 KiB guarded copies), and coalesce
contiguous changed pieces into single WC-friendly memcpy bursts while
preserving exact home.sums conflict detection.
- TitleHeap (runtime/src/title_heap.h): add portable reserve() helper for
MEM_WRITE_WATCH with silent fallback and write_watched() tracking.
- Tests: add unit tests in title_write_policy_test.cpp,
title_mirror_hooks_test.cpp, and title_heap_test.cpp.
AI-assisted: Antigravity (Gemini 4 Neon)
- TitleMirror (runtime/src/title_mirror.h):
- Add has_pending(va) and skip pages with unflushed pending_ binds in
homes_in(), homes_in_ranges(), write_back(), and write_back_batch() so
write-back never copies stale/unbound sparse chunk bindings over live CPU
memory.
- Pass each page's physical frame address (mapped->second + k * kPiece) to
the write-back callback instead of its virtual address so concurrent CPU
remaps cannot receive a previous mapping's bytes.
- Replace the unconditional O(homes_.size()) refilter scan at the end of
write_back() with an O(changed) local list of touched aliased homes.
- Add HomeRef, homes_in_ranges(), and write_back_batch() for batched
multi-range GPU readback with concurrent-remap frame validation.
- Copy a full 64 KiB page in one hooks_.copy call inside fill() via a
reusable member scratch buffer, falling back to 256-byte pieces only if
the whole-page copy fails.
- TitleHeap (runtime/src/title_heap.h):
- Add a per-span live-slot occupancy bitmap so release() rejects small-block
double-frees without duplicating the freelist, and size_of()/release()
reject freed slots, interior pointers, and unused span tails.
- Unit tests (title_mirror_hooks_test, title_heap_test):
- Add regressions covering pending_ skip, physical-frame destination,
O(changed) refilter scaling over 10k+ homes, 1-shot fill + per-piece
fallback, batched multi-range coalescing/conflicts/remap skip, and
TitleHeap double-free / interior-pointer / tail-slot rejection.
AI-assisted: Antigravity, Gemini 4 Neon
The title keeps plain data inline in its descriptor heap pages and points V#s at it. With one filtered home bound
at both addresses, the filter's output reached those V#s: four words a compute program reads as sizes looked like
a V# with a base nothing holds, three of them were nulled, the program read [0 0 0 720] and spun until the ring
timeout.
title_mirror.h: alias(lo, hi, buffer, offset) gives each page of the range a second home, the filtered copy, bound
at the alias in the same batches as the mirror's binds and filled by hooks.filter whenever the title's bytes change
(a piece's sum, or write-back); the page's own home is always the title's bytes. filter_range, unfilter_range and
filtered_at are gone; copy_bytes(va) is the copy the filter's caller writes slots into; unalias takes the ticket its
copies are freed after; write_back and homes_in take every home again.
The device writes slots into the copy (apply_in_place_changes, finish_in_place). An unreachable V# half is null
whole, all four words, in the filter and in fix_vsharp.
d3d12_heap_in_place_test: inline data after a table, a V# of the title pointing at it, and a rewrite on the same
page: the V# reads the title's four words, the table the filtered entries ([0 0 0 0] for the data), the title's
bytes unchanged; on the previous commit it read [0 0 0 720] at both addresses. A GPU store into the heap's page
now goes back to the title's bytes. title_mirror_hooks_test covers the alias's own homes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
title_mirror.h: a filtered page's sums per 256-byte piece are of the title's bytes (title compared with title); the
filter runs after that compare, only when a piece changed or the home is fresh, and writes the home. write_back skips
a filtered home, so page_mirror_write_back takes TitleMirror::write_back as is. A home leaving its filter is copied
whole once.
The T# index word (tsharp_index_word) is written by finish_in_place into the home's dword 6 once the T# is bound; the
filter leaves 0 (the fallback) there meanwhile, so the title's own dword 6 is never read as an index. Copy-path heaps
keep fix_console_slot's write. d3d12_heap_in_place_test checks a T# slot reads the tag and index while the title's
bytes keep their dword 6; title_mirror_hooks_test checks write-back skips filtered homes and the filter is not called
again for unchanged title bytes. set_tsharp_index_words_for_test for the test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the mirror's steps B and C (title memory resolved to heap_base + its address, ordinary memory mirrored when a
reader names it, the write-back of GPU stores from the homes, a separate bind flush), the in-place filter changes:
- Lock order console_heap_mutex, then page_mirror.mutex, then slot_change_mutex. vsharp_address's mirror path takes
the mirror's lock under console_heap_mutex now, so the filter, which runs inside the mirror's fills, takes no other
lock of ours: the in-place heaps' filter state is under the mirror's lock (page_mirror.in_place), and the mirror's
refresh no longer takes console_heap_mutex. Under the lock the filter does only reachability (arena, a buffer of
ours, or the mirror through page_mirror_resolve_locked, which names ordinary memory as any reader does), nulls and
the list of what is left: a V# the mirror does not hold and a T# to bind are finished in the heap's refresh
(finish_in_place), outside the mirror's lock, and written into the home unless the title rewrote the slot since.
The change list is taken under the mirror's lock when a heap is read in place, so the entries it has not read stay.
- No write-back from a heap read in place: page_mirror_write_back skips filtered pages (TitleMirror::filtered_at), as
their homes hold the filtered slots, not the title's bytes.
- The heap's pages are named to the mirror when the heap is made (ordinary memory is mirrored then), after its
filter range and its second binding are set. The binds go in flush_page_mirror's batch.
d3d12_heap_in_place_test also checks that a GPU store into the heap's pages is not copied back over the title's
bytes; title_mirror_hooks_test checks filtered_at.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two additive hooks in src/title_mirror.h for console descriptor heaps read in place; nothing changes for a mirror
that uses neither.
- alias(lo, hi, buffer, offset) / unalias(lo): the pages of [lo, hi) are also bound into `buffer` at offset +
(va - lo), follow their remaps and unmaps, and go in the same bind batches as the chunk binds, so the one wait
(VulkanContext::note_mirror_bind) orders a reader of either address. A heap uses it to be read below 4 GiB of the
arena, where 32-bit descriptor-table pointers reach. Pages not mapped stay unbound there and read zero.
- filter_range(lo, hi) / unfilter_range(lo) and TitleMirrorHooks::filter: the home of a page in a filtered range is
filled through the filter (the title's bytes in, what the GPU reads into the home), fresh when the home is made or
its filter changes, not fresh on a refill after a write (the home then holds the filter's last output). The
title's bytes are never written: the filter writes the home only, which is the mirror's own GPU memory. A home
shown at a filtered and an unfiltered address holds the filtered bytes; when the filtered address goes it is filled
as a copy again. home_bytes(va) gives a mapped page's home for writing one changed slot between fills. The
counters count filtered fills.
Test: title_mirror_hooks_test (no GPU, fake handles): binds into the second buffer with the chunk binds, after a
map, a remap and an unmap, and none after unalias; filtered fills fresh and not, a copy outside the range, a home
shown twice, refiltering a mapped page, unfiltering, and the title's bytes unchanged. vk_title_mirror_test passes
as before (Ryzen 9 7950X3D iGPU, RADV, Mesa 26.3.1, under validation).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>