Repository navigation
Conversation
abnalstlll-byte
left a comment
There was a problem hiding this comment.
Clean-Room & Technical Verification
- Mergeability: 3-way merge against upstream
main(bcaa13dad) is 100% clean with zero merge conflicts. - Clean-Room Compliance: 100% clean-room. Vulkan runtime concurrency architecture and synthetic mock tests only; zero retail code, game data, or keys (
check_no_game_data.pyclean). - Technical Rigor & Concurrency Design:
- Introduces independent
pipeline_mutex_(std::shared_mutex) to protect pipeline registry and compilation tasks, decoupling them fromresource_mutex_. - In
VulkanQueue::execute_now(), releasesresource_lockandtracker_lockbefore executing long-runningcompiles.build(...)passes, completely unblocking render-thread resource registration (add_resource/remove_resource) and avoiding lock convoys that previously triggered the title's hang watchdog during world start shader compilation. - On pass 1, safely re-acquires
resource_lockand re-prepares submissions against up-to-date resources while leveraging prior compilation outcomes inPipelineCompiles, preventing duplicate compilations or spurious failure logs. - Zero overhead on warm paths (
compiles.empty()). - Tested via synthetic mock suite
runtime/test/replay_pipeline_compile_unlock_test.cppandreplay_pipeline_compiles_test.cpp.
- Introduces independent
LGTM! Approved.
5238021 to
92a2a93
Compare
|
Built 1. The two tests don't compile. The runtime itself builds, but the tests stop with:
2. The new tests pass. 3. A regression: That is So in serial mode a refused compile no longer cuts the pass short. The rest of the submission's pipelines are compiled first, as the workers path already did, so a failing submission takes longer before it is reported unsupported; compute pipelines can take 2-5 s each, per the description. The pipelines that did build are kept, so this moves the work earlier more than it adds work, but it is still a change for the serial path. The description says collecting through Whole |
Address Windows MSVC / RX 7900 XT review findings on ProjectLeonida#1742: - Qualify VulkanQueue::QueueKind::compute and ReplayResult::unresolved_resource in replay_pipeline_compile_unlock_test.cpp and replay_pipeline_compiles_test.cpp. - Add PipelineCompiles::build_serial() / build_pipelines_serial() so the no-workers serial path still compiles outside resource_mutex_ while stopping at the first fatal refusal (preserving d3d12_pipeline_workers::refused_graphics serial expectations and avoiding wasted compiles after a failed draw). - Add serial_stops_at_refused_draw() unit coverage in replay_pipeline_compiles_test.cpp.
|
Thank you @adrianmjim for the MSVC / RX 7900 XT build and Both items are now fixed and pushed (rebased on
|
92a2a93 to
d33ada4
Compare
|
Thank you, @IlyassRS3: the render thread no longer waits behind shader compiles for
AI-assisted (Claude Code, Claude Opus 5.5). |
|
Intel integration verification of the merged fix: Windows 11, MSVC RelWithDebInfo, Intel UHD Graphics / i5-1334U, driver 32.0.101.6314. Integrated main 3657294 into an existing private runtime tree; no changes to this PR's logic were needed. 14/14 targeted tests passed with LEONIDA_VK_VALIDATION=1: replay_pipeline_compile_unlock, replay_pipeline_compiles and strict, d3d12_pipeline_workers and eager, vk_queue, vk_queue_query_sync, vk_presenter_sync, vk_queue_constructor_oom, vulkan_device_fault, xbox_bvh_builder, d3d12_unbound_tsharp_rules, d3d12_compute, and d3d12_m2_textured. This includes the serial-refusal behavior raised in the earlier review. This is a targeted combined-tree result, not a full Windows-suite or playability claim. No game data included. AI-assisted with OpenAI Codex. |
Brings ProjectLeonida#1889 up to date with main after ProjectLeonida#1742 (the pipeline compile unlock), resolving the five conflicts as described in the guide on the PR: ProjectLeonida#1889 (comment) - 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 ProjectLeonida#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>
Item ID:
RT-PIPELINE-COMPILE-UNLOCK-RESOURCESClaim: #1608 (comment)
Addresses finding: #1608 (comment) (render thread stalled on
VulkanContext::remove_resource->resource_mutex_behind 2–5 s compute pipeline compiles at world start, tripping the title's hang watchdog)Root cause
VulkanContextpreviously guarded both resources (resources_,buffer_vas_,query_pools_,add_resource()/remove_resource()) and registered pipelines (pipelines_,graphics_pipelines_,pipeline_workers_,device_fault_->pipeline_names) under onestd::shared_mutex resource_mutex_.VulkanQueue::execute_now()(runtime/src/vulkan_backend.h) heldstd::shared_lock(resource_mutex_)acrossprepare()andbuild_pipelines()to keepPipelineStateobjects alive during compilation. Whenever a queue compiled unbuilt world shaders (2–5 s each invkCreateComputePipelines),VulkanContext::remove_resource()/add_resource()on the title's render thread blocked onstd::unique_lock(resource_mutex_), creating a lock convoy that also stalled other queues andVulkanPresenteruntil the hang watchdog fired.Changes
runtime/src/vulkan_backend.h:VulkanContext::pipeline_mutex_(std::shared_mutex) to guardpipelines_,graphics_pipelines_,pipeline_workers_, anddevice_fault_->pipeline_namesindependently ofresource_mutex_, keeping a strict lock hierarchy:state_mutex_->pipeline_mutex_->resource_mutex_->tracker_mutex_->submit_mutex_.VulkanQueue::execute_now()to holdpipeline_lockacrossprepare()/ compilation /emit(), always collect unbuilt pipelines viaPipelineCompiles(both withpipeline_workers_and in serial mode), and on pass 0 when!compiles.empty()retire uncommitted pass-0 helper state and releasetracker_lockandresource_lockbefore runningcompiles.build(...)underpipeline_lockalone. Pass 1 then re-acquiresresource_lockand re-prepares against current resources so no staleVkBuffer/VkImagehandle can survive a concurrent resource update.compiles.empty()).runtime/src/vulkan_replay.h:PipelineCompiles::lookup()/contains_ticket(), optionalpriorparameter toPipelineCompiles::build()andbuild_pipelines(), and sharedcheck_compiled_pipelines()so pass-1 re-preparation reuses prior outcomes (preventing doublebuild()calls or duplicateunresolved_atlogs on non-strict failed compute dispatches).runtime/test/replay_pipeline_compiles_test.cpp,runtime/test/replay_pipeline_compile_unlock_test.cpp,runtime/CMakeLists.txt:replay_pipeline_compiles_testwithprior_compiles_reusecovering pass-1 reuse of built and non-strict failed compute dispatches.replay_pipeline_compile_unlock_testverifying (both withPipelineWorkers(2)and serialpipeline_workers_ == nullptr) thatadd_resource(),remove_resource(), and a secondVulkanQueue::execute()complete while a slow compile is blocked inbuild(), thatremove_pipeline()safely waits onpipeline_mutex_until compilation ends, that concurrent resource replacement is picked up on pass 1 (vkCmdCopyBufferbinds the newVkBuffer), and that a non-strict failed compute dispatch invokesbuild()only once.Verification
Vulkan::Headersinstalled)python3 -I scripts/check_no_game_data.py runtime/src/vulkan_replay.h runtime/src/vulkan_backend.h runtime/test/replay_pipeline_compiles_test.cpp runtime/test/replay_pipeline_compile_unlock_test.cpp runtime/CMakeLists.txt: PASS.python3 -I tests/test_text_write_line_endings.py: 3/3 OK.runtime/src/vulkan_backend.h,runtime/src/vulkan_replay.h,runtime/test/replay_pipeline_compiles_test.cpp, andruntime/test/replay_pipeline_compile_unlock_test.cpprequireVulkan::Headers(not present on this macOS host) and rely on CI (replay_pipeline_compiles,replay_pipeline_compiles_strict,replay_pipeline_compile_unlock, and existingvk_queue_*/vk_presenter_synctests).