| Age | Commit message (Collapse) | Author |
|
held-queue stalls
|
|
|
|
holder in submit_frame_test
|
|
landed-value check, wait_met re-check, relay_wait gate preservation & signal-only vis_seq transitivity
AI-assisted: Antigravity (Gemini 4 Neon).
|
|
wait relay, coalescer reorder, readable fast path & decoupled GPU profile resolve
- Add VulkanFence::signal_gpu_relay() (vis_seq=0) strictly for GPU-landed list-value gates (!force && !lost && !action && !cpu_met)
- Retroactive GPU-to-GPU relay via QueueHolds::relay_wait() + VulkanQueue wait substitution (never GPU-signaling values->gate, reversing wait() before add_gate(), requiring after_gate==0 && different queue)
- Decouple gpu_profile_.resolve() onto lazy resolver thread off FenceWaitDispatcher & throttle take_open() device-loss checks
- Reorder BeforeExecuteCoalescer to wb -> mirror -> flush -> tex -> shadows -> 2nd flush -> conditional 2nd tex (killing in_feed CPU fallbacks)
- Hoist host_stop & add negative caching in TextureVqCache + Stage 2b all-16 Cell::restore[] readability bypass
AI-assisted: Antigravity (Gemini 4 Neon).
|
|
d3d12_existing_heap)
Titles and d3d12_existing_heap rely on ExecuteCommandLists(empty) + Signal() as
a synchronization point that flushes pending streamed views and title textures.
AI-assisted: Antigravity (Gemini 4 Neon).
|
|
barriers, empty-batch/wait coalescing, replay floor & batched xmem slot-31
- Fix Pump::choose_release() TOCTOU on already-completed unlanded write groups/action gates + 10 ms quiet window on Reason::present
- Skip before_execute/visibility_seq on empty batches (preserving pending_wait_vis_seq_), coalesce past GPU-completed Waits (merging CPU vis_seq), cache CommandList summary, atomic unbuilt_sync_pipelines_ & BindlessSet clean fast-paths, hoist EmitScratch
- Dedicated QueueHolds barrier-drain thread with active_work_ tracking, wait_barriers_drained() ordering, cancel_after() wait, and non-blocking VulkanQueue::release_ready()
- Batch copy_page_mappings() per contiguous range & notify Event::replaced on mirror_heap decommit in xmem.cpp
- SEH-guarded aligned volatile read_value() (no noexcept under /EHsc) + 1000 ms slot-12 Vulkan fence mirror timeout
AI-assisted: Antigravity (Gemini 4 Neon).
|
|
unlocked run_barriers, and cached arm_batch
Eliminates single-texture slot-70 storms, multi-queue TitleImageUpload lock/submit stalls, gratuitous coalescer invalidations, and Present pump_mutex_ blocks:
- d3d12_vulkan_device.cpp: defers slot-70 make_title_texture()/refresh_title_texture() to batched refresh_title_textures() (with texture_watch.touch); skips re-dirtying hot pages when mirror_just_synced; ports changes_since()-tracked known_protect cache into TitleTextureCells::arm_batch().
- d3d12_title_image_upload.h / vulkan_title_detile.h / vulkan_backend.h / vulkan_indirect_clamp.h: caches PFN_vk* procs, raises kMaxBatchCmds=64 / kMaxScratchSlots=32, waits on oldest_in_flight_scratch_value(), batches vkUpdateDescriptorSets, replaces empty consumer submits with lazy note_title_upload_locked waits in submit_multi(), unlocks submit_mutex_ during upload recording, decouples prepare_indirect_clamp from tracker_mutex_, caches ReplayFunctions, and times tracker_lock waits.
- queue_holds.h / vulkan_backend.h / vulkan_present.h / d3d12_com.cpp: tracks per-(fence,value) vis_seq in QueueHolds (stopping GPU-signal & list-values false invalidations), fixes BeforeExecuteCoalescer cv.wait loop + adds 5-step leader timing, decouples QueueHolds::run_barriers() from pump_mutex_ via barrier_mutex_, and expands VulkanPresenter::frames_ to 4.
AI-assisted: Antigravity (Gemini 4 Neon).
|
|
and lock/worker telemetry
Eliminates multi-worker global lock convoys, Wait-split async room stalls, and instrumentation blind spots:
- vulkan_backend.h / d3d12_vulkan_device.cpp / d3d12_com.cpp: adds visibility_seq_ & signaled_visibility_seq_ tracking and BeforeExecuteCoalescer so concurrent/back-to-back cross-queue submissions serialize global refresh passes to one leader and skip redundant refreshes when pass_seq >= req_seq (opt-out LEONIDA_BEFORE_EXECUTE_COALESCE=0).
- vulkan_backend.h: replaces Wait-broken pending_submit_groups_locked() with pending_frame_groups_locked() and max_batches = max(16 * depth, 64) for depth >= 2, eliminating mid-frame room_cv_ stalls on Wait-heavy frames.
- vulkan_backend.h / submit_phases.h: includes release_held() and pump_ready() in async_worker() busy time and adds worker_lock_wait_ns reporting.
- d3d12_vulkan_device.cpp / d3d12_com.cpp: lock-free ConsoleHeap::in_place_work_pending fast-skip, FilterPageCache in finish_in_place(), identical-base dedup of mirror_ranges, and cached console-heap fast-path in GraphicsCommandList::address().
AI-assisted: Antigravity (Gemini 4 Neon).
|
|
batch-parallel sync compiles
Cuts queue submit overhead, descriptor-heap filtering cost, and synchronous cold pipeline compile latency:
- VulkanQueue: adds pending-wait tracking (has_unsatisfied_waiter), deduplicated submit_multi(), execute+signal coalescing with cross-queue/CPU waiter splits, and coalescing-group-aware async room gating.
- d3d12_com.cpp: caches descriptor heap VAs/counts on SetDescriptorHeaps, pre-tracks command-list barrier/query/indirect/draw flags, single-alloc PinnedObjects, and linear table dedup.
- d3d12_vulkan_device.cpp: AVX2 32-byte slot equality, 8 KiB L1d seen_keys, stack-local FilterPageCache, 64 KiB page-pointer caching, and T# dedup in finish_in_place.
- vulkan_replay.h / d3d12_vulkan_device.cpp: lightweight collect_unbuilt_pipelines() pre-pass and cancel-safe batch-parallel sync compile runner backed by PipelineCompiler.
AI-assisted: Antigravity (Gemini 4 Neon).
|
|
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).
|
|
coalescing barriers
AI-assisted: Antigravity (Gemini 4 Neon).
|
|
|
|
track active_seq_
Fix queue-sync bugs in VulkanQueue (runtime/src/vulkan_backend.h):
1. Synchronous execute_sync_impl(): when executing_ is active and this
batch is not blocked by an unmet Wait (blocked_by_wait_locked()), wait
on exec_cv_ with state_mutex_ unlocked instead of silently deferring
into held_. When !executing_ && !blocked_by_wait_locked(), take
executing_ and drain any already-ready held ops ahead of us first
(closing the gap between QueueHolds::signaled() and pump_ready()
reaching this queue), then hold behind a wait-blocked front if
must_hold() remains true or execute synchronously with before_execute_()
before returning. Wait, Signal, Marker, and genuinely wait-blocked
batches still enqueue under state_mutex_ without blocking on
before_execute_() or replay.
2. active_seq_ tracking: assign active_seq_ under state_mutex_ for direct
unheld execute_sync_impl(), signal_sync(), marker_sync(), update_tiles(),
and copy_tile_mappings(), clear active_seq_ before drain/release,
linearize oldest_held_seq() under state_mutex_, and flush
QueueHolds::pump_ready() after releasing state_mutex_ so after_held()
barriers never overtake active unheld submissions.
3. Remove unsafe cross-batch coalescing in drain_held_while_executing() and
async_worker() (along with batch_breaks, barrier_after,
run_single_held_batch, and run_coalesced_execute*) so every
ExecuteCommandLists runs its own before_execute_(), bindless_prepare_(),
prelude_record_(), and fault markers in strict FIFO order.
4. Fix stale prepared[] iteration in execute_now() statistics->mesh setup
by iterating only i < lists.size().
Update and expand submit_frame_test to cover sync exec_cv_ waiting,
unlocked wait-blocked enqueue, releaser-drain sync ordering, ready-front
drain while pump_mutex_ is held by another thread, active_seq_ protection
of after_held() across unheld execute() and signal(), per-batch FIFO
drain without coalescing, zero-copy CommandList Reset(), and QueueHolds
progress tracking.
Tested on Linux (AMD Ryzen 9 7950X3D iGPU, RADV RAPHAEL_MENDOCINO,
MESA_VK_DEVICE_SELECT=1002:164e!): 9/9 required queue ctest targets passed
(2.92s) plus 5/5 submit_frame_test stress runs.
AI-assisted: Antigravity (Gemini 4 Neon).
|
|
list-value gates
Fixes premature unmet release of console list-value gates at Present under
LEONIDA_SUBMIT_ASYNC and unlocked queue execution:
- QueueHolds (runtime/src/queue_holds.h): add process-wide queue_holds::any_progress()
backed by a lock-free active CPU/async work counter (WorkGuard / work_changed),
signaled_unpumped_ tracking across signaled() -> pump_ready(), and per-holder
lock-free has_pending_gpu_work() protected against detach() via holders_use_mutex_.
- VulkanQueue (runtime/src/vulkan_backend.h): account for queued async inbox calls,
active async_worker turns (through pump_ready()), pending release_requested_ flags
(with async_stop_ guard), synchronous/draining executing_ passes (through pump_ready()),
VulkanFence::signal() -> pump_ready(), and unretired GPU tickets (submitted_gpu_ vs
progress_ counter). Stop cross-queue release_ready() ping-pong by waking only when
held_front_seq_ != 0 and calling pump_ready() in async_worker() only when a call
ran or a held op was released.
- Pump::choose_release (runtime/shims/d3d12_xs_list_values.h): treat
leonida::queue_holds::any_progress() as active queue progress so held waits are
never broken unmet while a producer async worker, executing pass, or GPU submission
is still progressing; advance last_progress_ms_ so kStalledMs measures genuine quiet
time. Genuine deadlocks (cycles, idle queues + idle GPU at Present, stalled title)
still break cleanly.
- Tests: add CPU-only QueueHolds + list_value_progress tests in
list_value_progress_test.cpp and real VulkanQueue async-depth=4 + Present + busy
producer + genuine deadlock + synchronous executing_ tests in submit_frame_test.cpp.
AI-assisted: Antigravity, Gemini 4 Neon.
Tested on Linux (RADV RAPHAEL_MENDOCINO, MESA_VK_DEVICE_SELECT=1002:164e!):
8/8 passed (list_value_progress, submit_frame, vk_queue, vk_queue_query_sync,
vk_queue_constructor_oom, vk_fence_dispatcher_sync, vk_semaphore_lifetime,
vk_fence_lost_by_counter).
|
|
batches, zero-copy CommandList
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)
|
|
thread
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>
|
|
the submit phases line
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>
|