A pending stream texture whose first bytes arrive through a noted write (the pending slot-70 views case of
d3d12_existing_heap) kept its cached unreadable answer and was never filled.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A list value wait (wait32/wait64) that is not met at submission holds its queue until memory meets it. The fixed
200 ms timeout, LEONIDA_VALUE_WAIT_TIMEOUT_MS and the 4 ms demotions are removed (in Linux world runs 14-63 gates a
run timed out with the writer's value not there yet).
A held gate goes without its value only when nothing else can make progress (releaser idle, no title
ExecuteCommandLists in progress, nothing of the pump's running on the GPU; work the layer holds behind a wait is not
running, asked through the new rt::d3d12::fence_signal_submitted), and then only: in a cycle (at once), at a present
queued behind it (VIctory-Belobug-AMD's rule, queue/behind.rs step, queue.rs release_held), or when the title has made
no queue call for 2 s; every gate goes at device loss. src/list_value_progress.h (portable) replaces
list_value_wait_budget.h. Each release is logged with gate, queue, wait and reason; released waits met later are
counted. stop() drops gates it leaves shut so they no longer hold their queues.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A title-written T# that found no texture went on a retry list that every submission tried again, round robin, for
500 us (LEONIDA_CONSOLE_RETRY_US). World runs had up to ~35,000 waiting, 200-550 retried per submission, and every
retry counted again as a T# "naming no texture" (1.56 million in 27 log windows of one run). A bound T# whose texture
went never came back unless the title rewrote its slot.
The per-slot records of RT-VSHARP-SLOT-RECORDS now hold T#s too (src/console_heap_slot_records.h): the exact base
address and bound / waiting / waiting for room, with an index by that address. Texture changes go on the same change
list: note_image_address, a GPU placement added and a streamed texture published (texture_added), forget_image and a
placement removed (texture_gone), freed bindless entries (texture_room), each also at the other view of pool memory.
The next submission fixes exactly the T#s naming the address. A V# refused a geometry copy for lack of room is fixed
again when geometry copies are freed (geometry_room, GeometryViews::free_generation), closing the gap A1 left.
"No texture at the T# address" is counted in "unbound T#s by reason" by what the address is: title memory, a texture
of ours that is gone, low 32 bits naming one of ours (same shape / other shape / gone), or none. The slot records
line gives T#s recorded, waiting, fixes left waiting and refills.
Removed: retry_console_slots. LEONIDA_CONSOLE_RETRY_US applies only to the opt-in GPU heap pass now; slots deferred
by LEONIDA_CONSOLE_FIX_US are fixed first at the next submission (fix_deferred_slots).
Tests: console_heap_slot_records_test (T# and room cases), new d3d12_tsharp_refill_test (the last of 60,001 waiting
T#s samples its texture at the first submission after it appears; its T# leaves the hash table when it goes),
d3d12_unbound_tsharp_rules_test (address classes). Linux ctest 115/115 (llvmpipe); Wine suite (clang-cl, iGPU RADV)
425 pass / 24 fail, against test/three-fixes 425/23: d3d12_tsharp_refill new and passing, xmem (known flake) the
only pass->fail.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The adaptive gate never probed in two runs because no single wait reached
the 15 s limit: on NVIDIA 621.40, 80 waits of 3-7 s back to back (90 s in
all) kept the title's main loop from reporting for 30 s and its watchdog
ended the run; on an RTX 4060 with the watchdog kept kicked the limit was
0, so nothing could probe, and 459 waits of up to 2.9 s took 155 s by
t=202 s.
Until a verdict is in, a submission now also goes ahead once the waits at
the gate in the last 10 s, its own included, add up to
LEONIDA_COMPILE_GATE_PROBE_MS (2500 ms). A budget over a window rather
than a shorter per-wait limit, because it also counts many short waits and
a single wait reaches it as soon as a 2.5 s limit would; before the
verdict the gate stops the queues for at most about a quarter of any 10 s.
On a driver that holds submissions (630.20) the first probe enters after
2.5 s instead of 15 s and loses the device if the create stays 10 s more;
the held verdict (still 2 s, inside those 10 s) ends the early probes and
leaves only the per-wait limit, so that is one probe per run.
The limit and the budget no longer depend on the title's watchdog. Only
LEONIDA_COMPILE_GATE_WAIT_MS=0 (the budget then defaults to 0) or
LEONIDA_COMPILE_GATE=1 (no limit by default, never probes) waits however
long the creates take.
Tested: submit_mutex (new gate_probe_budget case; also under
LEONIDA_COMPILE_GATE=1 and =0, with the watchdog variables set, and with
LEONIDA_COMPILE_GATE_WAIT_MS=0), MSVC, Windows 11.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The console queue's CopyPageMappingsBatchX goes through xmem's range callback in a retail run. It host-mapped every
destination page of a paired GPU-only range twice: the GPU-only page and its CPU twin. Each map is a VirtualQuery, a
placeholder split and a MapViewOfFile3/UnmapViewOfFile2, which are wineserver round trips under Wine. All of it ran on
the render thread under g_phys_mutex, which DirectStorage's page transfers take too. A local world run spent 3.9-6.0 s
mapping per 10-12 s.
Nothing on the host reads a GPU-only address of a paired range:
- the D3D12 layer, DirectStorage and the texture refresh read the CPU twin (title_gpu_views::to_cpu);
- the runtime reads a page by number through its section's scratch view (host_page);
- the title's CPU never touches the range (PAGE_NOACCESS on the console).
So such a page now gets its physical page in g_mapped and g_table_pages alone, with no host view, as the console edits
GPU page tables only. The twin is mapped as before, and so is a destination with no CPU pair: an independent-pages
range (LEONIDA_SLOT31_RUNS), whose pages are read where they are.
- A view the title mapped there itself is unmapped once when a copy lands on it.
- unmap_range_locked drops table pages in its range, so the title's own unmap or release clears them.
- A table page is not one of its physical page's host addresses (no note_mapping, no alias peer). It can be neither
written nor guarded on the host, so a twin plus a GPU-only page is no longer "aliased" for the slot-133 shadows and
the geometry watch.
- A table update raises title_memory_map::changed and geometry_writes::notify(replaced) for the GPU-only address, as
a host remap did. A remap changes bytes, not what a V# resolves to, so the slot-record change list is not involved.
- The periodic slot-31 line gains "pages N by table, M by host remap" (slot31_mapping_counts).
Tests (Wine):
- xmem_test, test_copy_page_mappings_cpu_view: no host view on the GPU-only range; one host remap per page, not two;
a copy from a GPU-only page finds what its table entry holds; a page the title mapped there is replaced by a table
entry; the title's unmap clears the table.
- d3d12_xmem_placed, queue_remap_default_route: it read the GPU-only pages directly (the old behaviour). It now reads
them through a slot-31 copy and checks that they have no host view.
Wine suite on the iGPU: 425 pass / 23 fail, the same as main e5a7c8942, nothing changed. Linux ctest on llvmpipe:
115/115.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The records' two indexes kept each V# half in a bucket per power-of-two span class and 64 KiB-or-larger block,
and a change visited every entry of every bucket it reached, plus resolved halves for an addition that only
re-fixes waiting ones: 82,000-472,000 slots looked at per submission for 2-15 changes and 1,450-3,150 slots
fixed in the busiest world windows of one run, 4.4-13.4 ms a submission.
Now each index holds the halves by their exact range: halves naming the same range share a group with a resolved
and a waiting list, each half keeping its place in its list (a move or a removal is O(1), no stale entries, an
empty group goes). Groups are ordered by start per power-of-two class of their length; a query searches each
class in use once and walks the groups starting less than one class length before the change. A change looks at
exactly the halves whose range overlaps it (an addition: the waiting ones only); the groups compared besides are
those that start within one class length before it and end before it, one comparison each and no slot. 20 bytes
a half (was 24), plus a group per distinct range. Interface and device code unchanged.
Test: 300,000 slots of 16 bytes packed into 74 blocks of 64 KiB; a 40-byte release looks at the 3 it overlaps
(the bucketed index looked at the whole block and fails), by source it also finds a 1 MiB range starting two
blocks earlier, a moved slot leaves nothing behind, and an addition over all of them looks at the 1,000 waiting.
The 400 random rounds against a full re-resolution still pass (entries looked at 792,825 -> 133,506 for the same
81,005 slots fixed); copies that skip large ranges or the waiting lists on a removal fail.
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>
A title texture upload waited on the CPU, with the submit lock held, for all work submitted on every queue, at
most 250 ms, and skipped the write when that work was not done. World frames take longer, so changed textures
(the planes of a video frame among them) arrived late or out of step, and the submitting thread stalled up to
250 ms per upload (the 200-277 ms maxima of the textures phase in world runs).
The staged transfer now waits for that work on the GPU: write_staged_title_image hands it every queue timeline
value submitted so far. Every such value is already submitted, and console waits whose signal is not submitted
live in QueueHolds, so the GPU wait cannot deadlock. The upload slots are reused once their transfer is done
(looked up, not waited for), and new ones are made while all are in flight. Every title fill goes through this
upload, so the host-copy path for title textures (write_host_texture, its bounded wait and
LEONIDA_ORDER_TEXTURE_UPLOADS) goes. As before, the transfer is submitted on the primary queue before the
submission whose before_execute runs the refresh, and the other queues wait for it on the GPU, so that
submission's draws sample the new texels.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the bounded wait, the three submissions that went ahead on NVIDIA
621.40 came back from the driver in 11, 1 and 0 ms with the create still
there, but consecutive long creates made submissions wait the full 15 s
again and the title's watchdog still ended the run.
Every submission that enters the driver next to a create the gate went
past at the limit is now a probe. Two that come back in under 250 ms, at
least 1 s apart, with that create still in the driver turn the gate off for
the rest of the run; one that stays 2 s or more keeps it on. Both verdicts
are logged once. Two probes a second apart, because on 630.20 back-to-back
creates take and release the driver's lock and one submission could slip
in between; the second costs no extra wait. LEONIDA_COMPILE_GATE=1 gates
always without probing (and compute builds keep holding the submit lock),
=0 has no gate. The README row now says what =1 does again.
Tested: submit_mutex (new gate_adapts case; also under
LEONIDA_COMPILE_GATE=1 and =0), MSVC, Windows 11.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The gate keeps vkQueueSubmit out of the driver while a pipeline create is
in it (on NVIDIA 630.20 a submission that entered during a long compute
create waited 10 s in the driver and lost the device). The waiter holds the
submit lock, so every queue stops behind it: on an RTX 4070 Laptop (NVIDIA
621.40) one compute create stayed in the driver for over 54 s during the
story load and the title's 30 s hang watchdog ended the process.
A submission now goes ahead after LEONIDA_COMPILE_GATE_WAIT_MS (15 s by
default; 0: no limit). The creates in the driver then hold no later
submission back; creates that enter afterwards are waited for again. On
630.20 that only gives up creates over 25 s (15 s here plus the driver's
10 s), which the watchdog ends anyway. With the watchdog kept kicked
(LEONIDA_TITLE_WATCHDOG=0 and LEONIDA_TITLE_WATCHDOG_KICK) the default stays
no limit. The log names each submission that goes ahead and how long it then
spent in the driver. The README row, which still described the gate as
opt-in, now says it is on by default.
Tested: submit_mutex (new gate_wait_limit case), MSVC, Windows 11.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RADV puts sparse buffers 64 TiB above ordinary ones, so with the sparse arena of the previous commit every geometry
copy and title-window block lay below heap_base and TitleBufferWindows::allocate refused it (it accepted only a
positive offset below 2^47). Shaders translated since 2026-11-24 sign-extend a V#'s 48-bit base and say so in their
index entry (vsharp_base_sign_extended), and RADV hands out every address from one 2^47 half of the 48-bit space, so
any block is within reach of heap_base as a signed offset.
- shader_library.h: VsharpBaseCensus counts the marker over every loaded module; signed only when all have it.
- The device reads V# bases signed when the census says so (or with LEONIDA_IMPORT_BELOW_ARENA=1, as before). The
import refusal still follows that setting alone. One line logs the census.
- create_arena: the arena is sparse only with signed offsets; otherwise one allocation, and one line says why.
- TitleBufferWindows::shader_reachable replaces the positive-only check. The first failure of each Vulkan call while
making a block, and the first block refused for its address, are logged.
- rebase_title_vsharp sign-extends a base it already rewrote below heap_base.
- device_arena_memory (for tests); cs_user_data.comp reads V# bases sign-extended, as translated shaders do.
Tests: d3d12_title_va_game_device and d3d12_geometry_views_game_device (d3d12_title_va_test --game-device: the
device the game makes, with the arena's bind queue); geometry_views_test (shader_reachable at the measured RADV
addresses and the range edges); shader_library_test (the census). Wine suite on the iGPU: 429 pass / 23 fail against
425 / 23 on main 8bc59a74c, nothing pass to fail.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
check_aliased_guard covers the addresses known when the cells are first armed.
This covers the later case: the page is guarded at A and B, then reported at C
as well, with the cells' mapping moved at every address as xmem's note_mapping
does once the peers are updated. The next submission must ask for the other
addresses again and guard C, so a write through C faults and is copied at the
submission after it. Without the re-ask in ShadowPages::update_aliased, C stays
writable and the write through it is never copied.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One conflict, runtime/README.md: this branch rewrote the LEONIDA_SHADOW_ALIAS_MS
row, main (#2163) added the LEONIDA_SHADOW_KEEP row after it. Both rows kept;
the keep row's "aliased" now reads "aliased while they can't be guarded at every
address", since aliased pages are no longer copied without a sign of a write.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The arena was one allocation of its whole size, made at start: with LEONIDA_ARENA_MB=4095 a world run used about
0.8 GB of it (peak end about 1 GB) and held 4 GiB of Resizable BAR memory. Where the device can, the arena is now a
sparse buffer: LEONIDA_ARENA_MB bounds the address range, and memory is bound as it is used.
- src/arena_backing.h (new): the backing units. A unit is one VkDeviceMemory, mapped once, bound over whole 2 MiB
blocks. An allocation no larger than a block stays inside one block; a larger one takes whole blocks of its own
(the free-block map's keep-out, footprint and alignment). A unit is bound before the first allocation in it is
handed out, and when its last allocation is released it is pending with the release's retire ticket; it is unbound
and freed only once completed_retire_ticket() has reached that ticket. An allocation in a pending block revives it.
- The CPU reaches the arena through one accessor, DeviceState::arena_host(offset, bytes): one table read, null with a
rate-limited line for a range without memory. Callers that name an offset they do not hold (write_arena_value,
read_arena, the fsdraw probe) use ArenaBacking::with_host under its shared lock; copy_destination and
known_view_heap use offset_of. arena.mapped is gone, so every former `arena.mapped + offset` was converted.
- Binds go to a queue nothing else uses (pick_arena_bind_queue: RADV's sparse-only family, or a sparse family with
a queue to spare) and are waited for there, so a bind never sits behind a submission that waits for a fence the
CPU signals later. The device asks for that queue at creation.
- Unbinding is safe because: arena_release records submitted_retire_ticket() + 1 (as defer_destroy), so the
submission being recorded is covered too; reclaim_arena() runs at the start of ExecuteCommandLists, reads
completed_retire_ticket() before taking the arena lock, and unbinds only units whose ticket has completed; the
table entries are cleared under the exclusive lock before the memory is freed. An unbound range reads as zero
(residencyNonResidentStrict is required), never a fault.
- A D3D12 heap in the arena lends its unit's memory (at the heap's place in the unit) to reserved resources' tiles;
Heap::offset() keeps the arena VA.
- Without sparse buffers, strict residency, a sparse address space as large as the arena, or a queue to spare
(llvmpipe), one allocation backs the whole arena as before, through the same accessors. No new setting.
- The arena line at release gains `GPU address arena: bound N MiB now (peak P, U units of 2 MiB blocks, sparse)`;
the mem-probe breakdown's arena `bound` is the bound bytes.
Tests: arena_backing_test (CPU, fake driver): placement never crosses a unit, binds shared per block, unbinding
waits for the ticket, revival, a random workload whose bound bytes equal the blocks live allocations touch, bind
failure, the one-allocation arena, the bind queue choice. arena_sparse_gpu_test (a real device, 77 without sparse
binding): a 256 MiB arena with 40 MiB allocated has 44 MiB bound; CPU writes are what the GPU reads; released blocks
stay bound while a submission that reads them is in flight and are unbound (reading zero) once it completes; a bind
made while the work queue is blocked completes. Both are new (fail to build on main).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#2230 bounds a dispatch record by the device's maxComputeWorkGroupCount instead of 65 535. Nothing said how wide
the title's dispatches are, nor when a device's own limit still cuts one (llvmpipe allows 65 535 in x; RADV 2^32 - 1),
which its review asked for. The title's tile passes ask for 67 440 groups in x at 2560x1440 (found in the
VIctory-Belobug-AMD fork of VIctory, crates/victory-gpu/src/indirect.rs; no code of it is used).
- indirect_clamp.comp: stats words 12-15 count dispatch records that run wider than 65 535 groups in x, the widest
x that runs, those cut at the device's limits (and still running), and all of them.
- vulkan_indirect_clamp.h: the counters, read with the others (16 words a slot, words 8-15 zeroed before the pass),
and a line every 10 s while dispatch records are clamped: `indirect clamp dispatch: N records, W wider than 65535
groups in x, widest x X, C cut at the device's limits (x x y x z)`.
- indirect_clamp_spv.h regenerated from the .comp as its header says (glslangValidator 16.6.0).
- docs/d3d12_vulkan.md section 4.7: the device's bound per dimension (it still said 65 535), the line, and the test.
Tests: indirect_clamp_test's cases 6b and 6c check the counters (70 000 x 1 x 1: wider than 65 535 where the device
runs it, cut at its limit and counted where not). tests/test_indirect_clamp_telemetry.py checks the new atomics.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
write_back_titles() runs at the start of the shadow refresh, before ShadowPages::refresh() asks the write watch,
so a hot page still carried kClean from the last asking and the title's writes since then were copied over
with the older copy. write_back() now asks first (the asking moves into ask_written_locked(), shared with
refresh()), holds pages whose mapping changed, that a kernel write may be filling, or that xmem aliases, and
copies back only the 256-byte pieces where a copy differs from the title's bytes: a read-only binding writes
nothing and its pages stay guarded, and of two copies of the same bytes only the one that differs is written.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main's #2378 (a draw record of 2^23 vertices or more runs empty and charges nothing) changed indirect_clamp.comp
next to this branch's dispatch bound. The .comp, vulkan_indirect_clamp.h and indirect_clamp_test.cpp merged without
conflicts and keep both changes. The only conflict was the generated indirect_clamp_spv.h: it is regenerated from the
merged indirect_clamp.comp as its header comment says (glslangValidator 16.6.0, -V --target-env vulkan1.2 -Os
--spirv-val; spirv-val passes).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
World runs fill one bindless image array a few minutes in: `a bindless image array is full; dimension 3: 4096
indices, 4092 T#s of 4090 textures`. Dimension 3 is 1D (ImageDimension: 2D, 2D array, 3D, 1D). From then on every
new 1D T# reads the fallback's zeros, and the console heaps count it as "no view for the T#'s format or range",
which went from 2-28 a window to over 4000.
Nothing leaks: the 4096 indices are the fallback, 4092 entries of image_entries and 3 replaced views, every one
held by a texture the runtime still has registered, and a texture's indices go back when it goes (forget_image,
the deferred bindless_slot release, remove_image). The cause is the size: size_bindings grew 2D images to 65536
but 3D and 1D only to 4096 and 2D arrays to 16384, constants that guessed how many textures of each dimension a
title keeps, whatever the device holds (RADV allows 8388606 sampled images, llvmpipe 1015808).
- vulkan_bindless.h: one maximum (max_images, 65536) for the sampled array of every single-sample dimension, in
place of max_2d_images, max_2d_array_images, max_3d_images and max_1d_images. The 2D-array, 3D and 1D arrays
grow together after 2D and the storage arrays, so on a device whose limits stop growth earlier none of them is
favoured. The bound is memory (each generation's pool holds every element): 325729 descriptors on an RTX 5070,
10-20 MiB at 32-64 bytes a descriptor. The shaders declare runtime arrays, so no shader changes; the set layout
changes, so compute pipelines get new journal names (hash_bindless_layout) and the pipeline cache is rebuilt.
- BindlessSet::image_refusal says why add_image returned 0: no array for the dimension, the array is full, or only
its shorter storage range is.
- d3d12_vulkan_device.cpp: bind_image_locked and bind_image_views_locked report that reason; bind_title_image
counts it ("the bindless array of the T#'s dimension is full", or "the bindless storage arrays of the T#'s
dimension are full") instead of "no view for the T#'s format or range". The once-per-dimension line names the
dimension, the storage range and how many of the textures holding indices are still registered at their address.
- docs/d3d12_vulkan.md: the sizes, and the new reason.
Tests: bindless_sizing_test checks RADV's and llvmpipe's limits (every sampled dimension at 65536; on main 1D and 3D
stop at 4096) and that the three dimensions share a short budget alike. vk_bindless_dimensions_test (new, GLSL
shader) sizes a set from the device, gives 5000 live 1D, 2D-array and 3D images an index each and reads every one
through its index, then fills the rest of the array: the next is refused as full, and removed indices come back at
once or, after an erased key, at the next flush. On main it fails at "1D: 4096 indices in the set".
vk_bindless_test's index-space case filled 1D expecting the first index to be 1, which held only while the 1D
array was as short as its storage arrays; it now checks every index once and that indices above the storage arrays
go first.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After any arena release, title-window or geometry block destroyed, or alias change, the next submission walked
every live V# slot of the console heap (about 580,000 in world runs), reading each from the copy in ReBAR VRAM:
1.1-1.5 s a walk whatever the scene, about 2.9 s of a 4.6 s frame. It existed only because nothing recorded
which slot resolved into which backing.
Each V# half of a console resource heap's copy now has a record in host RAM (src/console_heap_slot_records.h):
the title's base and span, the device address its copy names, and whether it resolved or waits. Two indexes
(by base, by target; per power-of-two span class and 64 KiB-or-larger granule) find the halves near a range.
fix_console_slot, the only writer of a slot's copy, writes them; a zeroed range, a deferred slot and a
rewritten slot drop theirs; a destroyed heap takes them with it.
Releases (backing(), title_block_gone), alias ranges removed or replaced (TitleVaAliases tells its listeners
as it happens, forget_copy included) and additions (backings, alias ranges, title memory) go on an unbounded
per-device list. refresh_console_heaps takes it whole; every heap re-fixes exactly the slots it touches: a
release or removal every half naming the range, an addition the waiting halves over it. A new heap log line
gives the changes, slots looked at, slots fixed again and ms per submission.
Removed: the live_vsharps walk and its bitset (console_heap_vsharp_slots.h and its test), the release
generation checks (released_backings, TitleVaAliases::invalidations), LEONIDA_CONSOLE_RELEASE_FILTER, the
4,096-entry DescriptorRangeChanges ring with its full-sweep overflow and changed_ranges(), the empty-slot probe
and retry_unmapped_slots (unreachable: nothing set its flag). LEONIDA_CONSOLE_GPU_FILTER now defaults to unset
instead of the removed variable's value. The T# retries (retry_console_slots) stay.
Tests: console_heap_slot_records_test (portable): releasing a buffer 10 of 60,010 slots name looks at 10
entries and fixes 10 slots; an alias moved, removed and added back; overwritten and zeroed slots; partial
overlap; two slots on one backing; a buffer back; a refused alias copy backed later; a large span; a destroyed
heap; and 400 random rounds compared with a full re-resolution of every slot. d3d12_unmapped_vsharp_test now
expects all 128 waiting slots restored at the first submission after their alias comes (was: 16 by the probe in
64 submissions), none after it goes, and the slots naming a released buffer null. title_va_alias_test and
geometry_views_test check the listener in place of the ring.
Linux ctest 113/113; Windows suite under Wine (clang-cl, iGPU, RADV) equal to main 2d43417d4 test by test.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The `mem-probe t=` line sums our vkAllocateMemory bytes per memory type, but not who holds them: in a late world
run 7.5 GB of device-local memory and up to 1.2 GB of the Resizable BAR type could not be attributed. Every tick
now also prints
[rt] mem-probe breakdown t=<s>: allocated N MiB = arena A (n) [reserved, bound, in use: buffers, descriptor
heaps, shader code, heaps] + geometry copies + title windows and shadows + upload heaps + staging + texture
blocks + sampled textures + render targets and depth + other; imported M MiB; not in the total: bindless
tables, shader modules, pipelines and swapchain images
whose parts add up to the allocated bytes of the t= line. Diagnostic only: nothing changes what is allocated or
where, and with LEONIDA_MEM_PROBE unset nothing is installed.
- src/memory_breakdown.h (new, standard library only): the consumers, an Owner scope (thread-local) that names
the allocations a thread makes while it lives, the tally and the line's text.
- src/mem_probe.h: the vkAllocateMemory wrapper records the thread's owner; vkCreateImage/vkDestroyImage/
vkBindImageMemory are wrapped too, so memory nobody named that a dedicated image is bound to counts as a render
target or depth buffer (attachment usage) or a sampled texture. Named blocks keep their name.
- Owner scopes at the allocation sites: the arena (create_arena), geometry copies (GeometryViews' pool), title
windows outside the arena and slot-133 shadow buffers with their own memory, upload/readback heap buffers,
texture staging and copy scratch, and the texture blocks (ImageMemory, TitleImagePool).
- The device adds the arena's reserved, bound and in-use bytes (by kind) and the bindless table bytes, read under
the arena's and the descriptor locks; BindlessSet allocates through its own function table, so its bytes are
shown beside the total, not in it.
- runtime/README.md: LEONIDA_MEM_PROBE's row names the three lines.
Test: memory_breakdown_test (CPU): the tally sums to the total with imported memory kept apart, owner scopes nest
and stay on their thread, image usage picks the kind, and the text lists every part. It does not build on main
(the header is new).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since #1144 merged (via #2350), xapu_chad.cpp serves only chad.dll and xapu.dll comes from xapu_queue.cpp, which runtime/CMakeLists.txt links into gta6rt and build_runtime.ps1's cl.exe fallback compiles. Wording from nicoco23's review.
The stream parser that decides creation models `D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING`: it refuses a
non-zero `ViewInstanceCount` and accepts the subobject with a count of 0. The capture walker that keeps a stream for
derivation (`layout_of` in `shims/d3d12_xs_pso_stream.cpp`) did not model it, so that same stream created a PSO and
was never captured. The PSO then carried no `PsoStreamRecord`, and every `CreateDerivedPipelineState` on it failed
with E_FAIL ("base PSO has no kept stream"), which is a silent loss of the derived states the title asks for.
Model the subobject's size and alignment in the capture walker. Only the count == 0 shape reaches it (a non-zero count
is refused before a PSO is created), so the payload's `pViewInstanceLocations` is never read: the walk needs the
entry's own size and alignment to step over it, nothing more.
`pso_stream_test` gains `test_view_instancing_is_captured`: a synthetic stream built the same way as the existing
cases, plus a zero-count `VIEW_INSTANCING` entry, must be captured, keep the entry's payload offset, and still derive a
tag-1 record. It fails on `main` ("a stream with a zero-count VIEW_INSTANCING subobject is captured") and passes with
this change.
docs/gameinput.md conflicted on two passages, both kept:
- main's new LEONIDA_INPUT_FILE paragraph, with this branch's sentence on
make_game.py running build_runtime.ps1 with -FetchSdl3 (and --no-sdl3)
added to main's wording of the build paragraph;
- the settings table keeps this branch's LEONIDA_KEYBOARD_PAD default (1,
focused; off removes it), which gameinput.cpp reads, and takes main's longer
LEONIDA_INPUT_SCRIPT row (button@seconds:hold, the six-reads rule), saying
"on unless LEONIDA_KEYBOARD_PAD=off" for the keyboard pad.
No code conflicted. Tested: full ctest, 113 of 113, on Linux (the portable
subset; the gameinput shim is Windows-only).
Changes made by Claude Code (AI-assisted).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JPqXc6svM4pbBagTsVEYA3
runtime/CMakeLists.txt: main added the heavy_pipeline_cache, pipeline_cache_journal and compile_helper tests where this branch adds depth24_fragment; both sides are kept.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
#2372 started a detached thread that took the input lock every 8 ms, so that a scripted press that begins and ends
while the title is not reading reaches the reading history. That works around the cause and adds its own: the
history then depends on how the host schedules a Sleep(8) thread (a slow or loaded machine keeps fewer edges, and a
Windows timer tick of 15.6 ms drops a short hold), the thread never ends, and it contends with the title's reads.
The cause is that update() looked only at the state at the moment of the read. It now first adds a reading for every
start and end of a press since the last update, stamped with the script's time, then the state at the read: the
history is the same however often the title reads, on any machine, and no thread runs. The press log lines carry the
script's time of the press.
Also: LEONIDA_INPUT_TRACE (added by #2372) is documented in docs/gameinput.md and runtime/README.md, as
tests/test_docs_env_vars.py requires. gameinput_no_sdl_script gains y@10, which the title never reads while it is down
(reads at 4.5 s and 60 s): the press and its release must be in the history with their own timestamps. On main the
history has no Y reading.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#2315 kept `_register_thread_local_exe_atexit_callback` away from the host UCRT, which fast-fails a second
registration in the process (gta6rt's own startup makes the first). Review points fixed on top:
- The callback is a `_tls_callback_type` (UCRT process.h: `void (__stdcall*)(void*, unsigned long, void*)`), not
`void (*)()`: vcruntime's TLS destructor callback reads its reason argument, which was left as whatever rdx held.
It is now called as `(nullptr, DLL_PROCESS_DETACH, nullptr)`, as the UCRT does.
- `exit` and `_cexit` call it before the atexit table, as the UCRT does: the leaving thread's thread_local objects end
before the static ones ([basic.start.term]). #2315 ran it after the static destructors, and not in `_cexit`.
- The extra call on every thread detach is dropped, with the per-thread flag and the loader's include of the process
shim: the loader already calls the same function from the executable's TLS directory with DLL_THREAD_DETACH, and
the UCRT never calls the registered one there. The call after a returning entry point is dropped too (MSVC's
mainCRTStartup calls exit itself).
- run_tiny_atexit gains thread_local_exit and thread_local_cexit: a thread_local object of the main thread must end
before the handlers and destructors. On main the --run path never ends it (Wine) or stops at the second
registration (Windows).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LEONIDA_SKIP_COMPUTE is a play-time setting: the game drops the listed programs' dispatches. The precompile also
refused to build them, one "not built (LEONIDA_SKIP_COMPUTE)" line each and no override. Players run it with the
game's environment (docs/running.md), so their skip list kept those programs out of the journal for good, and a later
run without the list compiled them in the game.
- precompile_compute_pipelines builds every compute entry; with the list set it says how many entries it names.
--skip-listed leaves them out on purpose, one line each.
- The last line counts the whole run: built (compiled, from a cache), journaled already, being built by another
process, failed; left out: of those the list names, not buildable, filtered out (--filter, the size bounds and now
--limit too).
- BuildHost::unbuildable no longer checks the list. The compile server checks it itself, as before: the game that
starts it drops those dispatches.
Docs: running.md, linux_proton.md and d3d12_vulkan.md no longer give compile time as the reason for the skip list.
The 89-167 s per program came from wave64-emulated packs; with a native wave64 pack on an RX 7900 XTX (RADV, Mesa
26.3.1, Wine) all 721 library programs of 2 MiB or more built, 360 of them in 170 s on 32 threads, 2.5-32 s each, the
largest (13 MiB) in 28.5 s alone, at a peak of 14 GiB of RAM. Two world runs on that card with all of them journaled
and no skip list took them all from the journal and got no further than runs with the list (a stop with the GPU
idle at 404 s; an idle-queue device loss at about 214 s, which also happens with the list set). Their output is
not checked, so the docs keep the skip list and LEONIDA_RT_AS=off as the setting of our longest runs.
Test: precompile_skip_list (test/check_precompile_skip_list.cmake) precompiles two synthetic compute modules, one of
them listed, three times: with the list set both are built; with --skip-listed only the other one is, and the listed
one is named; a second run into the first journal finds both journaled. It fails on main.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Link gta6rt with /MAP and read gta6rt.map to name each TLS callback.
Fail on the C++ runtime's __dyn_tls_init (tlsdyn.obj) and __dyn_tls_dtor (tlsdtor.obj), allow Rust std's thread-local callback, fail on the rest.
A callback the map does not name, a missing map or a stale map fails with a message.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The sums stand for what every target holds. fill() gave a new target the title's current bytes while the sums kept
the bytes the other targets were refreshed with, so a title that wrote the old bytes back before the next refresh left
the new target behind (no piece differed from its sum). fill() now compares the filled range, widened to whole pieces,
with the sums as a refresh does: the pieces that differ are copied to every target over them and their sums updated.
New test d3d12_shadow_keep_refill (and _off with LEONIDA_SHADOW_KEEP=0): the reviewer's sequence, two overlapping
targets; it failed before this change (A held 1, B held 2) and passes now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gt9hwNPurxyJ9LAfUbNiYr