Round 1D runtime CPU optimization:
1. Split VulkanQueue state bookkeeping (state_mutex_, microsecond hold) from
execution serialization (executing_ + exec_cv_ + execution-local wait/pin
staging). Callers arriving while executing_ is active append to held_ in
strict FIFO order without blocking on before_execute_() or replay, and the
executing thread drains ready held work before releasing executing_.
2. Coalesce consecutive ready Deferred::Kind::batch ops in release_held() /
drain_held_while_executing() and consecutive Call::Kind::execute ops in
async_worker() (stopping on Signal, Wait, Marker, or Present after_held
barrier_after), inserting D3D12 inter-batch full memory barriers and
falling back to per-batch execution on validation failure.
3. Pass closed CommandList snapshots via std::shared_ptr<const CommandList>
from GraphicsCommandList to VulkanQueue (zero deep copies on submit;
Reset() reuses storage with an acquire fence when unique or allocates
fresh storage while in flight), and skip redundant visible_heaps
scan_title_table() recording for console descriptor heaps when table-scan
diagnostics are off.
4. Add unit tests in submit_frame_test covering unlocked before_execute_(),
strict FIFO order, held-batch coalescing and Signal/Wait splits, invalid
batch fallback, zero-copy Reset(), and async worker (depth=4) coalescing
with Present barrier ordering.
AI-assisted: Antigravity (Gemini 4 Neon).
Tested on Linux (RADV RAPHAEL_MENDOCINO): 15/15 queue/submit/replay ctest
targets pass (list_value_progress, vk_queue, vk_queue_query_sync,
submit_frame, vk_queue_constructor_oom, vk_semaphore_lifetime,
vk_fence_dispatcher_sync, vk_fence_lost_by_counter, vk_command_replay,
vk_predicated_copy, vk_predicate_capture, vk_overlapping_occlusion,
vk_host_at_aliasing, vk_host_texture_order).
Run write_back_titles() first in before_execute_() before refresh_page_mirror()
and refresh_console_heaps(), never force-drain unretired batches, coalesce
intervals in note_title_write() and across retired batches, batch GPU readback
copies without holding page_mirror.mutex across vkWaitSemaphores, stop marking
read-only CBVs/SRVs writable, hoist page_mirror.mutex in finish_in_place(),
reuse filter_heap_page scratch, gate diagnostic VirtualQuery behind
LEONIDA_VSHARP_NOTHING_DETAIL=1, and attribute mirror refresh/flush/lock waits
to submit_phases.
AI-assisted: Antigravity (Gemini 4 Neon)
Unlocking a mutex on another thread is undefined; MSVC's runtime throws, and under
Wine the test stopped on msvcp140's missing _Throw_Cpp_error.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two always-on lines every LEONIDA_SUBMIT_FRAME_SECONDS (10 by default, 0
off), from the counters the phase line already keeps and a few more:
[rt] submit frame: frames presented and, per frame, the submissions by
queue kind and the milliseconds the title's threads spent in the layer:
the existing phases counted per frame instead of per submission, plus
what the phase line leaves out - ExecuteCommandLists outside the phases
(list unwrapping, the console's list-value waits and writes, the queue
lock), the queues' Signal and Wait, and the present. Inside those, the
vkQueueSubmit calls and waits for contended submission-path locks are
given apart. Then the window's worst frame and the time of our own
threads per frame: the submit worker (LEONIDA_SUBMIT_ASYNC), the texture
read threads and filler, the console heap resolver, the geometry
refresher, the list values' pump and releaser, the fence callbacks.
[rt] submit floor: how many submissions changed nothing (no heap slot or
page, shadow page, geometry, texture fill or pipeline build), their
average and least cost and their phases, against all submissions.
Title calls are timed once, at their outermost entry, less the phases
inside them; a WorkerScope marks our own threads so their phases are not
counted as the title's. A frame ends at each present the presenter takes.
submit_frame_test checks a scripted run on the CPU (frame sums, title and
own threads, worst frame, floor) and, with a Vulkan device, that the floor
of 20 empty submissions through VulkanQueue sums to exactly what the
phase totals grew by.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>