Add an E line after the P line of a compute pipeline.
It holds the FNV-1a 64 hash of the library entry name, not the name.
A reader from before E lines skips them, counted as lines not read.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
With LEONIDA_PIPELINE_COMPILE=on-demand a console stream (device slot 86) is
only parsed when it is first bound, and create_graphics queued the prewarm
from there, so a planned pipeline got no lead at all. ecox982745 measured 0
of 8 planned builds before the first bind in that mode, 8 of 8 otherwise.
When the plan has the stream's pipeline, the parse is now queued as its first
prewarm job (at the rank of its first recorded variant, on a compile worker);
create_graphics then queues the variants as for any other PSO. A bind that
comes first waits for the parse through resolve_type's call_once, as it would
have parsed it itself.
d3d12_pipeline_workers_test gets a device case: a first device records the
order, then console-stream PSOs with an eight-entry plan must build those
eight before any command is recorded, with the ordinary stream and with
on-demand, and nothing without a plan. Without the fix the on-demand case
fails with 0 of 8.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LEONIDA_PIPELINE_PREWARM_ORDER=<file> (or 1 for pipeline_order.log beside the
session cache) reads the order log #2220 records. Of the runs recorded on this
GPU, the one with the most records is used. When the title creates a PSO whose
description key is in it, each recorded graphics or mesh variant is queued on
the compile workers (#2233) as a warm-up at priority 1 + rank: after every
demanded build, one warm-up at a time, none while a demanded build runs.
Records are taken in order up to LEONIDA_PIPELINE_PREWARM_BUDGET_MS of recorded
build time (default 300000) and LEONIDA_PIPELINE_PREWARM_MAX_ENTRIES (4096).
Compute records are left to the compute warm-up and the offline precompiler.
A missing, garbled or other-GPU log is ignored with one message; damaged lines
and the E lines a v1 reader does not know are skipped.
New CPU test pipeline_prewarm: order kept, budget and entry limit, run
choice, a missing or garbled log, E lines, and on the compile workers the
recorded order and a demanded build overtaking the prewarms.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The startup cache checkpoint starts only when no compile worker is busy, but a
demanded build can start on another worker while the checkpoint queries the
cache size. has_compile_waiter() only looked at the queue, so the check after
the size query went on to read the cache blob while that build ran.
has_compile_waiter() now also answers true while a demanded build runs.
New gated test in d3d12_compile_pool_test: the checkpoint waits at a gate
standing in for the size query, a demanded build starts on the second worker,
and the second look must see it. It fails without the fix.
Reported by lixonik in review of #2233.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The checker only reads the PE file with the host's Python, so it does not need the
run_module_names guard (NOT CMAKE_CROSSCOMPILING). Move the registration out of it, with
its own host Python lookup. runtime/cmake/clang-cl-xwin.cmake builds the same MSVC ABI
and UCRT, so the same callbacks would appear; MinGW is not a supported gta6rt toolchain.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
When a console root is mounted, resolve the directory path through view()
so non-existent subdirectories correctly return ERROR_PATH_NOT_FOUND to match
Win32 GetDiskFreeSpaceEx behavior.
Between periodic refresh_title_textures passes, synchronous slot-70 view creation and the async fill worker checked TextureReadability with a constant generation, missing title_memory_map range changes since the last pass. Track the map generation on TextureReadability and consult title_memory_map::changes_since outside refresh passes so unmapped or decommitted pages defer before hashing and newly mapped pages publish immediately without waiting for a submission.
Also mark mix_words and hash_bytes LEONIDA_GUARDED_NO_BUILTIN using an unaligned 64-bit load so clang-cl cannot emit CRT memcpy calls inside the __try frame, and classify non-title read faults over unmapped title pages in xmem::physical_page_fault as FaultExit::passed_guarded.
Lower computed v_interp_p1/p2 (I, J) pairs under --f16-interp-fallback (without --bary-fallback) without PerVertexKHR or a geometry shader by hoisting OpDPdxFine/OpDPdyFine screen-quad barycentric and attribute derivatives into uniform %entry (OpCapability DerivativeControl, guarded by an integer IEEE-754 normal determinant check) and evaluating P_0 + I*P_10 + J*P_20 per site.
A page xmem maps at two addresses was copied whole at every refresh, since
a guard on one view doesn't fault a write through the other: about 1 GB a
submission after the story load on a retail boot. ShadowPages now arms the
geometry watch's cells of each aliased 64 KiB block at every address it is
mapped and copies a block only when a cell's version moved. xmem tells the
cells of a mapping change after updating the peers, and of list value
writes made through the section.
AI-assisted; tested under WineHQ 11.22 and GE-Proton11-14 on an RTX 3090
(NVIDIA 590.48.01).
With LEONIDA_ASYNC_PIPELINES=1 every demanded build, the compute warm-up and
the cache checkpoint ran on one general worker (plus a graphics-only one), so
one long driver compile held every pipeline a submission asked for behind it,
and their draws and dispatches were skipped meanwhile.
PipelineCompiler now runs LEONIDA_COMPILE_THREADS workers (half the logical
processors, 2 to 8). A worker takes the most urgent job it may:
- demanded builds first, in the order they came, then warm-ups by size, then
the checkpoint, which waits until no worker compiles;
- large builds (compute over 128 KiB, graphics of 1 MiB or more) and warm-ups
together take at most threads-1 workers, so one stays free for a small
demanded build; at most LEONIDA_COMPILE_HEAVY_MAX large builds at once
(default threads-1, 1 with LEONIDA_SERIAL_BIG_COMPILES=1), compute and
graphics alike, each still within the memory gate;
- warm-ups run one at a time, and none starts while a demanded build runs:
each holds the compile gate for its whole create, and a submission waits
for every create in flight;
- one build of a PSO at a time, so after_running and the teardown rules hold.
LEONIDA_COMPILE_THREADS=1 keeps the layout before the pool. The design is
MoonEyes' (#2077), ported onto #2098's scheduler.
Tests: d3d12_compile_pool (CPU, jobs held at gates: settings, a long build
does not hold up a small demanded one, heavy count, free worker, warm-ups one
at a time and after demanded builds, order, one job per PSO, release/cancel/
stop_for_exit with jobs in flight), and d3d12_compile_teardown also with one
worker.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ExecuteIndirect argument clamp (indirect_clamp.comp) cut every dispatch
record at a fixed 65,535 groups per dimension, Vulkan's guaranteed minimum.
Devices report far more in x (NVIDIA: 2^31 - 1), so a one-dimensional
indirect dispatch of more than 65,535 groups ran only its first 65,535
groups; the rest never wrote their output.
The clamp now takes the device's maxComputeWorkGroupCount per axis in its
push constants (88 bytes, was 72) and bounds dispatch records by that. The
2^20 groups-per-dispatch cap, the list budget and LEONIDA_INDIRECT_GROUP_BUDGET
are unchanged; the product check now divides instead of multiplying, since x
alone may exceed 65,535. Mesh dispatches keep 65,535 in x.
indirect_clamp_test runs real indirect dispatches through the clamped
scratch with a marker shader (one atomic per group): 70,000 x 1 x 1 ran
65,535 groups and left 4,465 unrun on main, and runs all 70,000 exactly once
now; 65,535 x 1 x 1 and 1 x 65,535 x 1 (at the old limit) run exactly once
on both. A size past the device's own limit is skipped.
Idea from codec-d/cool_fox docs/findings.md ("Blocky patches: indirect
dispatches cut at 65,535 groups"); idea only, no code taken.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve console roots (GAME:\, G:\, T:\) to mapped host paths before
querying host disk geometry and capacity, and provide synthetic Xbox
console storage fallback quotas when unmounted.
A thread_local with a destructor gives gta6rt.exe __dyn_tls_init/__dyn_tls_dtor callbacks;
the title's own _register_thread_local_exe_atexit_callback then fast-fails (0xC0000409).
check_pe_tls_callbacks.py reads the PE TLS directory and fails on a non-empty list; a stdlib
test checks it on two in-memory PE32+ images.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
An update whose source is not a structure of this layout (one the title never
built, which D3D12 leaves undefined) made the refit follow its parent table
anywhere. MODE_CHECK now compares the copied header with the layout, and the
update records both tails: the refit runs when the check passes, a full build
when it fails. The refit walk follows only pointers to the layout's nodes.
A vertex index at or past the geometry's VertexCount is no longer read: its
triangle is inactive. XdxrTriangles carries vertex_count from the desc.
vk_xdxr_build_test: blas_vertex_count and eight update-source cases (zero,
random, another element count, garbage tree; large and small-sort).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gt9hwRYcpySx4P4ncQ3wD5
A fenced batch waits for its submission's retire ticket. On a queue the layer
holds back (console ordering) the ticket is not ours, and in the worst case
nothing retires soon: the pending list would grow for the rest of the run.
Past 64 pending batches the oldest is now copied back without waiting, once
each, and the fact is logged once. Docs say so.
Conflicts: docs/d3d12_vulkan.md (main's shorter async paragraph, then the
order-log paragraph), runtime/CMakeLists.txt (both test blocks kept),
runtime/shims/d3d12_vulkan_device.cpp (both includes; build_compute now
reports ComputeBuild::ms to the recorder).
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A slot-133 buffer the driver will not import is a shadow of the title's pages,
and the write through it landed in the copy exactly as a window's did. The
mechanism is already the same one - the pages are title memory, the alias of
the buffer resolves through the noter, and the tracker carries the range - but
nothing said so and nothing tested it.
d3d12_placed_write_back: a root UAV over a placed buffer. The pages keep the
title's words until the next submission, then hold the shader's; a write by the
title over the result survives the copy forward.
861bb0546 added geometry_execute_serials() as a function-local
thread_local std::vector. A C++ thread_local with a destructor in
gta6rt.exe adds TLS callbacks to the image, which the loader's TLS
index-0 move must not have (pe_loader.cpp reserve_tls_index0; see
VulkanContext::stage_xdxr_table). With it the title's CRT startup hits
ucrtbase's one-shot _register_thread_local_exe_atexit_callback guard
and terminates: 0xC0000409 (info0=7) at ~1.6 s, before any D3D12 call.
Use a fixed aggregate instead: no destructor, no TLS callbacks, the same
per-thread LIFO, bounded at 32 replays with overflow reported once.
Tested: runtime builds; with LEONIDA_D3D12=vulkan the fix boots past
startup and submits, while 0b11d86bc exits 0xC0000409 at ~1.5 s.
NVIDIA RTX 4090, driver 616.64, Windows 11.
AI-assisted (Claude Code).
Co-Authored-By: Claude Code <noreply@anthropic.com>
#2098 gave the SDL path its own loop (held 300 ms, then until the title
has read the pads six times, at most 5 s), which ignored button@seconds:hold.
A press now lasts its own hold, then the read latch, and never past 5 s or
its hold if longer. The long-script test checks both: X kept past 300 ms
until six reads, Y kept for its 0.6 s after them. It fails on the old loop.
Found by AndreiKocherzhinskiiA on #1608.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
At world-start frame rates the retail title reads its pad every few seconds,
so a 0.3 s scripted press falls between two reads and never arrives. An
entry may now give its own hold time; without one the press stays 0.3 s.
Holds of 0 or less, over 600 s or that are not a number reject the entry.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On RADV a GPU hang ends in VK_ERROR_DEVICE_LOST with no checkpoints, so the
device-fault report lists the 64 dispatches in flight but cannot say which
one stopped the queue.
LEONIDA_DEVICE_MARKERS=1 (with LEONIDA_DEVICE_FAULT=1 or 2) enables
VK_AMD_buffer_marker where the device has it. Every dispatch the report
numbers writes its seq into its queue's slot of one persistent host-visible,
coherent buffer: at top of pipe before the dispatch (started) and at bottom
of pipe after it (finished), with vkCmdWriteBufferMarker2AMD. On a loss or a
stall report each queue's last finished and started seq are printed, and
the oldest started, unfinished dispatch is reported as the likely hang and
marked in the submitted-dispatch list. A history of the last 16,384
dispatches names it when it has left that list. The values are best-effort
after a loss, and the report says so.
The seq is now handed out when a dispatch is recorded, so the marker and
the list share one numbering; it counts every recorded dispatch, and the
list can show gaps where a submission recorded more than 64.
Cost with the switch on: two marker writes per dispatch and one history
entry; with it off nothing changes. Without the extension, or without
LEONIDA_DEVICE_FAULT, one "device-markers: unavailable" line is logged.
Tests: vulkan_device_markers (portable: numbering, marker writes, ring,
likely-hang verdicts, the 32-bit wrap) and vk_device_markers (a real device:
after the wait the started and finished markers equal the last seq; SKIP
without the extension).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The null-view marks (#1504, by ubiquitarianism) are kept by the real CPU
handle. They were moved by descriptor copies and cleared by a view made
with a resource, but never dropped when the heap went away, so an RTV heap
made later at the same address inherited stale marks and its clears were
skipped. The heap proxy now records an RTV heap's real CPU range and
heap_release drops the marks in it. The barrier conversion keeps no state
across calls, so it needs nothing here.
xs_proxy_mock_test: an RTV heap's marked view is skipped while the heap
lives and cleared after it is released; a mark outside it stays; a second
heap at the same address starts unmarked and marks again. docs/d3d12_vulkan.md
says so.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f0611b752 took the executable's addresses out of the code. Two behaviours
changed with it; the removal stays, the changes are now explicit:
- runtime/src/main.cpp: the watchdog kick runs again only with
LEONIDA_TITLE_WATCHDOG=0, as on main; LEONIDA_TITLE_WATCHDOG_KICK only
supplies the two RVAs it needs. Either variable alone leaves the
watchdog armed and the loader says so once (before this commit the kick
ran whenever LEONIDA_TITLE_WATCHDOG_KICK was set).
- scripts/windows-boot/boot.ps1 no longer has the game- and
session-state RVAs built in, so LEONIDA_PEEK has no default and the
RESULT states read "?" unless LEONIDA_GAME_STATE_RVA and
LEONIDA_SESSION_STATE_RVA are set. The script now warns when they are
not, and runtime/README.md (LEONIDA_PEEK, LEONIDA_TITLE_WATCHDOG and
_KICK rows), scripts/windows-boot/README.md and docs/first_run_ui.md
say so.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflict in runtime/shims/d3d12_xs_device.cpp, proxy_copy_descriptors_simple:
keep this branch's copy_null_rtv_marks call and main's fsdraw::enabled()
gate for the descriptor-copy diagnostic.
tools/rdna2spirv.py merged without a textual conflict, but #1662 on main
calls restore_dot4_inline_sel in the exact re-anchoring path, which this
branch had deleted. The merge puts main's function back so that call
resolves; the next commits reconcile it with the dot4 op_sel rule.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
geometry_views_test case 13 runs DeviceState's order for one submission with
an idle GPU (completed == submitted): execute_begin, the drain at
kAfterExecutes in before_execute_, the replay records its ticket, execute_end.
Another queue's replay began before the release and one more begins after
the retirement. It checks that
- the drain retires the view but does not reap it (a ticket read in the drain
reaped it in the same call),
- the view waits until every replay begun before the retirement recorded its
submission, then for the last of their tickets, and not for the later replay,
- the retirement invalidates answers made without an alias (forget_copy:
changed_ranges, invalidations, take_removed),
- the destroyed block leaves for_each_block, changes layout_generation and is
reported to the device (title_block_gone).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since #2098 every TitleBufferWindows carries a 128 KiB published_ array, so the
eight GeometryViews this test puts on the stack pass the 1 MiB Windows default
and the test died at startup with a stack overflow. They are heap-allocated now.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#2098's TitleBufferWindows::published_ and update_gpu_backed assumed blocks are
never destroyed: for_each_block fed every block made so far into the console
heap pass's backed table, and the table was rebuilt only when the published
count grew. With empty blocks now destroyed, a freed block stayed in the table,
and its "never of memory that is not there" contract broke.
- A destroyed block's published_ slot keeps its other fields; only its address
(now atomic) goes to 0, and for_each_block and find_mapped skip it. A slot is
never reused before release(), so a lock-free reader never sees one half
rewritten.
- layout_generation() changes whenever a block is made or destroyed;
update_gpu_backed uses it instead of the block count to see a change.
- destroy_block tells the device (DeviceState::title_block_gone): the block's
span goes into released_ranges, as a released backing's does, so the backed
table cuts it at once and the key entries and heap slots answering into it go
at the next refresh. A block is destroyed only once its last range was freed,
after the GPU work that used it completed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
forget_geometry_alias only removed the view's alias ranges. vsharp_address and
placed views take geometry_va() answers straight from GeometryViews, with no
alias entry, so a retirement left the console heap slots translated through
them, and the GPU key table's entries, pointing at the view after its reap.
TitleVaAliases::forget_copy records the retired view as a removal: its title
range (CPU address and GPU twin) goes into changed_ranges with an invalidations
bump, so the console heaps translate those slots again, and its shader VA into
take_removed, so the GPU key table drops answers into it. That is what remove()
does for a range that has an alias; recording the answers instead would cost a
table entry per answer on the hot path, while this costs one entry per
retirement. The retirement runs before refresh_shadows() (previous commit), so
the submission about to run already translates without the view.
pool_spans keeps a retired view's shader_va, but only for its statistics line;
nothing answers from it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
drain_geometry_releases retired released views at submitted_retire_ticket(),
read in before_execute_. The submission about to run records its own ticket
only after that, so it was not covered, and with an idle GPU
(completed == submitted) drain_released reaped the view in the same call,
before the lists recorded against it ran. A sparse bind in the same replay or
another queue's replay can take tickets in between, so submitted + 1 is not
enough either.
- VulkanContext::set_after_execute: called at the end of every replay that
called before_execute_, however it returns, once its submissions are recorded.
- GeometryViews::execute_begin/execute_end track the replays in progress. A view
retired at kAfterExecutes takes the serial of the last replay begun once it
is unreachable, and gets its ticket (submitted_retire_ticket(), read under
the views' lock) only when every replay up to that serial has ended.
- before_execute_ drains before refresh_shadows(), so this submission's console
heap slots are never translated to a view retired in the same call.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since #2098 a tagged module reads its instruction's array only when the table entry's kind names it. The harness
binds index 1 in images[1] (binding 0) and in the 2D-array images[1] (binding 3), but tagged it 2D only (2D array
in cube mode), so ps_array_resinfo and ps_get_lod_array read the 1x1 fallback on every driver.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflict in runtime/shims/d3d12_title_buffer_windows.h: main (#2098) added the
lock-free published_ block list (for_each_block, find_mapped); this branch
destroys empty blocks. Both are kept; a destroyed block's published_ entry is
cleared here, and the follow-up commits make that safe for the lock-free readers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A gta6rt configured without Vulkan headers is built without
LEONIDA_VULKAN_DEVICE. D3D12XboxCreateDevice then ignored
LEONIDA_D3D12=vulkan without a word and wrapped the host's D3D12 device,
so a run stopped somewhere else and read like a boot result.
It now prints one [rt] d3d12_xs line naming the cause and the configure
options. Which device is created does not change. The reading of the
variable moves to shims/d3d12_backend.h, used by both builds; new CPU-only
test d3d12_backend, registered outside the Vulkan-headers block.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Review of #1886: the seed the driver hands back with the session's builds no longer counts against
LEONIDA_PIPELINE_CACHE_BYTES (pipeline_cache_store::over_save_limit, with a unit test), the stale 512 MiB
checkpoint sentence is gone from docs/d3d12_vulkan.md, and kExitCacheWriteMs is 6 s with the measured
write times (1.87 GB in 1.4 s, 2.9 GB in 1.3-1.6 s; about 2.2 s at the 4 GiB default).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gt9hwRYcpySx4P4ncQ3wD5
Since #2098 (merged in from main) a tagged module reads its instruction's array only when the entry's kind names
it; with the 2D bit alone, ps_ssharp_cube and ps_ssharp_3d read the magenta fallback.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>