mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:55:52 +01:00
[PR #1863] runtime: bound prepared_ mesh-stats loop, recycle all finished slot batches, handle zero-count indirect dispatch #1875
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1875
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1863
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/rt-queue-recycle-and-stats-bounds📝 Commits (1)
e31049cruntime: bound prepared_ mesh-stats loop, recycle all finished slot batches, handle zero-count indirect dispatch📊 Changes
4 files changed (+597 additions, -26 deletions)
View changed files
📝
runtime/CMakeLists.txt(+7 -0)📝
runtime/src/vulkan_backend.h(+7 -7)📝
runtime/src/vulkan_replay.h(+22 -19)➕
runtime/test/queue_recycle_and_stats_test.cpp(+561 -0)📄 Description
Item ID:
RT-QUEUE-RECYCLE-AND-STATS-BOUNDSClaim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7163162118
Summary
Fixes three correctness and resource-retention bugs in
VulkanQueue(runtime/src/vulkan_backend.h) and command-list replay (runtime/src/vulkan_replay.h):statistics->meshcollection tolists.size()inVulkanQueue::execute_now()(runtime/src/vulkan_backend.h:3151)prepared_is intentionally kept at the high-water mark of previousExecuteCommandListsbatch sizes (vulkan_backend.h:2939-2942), and every other loop inexecute_now()bounds iteration tolists.size().for (const auto& list : prepared), pulling stalestatistics_meshentries fromprepared_[lists.size()..]intostatistics->mesh. After a multi-list batch containing a mesh draw inside a pipeline-statistics query, a later smaller vertex-only statistics batch saw the stale1entry and needlessly createdmesh_poolandprimitives_pool(and appended extra entries paststatistics_segments).CommandSlots inVulkanQueue::recycle_finished()(runtime/src/vulkan_backend.h:3835-3853)recycle_finished()freedsegments,geometry,khr_instances,khr_as_queries, andeventsacross every completed slot (slot.ticket <= done), but leftpredicate,predicated_copy,counted_dispatch, andindirect_clampalive until a slot was specifically chosen asreuseinacquire().recycle_finished()always returns the first completed slot, slotsbuffers_[2..N-1]after a submission burst stayed idle while pinningPredicateReducer::Batch(VkBuffer+VkDeviceMemory+VkDescriptorPool),PredicatedBufferCopier::Batch(VkDescriptorPools),IndirectDispatchCounter::Batch(VkBuffer+VkDeviceMemory), andIndirectArgumentClamp::Batch(counter slots out of the 4,096 cap) until queue destruction..reset()calls intorecycle_finished()frees all finished slots' batches immediately on the nextacquire().ExecuteIndirect(dispatch)before clamp/counted-dispatch helpers (runtime/src/vulkan_replay.h:3844, 4936)prepare()explicitly allowsind->max_count == 0as a no-op (vulkan_replay.h:3821), but previously fell through toprepare_indirect_clamp/prepare_counted_dispatchwhich both reject!max_countand failed the entire list. Now returns early (after validating arguments, pipeline, andvk.dispatch_indirect) and skips emit for!ind->max_count.Tests
Added pure-CPU mock-Vulkan test
runtime/test/queue_recycle_and_stats_test.cpp(registered as CTestqueue_recycle_and_statsunderif(TARGET Vulkan::Headers)inruntime/CMakeLists.txt).Verified locally on macOS arm64 (Apple Clang) using the pinned Khronos
Vulkan-Headers(6802bb4733b63ed5efd3adb308a6c885ef180ea1):queue_recycle_and_stats_test: PASS under ASan+UBSan, PASS under TSan (0 races), PASS under-O2(3 consecutive runs),-Wall -Wextra -Werror.replay_query_predication_test: PASS under ASan+UBSan.main'svulkan_backend.h+vulkan_replay.h: fails all 7 bug assertions (stalemesh_pool/primitives_poolcreation on vertex-only batch, and 3/4 leakedPredicateReducer::BatchandIndirectDispatchCounter::Batchslots).python3 -I scripts/check_no_game_data.py ...andpython3 -I tests/test_text_write_line_endings.pypass.Disclosure
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.