The device, queue, list and fence proxies now take each slot's meaning
from data, runtime/shims/d3d12_xs_slots.h, built from victory-gpu
(device.rs:402-458, queue.rs:957-1001, list.rs:2055-2173,
fence.rs:141-154) and Leonida's own measurements, each entry citing its
source; static_asserts refuse two entries for one slot. VIctory's switch
(device.rs:149-168) picks the layout: a device created as ID3D12Device11,
as the title's is, gets the console layouts; any other keeps the PC order
that Leonida's PC-interface tests (device_proxy_test, queue_proxy_test,
tiny_frame) drive. This replaces the guessed +4 list rule and the
PC-order queue and fence proxies for the title.
Console layout:
- Queue: Signal 16, Wait 17, GetTimestampFrequency 18 -> PC 14/15/16;
GetDesc 28 -> PC 18; ExecuteCommandLists 10 and ExecuteX 35 -> PC 10
(list proxies unwrapped); Signal2X 34 -> PC 14; PresentX 32 -> the
device's present handler (set_present_handler), else S_OK, as VIctory
answers; markers 11-13 ignored; 23/24 (SuspendX/ResumeX) and 31
(CopyPageMappingsBatchX) refused as open; every other slot refused.
- Fence slot 12: the address of a 64-bit word kept at the real fence's
completed value. CPU Signal and GetCompletedValue update it at once; a
console queue Signal registers SetEventOnCompletion on one process-wide
event whose thread-pool wait re-reads the listed fences.
- Device: 25/26/108 take the return buffer first (V resource.rs:802-811,
840-849, 2583-2593; Leonida retail_boot_chain 3.1; the title faults at
26 without it), either order accepted; 48 takes the console queue
description {type, flags, engine/pipe, queue} (queue.rs:464-495); 69 is
ignored; 74/75 keep page pools; 127 -> PC CreateCommittedResource3 with
a PC description and ALLOW_DISPLAY cleared (CreateCommittedResource in
COMMON before Device10); 57 is refused with its output nulled; 12 makes
console list proxies; every allocator is wrapped and its slot 9 is
accepted; a slot from 44 on that no source names is refused instead of
reaching the PC method at that number.
- List: queries 28-30 -> PC 52-54, the +4 block 32-55, 61 ExecuteIndirect,
80 DispatchX -> Dispatch, 85/86 -> CopyTextureRegion/CopyResource,
129 -> DispatchMesh, 139 ResetX -> Reset, 146 -> Barrier; 51 and 70
(float arguments) through thunks with the real prototype; the 59 marker
and VIctory's hints and syncs ignored; the console List5/List6 ids
answered (the list is made as ID3D12GraphicsCommandList).
Both layouts: device 78-81 are VIctory's frame clock (frame.rs), not the
HLE stand-in that returned at once.
Where the sources disagree (evidence from the title wins):
- List: the +4 rule sent 56-58 to the PC queries, 60 to EndEvent and 31
to ExecuteBundle. VIctory has the queries at 28-30 and names none of
27, 31, 56-58, 60, which are now refused. Leonida's 59 marker (FSR DLL)
fits VIctory's newer layout, where ExecuteIndirect moved to 61.
- Device 48: retail_boot_chain 3.2 read a PC description and had to
clamp Flags; VIctory's layout explains it (the pipe lands there).
- Device 75: PC CreateCommandQueue1 in Leonida, UnregisterPagePool in
VIctory: VIctory's in the console layout.
- Device 45/46/50: PC Device1/3 methods in Leonida; console methods
nobody names per VIctory's counts: refused in the console layout.
- Device 67: VIctory leaves it unimplemented with the same (desc, iid,
out) shape; Leonida's DeserializeComputePipelineStateX (FSR DLL) stays.
- Queue GetDesc: VIctory takes `this` first (queue.rs:950), the device's
struct returns take the buffer first; the queue accepts both.
- Frame clock: the stand-in made a token on every poll and refused a null
token; VIctory's (S_FALSE time-outs, a token only with flag 2) paces
the title.
Open: list 62, 71-74, 100 and 148 still return 0 (no Vulkan-layer path
for title addresses); queue 23/24/31 and device 61/70/71/86 refused;
XboxPresentation is not attached (gta6rt has no window, and its
FramePacer issues its own tokens and models only the origin event); a
title write to the fence word does not move the fence. Not run on the
title: it stops earlier, while DirectStorage is being ported.
Tested (MSVC 19.44, RelWithDebInfo, no Vulkan headers): xs_proxy_mock_test
checks every console queue (128) and list (160) slot against the tables
and through the proxies, the struct returns in both orders, 48, 69,
74/75, 127, 57, the refused device slots, the fence word with deferred
signals, PresentX and the frame clock (40 runs, no failure);
device_proxy_test runs the console layout on WARP. ctest: 116 of 117 pass
without loader; root_sig fails on the base commit too, and loader (no
D3D12 code) times out here. The Vulkan-only tests were not built.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On RDNA3 a lane DPP leaves unwritten does not keep its mask bit: v_cmp writes 0 to
its VCC bit and v_cmpx turns it off in EXEC (mcpeacebir-lang, RX 7800 XT, #1608).
The refusal text and the docs/design.md row said the bit was kept, as fact. The
forms stay refused, since RDNA2 is not measured; the wording now says that.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Extend #957's DPP VOPC compare to v_cmpx: the same lane selection, with the
result written to EXEC. v_cmpx prints no destination, so src0 is its first
operand. Only the forms where every lane writes its bit are taken, as for
v_cmp. 78 pipeline-library pixel shaders of 1.0.2.1 were refused for it; all
78 now translate and pass spirv-val.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A click-through window of its own with its own thread: frame and submission rate, a submission's CPU time by phase, the
phase running now, pipeline builds in flight, indirect draws, cores and memory. Off by default. submit_phases keeps
per-phase counts of the threads inside a phase, so overlapping submissions of several queues leave none behind.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ported from VIctory (victory/crates/victory-hle/src/modules/apu.rs, dsp.rs,
audio.rs; victory-formats/src/xma.rs), GPL-3.0-or-later, Marvisak and
contributors (DexNom fork), keeping its measured ABI: XApu records
(CommandId 0x18, Activate 0x38, Process 0x40, ApuResult 0x50), command
kinds, options and HRESULTs; XDsp StreamDesc 0x1c, Status 16, Command
0x20; IAcpHal slot order, 28-byte messages, command ids 1-3, 5-8, 18;
SHAPE_CONTEXTS 0x60.
- shims/xapu.cpp (xapu.dll): queues and results are real. PLACEHOLDER
decoding: no Opus decoder is in the repository (VIctory uses the
opus-pure crate), so a process command parses its packet
(src/opus_packet.h, RFC 6716 framing as libopus checks it) for its
frame count, output length and errors, and writes silence. Malformed
packets fail with BAD_PACKET; rate conversion stays E_NOTIMPL.
- shims/chad_dsp.cpp (chad.dll): completion (status words, tickets) is
real; convolutions and transforms output silence, as in VIctory.
- shims/acphal.cpp: the coprocessor acknowledges commands with VIctory's
messages (fmod waits for the first in System_Create; the old stub never
answered), sets notification words, and decodes enabled XMA contexts on
a thread into their rings. Context arrays get device addresses that map
back. Fixes: SHAPE_CONTEXTS is 0x60 (APU addresses are 32-bit; 120
bytes wrote 24 past the title's structure); AcpHalReleaseShapeContexts
writes nothing through its argument (the title passes a handle); the
non-cached heap's device addresses start on a 64 KiB boundary; state
the decoding thread reads is immortal.
- src/xma_decode.*, src/xma_tables.h: real XMA2 decoding (VIctory's port
of FFmpeg's WMA Pro decoder) with four fixes from VIctory's history
that the DexNom snapshot lacks (ba42db643, d4d182204, 03a6f2290,
4eb0898b3); src/xma_context.*: the context machine, with three more
(7a5d85e6a, 1054fe87d, 985d8d4b0).
Host output is unchanged: the title's middleware opens WASAPI through
COM (com_shim.cpp forwards CoCreateInstance to the host), as in VIctory.
Tests (CPU only, no game data, in CTest): xma (decoder against a
direct-sum IMDCT, VIctory's frame walk, noise and ring tests), xapu,
chad_dsp, and acphal extended (messages, notification words, the
decoding thread filling a ring). gta6rt --dry-run on 1.0.2.1 binds all
ten xapu/chad imports (unimplemented 11 -> 1: DStorageGetFactory).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main d3b8251bc brings #1889 (large compiles within a memory budget), #1987 (unbound T# reasons), #1759, #1860
and others under this branch. Conflicts:
- d3d12_vulkan_device.cpp, includes: both (pipeline_cache_journal.h and large_module_gate.h).
- d3d12_vulkan_device.cpp, fix_console_slot's T# branch: main's form (counts refused_reasons, #1987), with this
branch's comment on why a slot that is no T# is nulled. The same reason count is added to console_tsharp_check,
the GPU console-heap path's T# registration, so its log line has the reasons too.
- d3d12_vulkan_device.cpp, the heap log: both blocks (the release filter / GPU heap lines and main's "unbound T#s by
reason" line).
- d3d12_vulkan_device.cpp, PipelineState::build_compute: this branch's body (build_compute_pipeline, journal, compile
helper) behind main's entry: the `Work` argument and enter_build, so a large module takes its place at
big_compile_gate() before variants_mutex_, as #1889 requires (a thread that waits for memory holds no PSO lock).
build_compute_pipeline's own big_compile mutex now follows main's BigCompiles: taken only with
LEONIDA_SERIAL_BIG_COMPILES=1 (it was on by default here), so the default is main's budget, not one at a time.
- d3d12_vulkan_device.cpp, queue_locked: this branch's Build-state jobs (claim, defer, finish). main's
`requested_`/`publication` mechanism they replace is not kept. build_variant passes Work::speculative for a
"warmup" build and Work::demand otherwise, as main's queue_build did.
- vulkan_replay.h, ComputePipeline: main's comment on `large`, and this branch's `await`.
- vulkan_backend.h: this branch's LEONIDA_SUBMIT_ASYNC block, with main's lock order in the state_mutex_ comment
(state_mutex_ -> pipeline_mutex_ -> resource_mutex_ -> tracker_mutex_ -> submit_mutex_).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The legal-terms page keeps Confirm greyed out until both boxes are ticked, and
down stops at Confirm, so an a/down-only script sits there. Record the page
order, what each page needs and the retry block that reached the loading
screen on native Windows; one README status sentence links it.
- A second Vulkan instance in the process no longer overwrites the messenger
handle (the first one was left alive past its instance): it is refused, and
enable_device only enables the extension for the instance that owns the
messenger. install/uninstall are under a lock.
- `on` is set only when a messenger records the device, and is atomic. With
LEONIDA_ADDRESS_BINDINGS=1 and nothing recording, the fault report says the
bindings were not recorded instead of reading as "no object there".
- An object that only shares the reported page with the fault address is
labelled "on the page" (unbound: "held the page"), not "containing".
- Tests: exact end and start of an object, page vs byte precision, unbind
matching by handle and size, the kept_unbound cap, recording from several
threads while a report reads, and the two-instance messenger cases. The test
builds on Linux too (setenv in place of _putenv_s).
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
Review of RT-HEAVY-PIPELINE-CACHE:
- The writer thread marked a generation written even when the save failed, so the
cache stayed unsaved until teardown. A failed save now keeps the cache dirty and
is retried after a bounded backoff (5 s, doubling, capped at 2 min), so a write
that keeps failing does not spin. WriteSchedule::failed() holds that decision and
heavy_pipeline_cache_test checks it.
- save_heavy_pipeline_cache accepted VK_INCOMPLETE and published the truncated blob
over a complete file. It now requires VK_SUCCESS, like the session cache, and
keeps the previous file; the next try queries a fresh size.
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
AGENTS.md gets two runtime traps found on the real title: a thread_local
with a destructor in gta6rt.exe aborts the title (0xC0000409), and console
methods returning a struct by value take a hidden return pointer in RCX.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gta6rt --run stopped at the first unimplemented import, XCRDAPI.dll!DStorageGetFactory.
shims/dstorage_xs.cpp now serves it, ported from VIctory's
crates/victory-hle/src/modules/dstorage.rs (GPL-3.0-or-later; Marvisak and contributors,
DexNom fork) with VIctory's measured ABI: the factory interface id, the factory, file,
status-array and queue method tables in their slot order, the 0x48-byte request and the
queue description (shims/dstorage_xs.h), and its status and error reporting.
- One pool of workers runs every queue's requests: started in queue order, queues shared
by priority with weighted round robin (about 10x per level, in bytes), at most the
staging buffer's worth of compressed source in flight. A status entry is written once
every earlier request of its queue has finished, with the first failure since the last
entry. A queue submits itself at half its capacity and blocks when full; Close drops
what has not started and waits for what runs.
- Files open through the title's CreateFileW shim, so GAME: and G: paths read the
overlay copy or the package. zlib is leonida::zlib_inflate. Destinations are addresses
or xmem physical pages, whose page array is read when the request runs (waiting up to
100 ms for numbers still zero); new rt::xmem::physical_span/write_physical write the
pages through their section's own view, committed first.
- Raw file reads into title memory are read beside and copied in (VIctory's fix for
ERROR_INVALID_USER_BUFFER): here a ReadFile into an untouched mapped physical page fails
with ERROR_NOACCESS, while our copy faults into xmem's commit handler.
- BCPack goes through leonida_bcpack_decode (src/bcpack_decode.h); the stub linked for
now returns false, so BCPack requests complete with HRESULT_FROM_WIN32(ERROR_INVALID_DATA),
logged once per BC format.
- No thread_local with a destructor: it made gta6rt.exe's CRT register its thread-local
destructor callback with the UCRT, which takes one per process, and the title's CRT
startup then ended the process with 0xC0000409 after its static initializers.
- LEONIDA_DSTORAGE_TRACE (failed or all requests) and LEONIDA_DSTORAGE_RETRIES (physical
page write retries) are documented in runtime/README.md.
dstorage_xs_test (CTest dstorage_xs, no game files): reads from a synthetic GAME: file
through a queue, zlib streams compressed by the test, memory sources, statuses completing
in order with the first failure (EOF, bad zlib, BCPack, unsupported option, oversized
read), self-submission, closed queues, the scheduler's priority and staging choices, and
physical-page destinations (one allocation, several, a late page array, an unknown page,
a raw read into untouched pages). 59 checks pass.
On the 1.0.2.1 package, --run now gets the factory, sets the 32 MiB staging buffer and
opens 12 RPF archives through DirectStorage; it then stops in the D3D12 device proxy's
slot 26 (GetCustomHeapProperties), which receives the hidden return pointer in RCX.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A window of the title's memory is a read-side mirror refreshed before every
submission, so a UAV or raw write into one landed in the copy and the title
never saw it. At the world start that is the WRITE_INVALID device loss of
#1537 (QemmHD, 160 s into the load, past the cap): the culling compute writes
through addresses that name title memory, and nothing ever reads the result
back into the pages.
The layer now keeps every title range a submission's bindings reach (the
resolve path, so root views, table V#s and created views alike) and copies
those ranges from the copy to the title's pages at the start of the next
refresh, before the forward copy. A page the title wrote in between takes the
title's newer bytes and its GPU result is dropped; the tracker already knows
those pages (guarded, hot and clean). Caps: 8,192 ranges and 64 MiB a
submission, logged once; LEONIDA_TITLE_WRITEBACK=0 turns it off.
Test: d3d12_title_window_write_back, a dispatch through a root UAV at the
title's pages: the written words reach the pages, hold across two
submissions, and a title write survives the next forward copy. No game files.
Item: RT-TITLE-WINDOW-WRITE-BACK (claimed in #1608)
Wine against llvmpipe.
The title HUD (#1922, LEONIDA_TITLE_HUD=1) read VRAM from DXGI's
QueryVideoMemoryInfo on the host dxgi.dll and private memory from
PROCESS_MEMORY_COUNTERS_EX::PrivateUsage. Under Wine both read 0.
- VRAM: the runtime's device enables VK_EXT_memory_budget when the GPU
has it (VulkanDeviceInfo::memory_budget), and
rt::d3d12::vulkan_vram_budget sums heapUsage and heapBudget over the
DEVICE_LOCAL heaps (other heaps' usage shown as shared), from
src/vulkan_memory_budget.h. The HUD calls it once per refresh on its
own thread. Without the extension it falls back to DXGI, and where
that has no figure either it shows "VRAM n/a" rather than 0.
- Private memory: Wine's GetProcessMemoryInfo fills only the
PROCESS_MEMORY_COUNTERS part and leaves PrivateUsage 0; PagefileUsage
is the same commit-charge figure on Windows 8 and later, so the HUD
takes the larger of the two.
Tests: title_hud_test checks the sums, the DXGI fallback, the "n/a"
text and the private-bytes choice with made-up values, and that a VRAM
source reaches the title at most once per refresh. The new
d3d12_vram_budget_test checks that the device enables the extension
exactly when the GPU has it and reads a non-zero budget, and skips
(77) without it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Addresses review feedback from KernelSmoker and Deedlyy on PR #1166:
- Converted tests/test_descriptor_address_translation.py to standard-library unittest, allowing it to run dependency-free with python -I.
- Added TestProductionImplementationConformance checking runtime/src/gfx10_descriptors.h and tools/rdna2spirv.py against documented bitfield layouts.
- Preserved all 30 test cases running in 0.05 s.
AI-assisted (Claude Code, Claude Opus 5.5).
Since #1353 the shims' serializers (versioned and legacy) serialize a
description the host refuses for CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED or
SAMPLER_HEAP_DIRECTLY_INDEXED (Windows 10's in-box d3d12.dll): they call
the host again without the two bits and put them back into RTS0. The
three host-parity checks failed on Windows 10 for that, as reported in
review.
Where the host refuses such flags but takes the description without
them, the shim now has to return S_OK with that blob byte for byte,
except the RTS0 flags dword, which must hold all the flags, and a valid
container hash. Byte-for-byte parity stays wherever the host accepts,
and the shim still has to refuse whatever else the host refuses. The doc
bullet says the same.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings #1889 up to date with main after #1742 (the pipeline compile unlock),
resolving the five conflicts as described in the guide on the PR:
https://github.com/ubiquitarianism/leonida/pull/1889#issuecomment-7175252290
- vulkan_replay.h: PipelineCompiles::build takes both the large-compile
budget and main's `prior` compiles; build_pipelines passes the budget,
and main's check_compiled_pipelines / finish_compiled_pipelines stay.
- vulkan_backend.h: execute_now takes the large-compile demand and passes
the budget to the pass-0 compile, and pass 1 passes the budget too.
set_large_compiles locks pipeline_mutex_, since #1742 moved the
pipeline state under that lock.
- replay_pipeline_compiles_test.cpp: both test blocks kept, and the
prior_compiles_reuse call passes an empty budget.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
runtime/shims/startup_trace.h: main added the tls_index0 example event
and the exception's region/regs fields to the header comment; keep them,
add this branch's delay_import_unimplemented example and renumber seq.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>