mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:30:53 +01:00
[PR #2402] vulkan: read the retirement records under their own lock (RT-RETIRE-TICKET-LOCK) #2403
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#2403
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/2402
Author: @wavehs
Created: 11/26/2026
Status: 🔄 Open
Base:
main← Head:retire-ticket-lock📝 Commits (1)
35eb7b4vulkan: read the retirement records under their own lock (RT-RETIRE-TICKET-LOCK)📊 Changes
4 files changed (+109 additions, -16 deletions)
View changed files
📝
runtime/CMakeLists.txt(+10 -0)📝
runtime/shims/d3d12_vulkan_device.cpp(+3 -2)📝
runtime/src/vulkan_backend.h(+31 -14)➕
runtime/test/retire_ticket_lock_test.cpp(+65 -0)📄 Description
Claimed in the coordination issue as: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7201897573
(follow-up to DadaCap's finding: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7201692029)
Depends on: none.
What and why
VulkanContext::completed_retire_ticket()andwait_retire_ticket()readretire_tickets_undersubmit_mutex_, so a caller that only asks what retired waits behind whoever holds that lock — a queue submission, or avkDeviceWaitIdleunder it. That is the hop DadaCap described: the held-work releaser inside a gateSignaland the progress watch both want the completed ticket and neither needs to submit.retire_tickets_now has its own innermostretire_mutex_:record_submit_lockedandretire_queue_idle_lockedtakesubmit_mutex_ -> retire_mutex_;completed_retire_ticketandwait_retire_tickettakeretire_mutex_alone; thewait_submitted_lockedsnapshot takes it under thesubmit_mutex_its caller already holds;retire_mutex_beforesubmit_mutex_, so the order is unchanged everywhere else;poll_retirement_lockedtry-locksretire_mutex_on purpose: a query already in progress watches the same timelines, and waiting for it while holding the submit lock is what this change removes.Queue teardown is still safe: it marks the queue's entries idle under
retire_mutex_(viaretire_queue_idle_locked) before destroying the timeline semaphore, so an in-flight query either finishes first or is skipped because the entry is idle.Test
New CPU-only ctest
retire_ticket_lock(runtime/test/retire_ticket_lock_test.cpp): one thread holdscontext.submit_mutex()for 500 ms, the main thread callscompleted_retire_ticket()and must get ticket 0 in under 200 ms.Tested
macOS 27.2.1 arm64 (Apple clang, CMake/Ninja, RelWithDebInfo), portable runtime build, no GPU and no game files:
ctestafter a full build: 114/114 passed (63-66 s).retire_ticketsandreplay_pipeline_compile_unlockare in that run;submit_mutexis Windows-only and is not part of the portable set.python3 -I tests/test_ctest_registration.py-> 6 tests, OK.python3 -I scripts/check_no_game_data.pyon the four changed files -> exit 0.python3 -m compileall -q make_game.py tools tests-> OK.Not built here: the Windows runtime (MSVC) and the title. The change is portable C++17 and the new target links
Vulkan::Headers Threads::Threadslike its neighbours, but the Windows build should confirm it.AI-assisted.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.