Repository navigation
Conversation
Kam471
left a comment
There was a problem hiding this comment.
Built and ran vk_storage_init_sync_test at c74d2396 on Windows 11, RTX 5070 Ti: 5/5 scenarios ok, exit 0.
- destroyed initializing queue before second queue submit: ok
- destroyed initializing queue during in-flight waiter: ok
- second batch on Queue B still waits while init is in flight: ok
- chained cross-queue storage-init signaling: ok
- failed-submit rollback and remove_resource cleanup: ok
git diff --check clean. The context-owned timeline semaphore removes the dependency on the initializing queue's progress_ semaphore, which is what the lifetime hazard needed.
|
Verified Hardware & validation results
Code & Python checks
AI-assisted (Gemini, Antigravity). |
Flyander
left a comment
There was a problem hiding this comment.
[P1] Keep a queue wait after the timeline value completes
vkGetSemaphoreCounterValue only observes the counter. If queue A completes storage initialization before queue B's first shader use, this code records completed >= latest, sets pending=false, and submits B with no semaphore wait. The host query does not establish the signal-to-batch memory dependency; Vulkan defines that dependency through the queue semaphore wait: https://docs.vulkan.org/spec/latest/chapters/synchronization.html#semaphore-waiting. Please retain a timeline wait for a shader consumer even when the value is already reached.
[P2] Do not block submissions that cannot consume storage images
prepare_storage_init_sync runs for every submission, including copy-only or empty work. When initialization is pending on another queue, it adds the wait even though that submission has no dispatch, draw, or ExecuteIndirect that reads storage images. Gate the consumer wait on actual shader use; keep signaling the initialization submission.
[P2] Propagate timeline semaphore creation failure
When vkCreateSemaphore fails, the constructor sets storage_init_timeline_ to VK_NULL_HANDLE but leaves the context usable. prepare_storage_init_sync then returns without a wait or signal, while the initialization can still be submitted and storage_pending_ cleared. A later queue can use an image without cross-queue ordering. Fail initialization or use a safe serialized fallback instead of silently disabling synchronization.
|
[P2] Preserve both synchronization channels when integrating #4517 Cross-PR integration finding (runtime/src/vulkan_backend.h:2322-2324): #4517 changes this same submit() API to carry the bindless timeline through the single extra_wait / extra_signal pair, while this PR uses that pair for storage initialization. These changes are therefore not merely adjacent: one execute() can record a bindless table/fallback upload and initialize a pending storage image in the same shader batch, and that submission must signal (and potentially wait on) both dependencies. Resolving the overlap by retaining either call path would silently drop the other synchronization edge. Please either generalize submit() to accept both pairs (or unify the trackers), mark the merge dependency/overlap, and add a combined regression where one batch records both kinds of work and a different queue consumes them. AI-assisted review. No game data used. |
|
Tested Your new test, which is the point of the change — it builds and runs on Linux: Same result after merging your branch onto GPU suite, same numbers in all states:
Machine: Linux Mint 22 (Ubuntu 24.04 base), |
…, and generalize submit
|
Addressed @Flyander's review points and @editrice's cross-PR integration finding in
Verification at
|
|
Fixed the
Verification at
|
|
This conflicts with current main 3faac55 in runtime/src/vulkan_backend.h — main's D3D-71 zero_pending_ work landed in the same member block after your base (merge-tree: sole file, four hunks). Nothing on main duplicates the context-owned storage-init timeline, so it is a rebase, not a supersession; the rebase must decide how zero_pending_ participates in the new design. Static review is sound: the borrowed queue-progress-semaphore lifetime is the right root cause for the destroyed-semaphore crashes and signal assignment is serialized under the exclusive tracker lock, so concurrent initializers cannot collide. One coordination note: it also conflicts pairwise with #4557 in the same header — whoever lands second rebases. Not compiled or GPU-run here; no CI checks reported. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only review). |
|
Re-tested the new head Still green on this box:
What changed since my last pass, and it is the actionable part: your branch no longer merges cleanly onto whereas the same test two hours ago merged cleanly. So the merged-state numbers I could give you for RTX 5080 not used in this pass (186 MiB free, another job holds the card). AI-assisted testing, counts read through |
Summary
Replaces per-queue
VulkanContext::storage_init_semaphore_(which stored a rawVulkanQueue::progress_semaphore owned by the initializing queue) with a context-owned timeline semaphore (storage_init_timeline_) inruntime/src/vulkan_backend.h, and cleans upstorage_pending_inremove_resource().Fixes five issues:
VUID-VkSubmitInfo-pWaitSemaphores-parameter): Destroying the initializing queue destroyedprogress_viavkDestroySemaphorewithout invalidatingstorage_init_semaphore_, causing subsequent submissions on other queues to wait on a destroyed semaphore (or risk handle-reuse aliasing).VUID-vkDestroySemaphore-semaphore-05149): Even if~VulkanQueue()cleared the pointer, destroying the initializing queue while another queue had an in-flight submission waiting onprogress_violated Vulkan semaphore lifetime rules. Owningstorage_init_timeline_inVulkanContextkeeps the awaited semaphore alive until context destruction.storage_init_seen_on batch 1 skipped waiting on batch 2 even if initialization on queue A was still in flight.prepare_storage_init_sync()checksvkGetSemaphoreCounterValueagainststorage_init_value_and skips waits once the timeline counter reacheslatest.waits_leak: Waiting viasubmit(..., extra_wait, ..., extra_signal, ...)leaveswaits_/wait_values_unmodified on a transientvkQueueSubmitfailure.storage_pending_entries:VulkanContext::remove_resource()now erasesidfromstorage_pending_so destroyed/reused IDs do not trigger spurious init tracking.runtime/src/vulkan_backend.h).Negative control (unmodified
main03b09a08)Running
vk_storage_init_sync_testbefore thevulkan_backend.hfix fails subtest 1 deterministically both without validation and withLEONIDA_VK_VALIDATION=1:Verification
Tested on AMD Radeon RX 6900 XT (AMD Adrenalin 26.11.2, Windows 11 x64, MSVC 19.52.37029, Vulkan SDK 1.4.363.1):
.\runtime\build\vk_storage_init_sync_test.exe(3 consecutive runs): 3/3 passed (all 5 subtests OK).LEONIDA_VK_VALIDATION=1 .\runtime\build\vk_storage_init_sync_test.exe(5 consecutive runs): 5/5 passed,validation errors: 0.LEONIDA_VK_VALIDATION=1onvk_queue_test.exe(validation errors: 0),vk_queue_query_sync_test.exe,d3d12_descriptor_test.exe,d3d12_r9g9b9e5_uav_test.exe(0 validation errors): all passed.ctest --test-dir runtime/build --output-on-failure: 100% tests passed, 0 tests failed out of 156 (including#66 vk_storage_init_syncPassed in 0.13 sec; 8 skipped for missing game data / validation-off gating, 1 disabledgameinput).python -I tests/test_ctest_registration.py: 4 tests OK (0.097s);git diff --checkclean; CRLF count = 0 across all modified/added files.AI-assisted.