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).
Round 1A:
- Use VsharpPath::scratch for in-place console heaps in finish_in_place and fix_console_slot so they never allocate general-purpose title windows.
- Never fall through to make_title_window / ShadowPages in resolve_title_memory for addresses already covered by the page mirror.
- Guard vsharp_address's window-creation fallback with bytes <= kTitleWindowMax so oversized V# spans cannot allocate and reject orphan windows.
- Advance <= 2 GiB reservations in title_mirror_space::take past chunk boundaries so placed buffers stay within a single 2 GiB sparse chunk.
- Track arena-backed title windows and slot-133 shadows under ArenaUse::arena_window and report them in memory_breakdown.
Round 1C:
- Add re-entrancy-safe two-pass filter_heap_page_pieces() ready for TitleMirrorHooks::filter_pieces changed-piece mask.
- Reject guaranteed-unresolvable V# halves (null, unbacked bit-47, out-of-arena spans, non-title addresses without an alias) in O(1) inside filter_slot_locked without inserting into heap.records or deferring.
- Clear deferred slot records before finish_in_place and answer repeated V# halves from heap.records under page_mirror.mutex plus a per-batch dedup cache.
Tests:
- Added Linux unit tests in console_heap_slot_records_test (chunk alignment, arena window breakdown, deferred record clearing/answering).
- Added Wine regression tests in d3d12_heap_in_place_test and d3d12_page_mirror_test.
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>
A slot-133 texture placed where a slot-70 view had made a texture of the layer's takes the address over
(place_at_title_address); register_title_texture then retires the slot-70 entry, and retire_title_texture erased the
address from images_by_address unconditionally - the placed texture's key. Every T# naming that address found no
texture ("no texture at the T# address: title memory"), the texture was never named, so never filled, and the slot
read the fallback.
forget_image_of(address, owner) erases the address and its views only while `owner` is registered there, under one
descriptor_mutex hold; retire_title_texture and ~Resource use it (the latter checked in two steps before). The views
of the retired texture left when the address was taken over.
d3d12_heap_in_place_test: a slot-70 view, then a slot-133 texture at the same address in a reservation at 16 TiB and
up, named by a T# the title writes into a heap read in place: it binds with the tag and its index, reads the fallback
(index 0, the 1x1 zeros) when the texture goes, and binds again when a texture is placed there again. It failed
(index word 0) before the fix.
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>
When every page of a console CBV/SRV/UAV heap lies in the page mirror (a reservation xmem placed in its range),
add_heap_in_place gives it no copy and no page tracker of its own. 25,865 of the corpus's 26,503 shaders keep 32 bits
of a descriptor-table pointer, so the heap's pages are bound a second time into the arena below 4 GiB
(TitleMirror::alias, same bind batches and wait as the mirror's), at a range of whole arena blocks with no arena
memory behind it (arena_reserve_unbacked); the null slots after the heap are that range's rest, unbound, reading
zero. Table pointers go there as before (console_heap_ranges).
The mirror fills the pages' home through filter_heap_page (TitleMirror::filter_range): the title's page is only
read; a slot whose bytes changed since it was last filtered, or that a change touched (the records' change list,
applied at the mirror's refresh before the written pages are filled, filtered straight into the home), is fixed as a
copied slot was, into the home: a V# whose base lies in the arena, the mirror or a buffer of ours stays as the title
wrote it (reachable_as_written, no record); another V# is resolved as before (an interim until every title allocation
is in the mirror) or written with no base and no records and waits; a T# is bound as before [TSHARP-INDEX: its
bindless index in the entry]; other words are null. A GPU write-back is never taken from these pages: the mirror has
none, and no window is made for them.
A heap the mirror does not hold (a device without the mirror, memory outside its range) is copied as before. New
log line per in-place heap: pages filtered and slots changed per submission and per frame, the ms, and the V#
halves read as the title wrote them. arena_gpu_read reads the arena with the GPU after the mirror's last bind
(tests).
Test: d3d12_heap_in_place_test (Wine, iGPU): a heap in physical pages of an XMemVirtualAlloc reservation; the GPU
reads, below 4 GiB, a V# into nobody's memory and a data word null and V#s into the arena and the mirror as written,
while the title's bytes stay as written byte for byte; a rewrite through the title's own view reaches the GPU at the
next refresh, filtered, and the title keeps what it wrote; the null slots read zero. It fails on the copy path. Linux
ctest 123/123.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>