diff options
| author | cixotdev <339371196+cixotdev@users.noreply.github.com> | 2026-11-22 21:17:10 -0300 |
|---|---|---|
| committer | cixotdev <339371196+cixotdev@users.noreply.github.com> | 2026-11-22 21:17:10 -0300 |
| commit | 8dfe9bce1a3cf078685db7a8da88b3b2b47e07a8 (patch) | |
| tree | f2763ee918e8b01b7457b17d8ff59525606cc9dc /runtime/shims/d3d12_com.cpp | |
| parent | aa2988cc555bad7ecd508b48a702adbb32fe7c95 (diff) | |
runtime: notify QueueHolds when a held CPU Fence::Signal fires
When ID3D12Fence::Signal is deferred behind a pending GPU queue signal,
Fence::Signal enqueues a FenceWaitDispatcher callback that calls
vkSignalSemaphore directly instead of going through VulkanFence::signal.
That callback previously never notified QueueHolds via
holds().signaled(semaphore, value) and holds().pump_ready(), leaving any
cross-queue Wait-before-Signal batch stalled on that fence value
forever even after GetCompletedValue() reached it.
Record whether vkSignalSemaphore succeeded, decrement held_ first, and
then call holds().signaled(semaphore, value) and holds().pump_ready()
with no dispatcher or queue lock held. Add cross-queue regression cases
to check_held_cpu_signal in d3d12_fence_timing_test.cpp covering both a
Wait queued before the held CPU Signal and a Wait queued while the CPU
Signal is already held.
Claim: https://github.com/ItsNotRexed/Leonida/issues/4084#issuecomment-7088187469
AI-assisted: yes (Antigravity)
Diffstat (limited to 'runtime/shims/d3d12_com.cpp')
| -rw-r--r-- | runtime/shims/d3d12_com.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/runtime/shims/d3d12_com.cpp b/runtime/shims/d3d12_com.cpp index d9b1a009c..fc664a52b 100644 --- a/runtime/shims/d3d12_com.cpp +++ b/runtime/shims/d3d12_com.cpp | |||
| @@ -1134,14 +1134,19 @@ public: | |||
| 1134 | const VkSemaphore semaphore = fence_.semaphore(); | 1134 | const VkSemaphore semaphore = fence_.semaphore(); |
| 1135 | context_.enqueue_fence_callback(semaphore, queued, [context, semaphore, queued, value, held = held_] { | 1135 | context_.enqueue_fence_callback(semaphore, queued, [context, semaphore, queued, value, held = held_] { |
| 1136 | std::uint64_t now = 0; | 1136 | std::uint64_t now = 0; |
| 1137 | context->vk.vkGetSemaphoreCounterValue(context->device(), semaphore, &now); | 1137 | bool signaled = false; |
| 1138 | if (now >= queued && now < value) { | 1138 | if (context->vk.vkGetSemaphoreCounterValue(context->device(), semaphore, &now) == VK_SUCCESS && |
| 1139 | now >= queued && now < value) { | ||
| 1139 | VkSemaphoreSignalInfo info{VK_STRUCTURE_TYPE_SEMAPHORE_SIGNAL_INFO}; | 1140 | VkSemaphoreSignalInfo info{VK_STRUCTURE_TYPE_SEMAPHORE_SIGNAL_INFO}; |
| 1140 | info.semaphore = semaphore; | 1141 | info.semaphore = semaphore; |
| 1141 | info.value = value; | 1142 | info.value = value; |
| 1142 | context->vk.vkSignalSemaphore(context->device(), &info); | 1143 | signaled = context->vk.vkSignalSemaphore(context->device(), &info) == VK_SUCCESS; |
| 1143 | } | 1144 | } |
| 1144 | held->fetch_sub(1); | 1145 | held->fetch_sub(1); |
| 1146 | if (signaled) { | ||
| 1147 | context->holds().signaled(semaphore, value); | ||
| 1148 | context->holds().pump_ready(); | ||
| 1149 | } | ||
| 1145 | }); | 1150 | }); |
| 1146 | return S_OK; | 1151 | return S_OK; |
| 1147 | } | 1152 | } |