diff options
| author | pmilewsskiedu-gif <pmilewsskiedu-gif@users.noreply.github.com> | 2026-11-22 20:57:54 -0500 |
|---|---|---|
| committer | pmilewsskiedu-gif <pmilewsskiedu-gif@users.noreply.github.com> | 2026-11-22 20:57:54 -0500 |
| commit | 8728339f9e8e7fb46ac4d965d4d4e03276f62378 (patch) | |
| tree | 054558edaede22be0b753c3eabb18d8d4cdaa060 /runtime/src/vulkan_backend.h | |
| parent | 0e63ec7658945e3726de4d70ed1a9ab5e12d324b (diff) | |
Runtime: preserve fence signal and report blocking wait device loss
Diffstat (limited to 'runtime/src/vulkan_backend.h')
| -rw-r--r-- | runtime/src/vulkan_backend.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/runtime/src/vulkan_backend.h b/runtime/src/vulkan_backend.h index a168d9a49..260a0ec9f 100644 --- a/runtime/src/vulkan_backend.h +++ b/runtime/src/vulkan_backend.h | |||
| @@ -1411,11 +1411,19 @@ public: | |||
| 1411 | // ID3D12Fence::Signal from the CPU. Vulkan timelines only increase: a value at or below the current one is | 1411 | // ID3D12Fence::Signal from the CPU. Vulkan timelines only increase: a value at or below the current one is |
| 1412 | // ignored (D3D12 would set it), and the caller is told. | 1412 | // ignored (D3D12 would set it), and the caller is told. |
| 1413 | bool signal(std::uint64_t value) { | 1413 | bool signal(std::uint64_t value) { |
| 1414 | if (value <= completed()) return false; | 1414 | // The dispatcher may be testing a failed counter query. Do not call completed() here: |
| 1415 | // it marks the context lost on a query error and prevents the dispatcher from waking. | ||
| 1416 | if (context_.is_device_lost()) return false; | ||
| 1417 | std::uint64_t current = 0; | ||
| 1418 | if (context_.vk.vkGetSemaphoreCounterValue(context_.device(), semaphore_, ¤t) == VK_SUCCESS && | ||
| 1419 | value <= current) | ||
| 1420 | return false; | ||
| 1415 | VkSemaphoreSignalInfo info{VK_STRUCTURE_TYPE_SEMAPHORE_SIGNAL_INFO}; | 1421 | VkSemaphoreSignalInfo info{VK_STRUCTURE_TYPE_SEMAPHORE_SIGNAL_INFO}; |
| 1416 | info.semaphore = semaphore_; | 1422 | info.semaphore = semaphore_; |
| 1417 | info.value = value; | 1423 | info.value = value; |
| 1418 | if (context_.vk.vkSignalSemaphore(context_.device(), &info) != VK_SUCCESS) return false; | 1424 | const VkResult result = context_.vk.vkSignalSemaphore(context_.device(), &info); |
| 1425 | if (result == VK_ERROR_DEVICE_LOST) context_.mark_device_lost(); | ||
| 1426 | if (result != VK_SUCCESS) return false; | ||
| 1419 | context_.holds().signaled(semaphore_, value); // queues that held a batch for this value run it now | 1427 | context_.holds().signaled(semaphore_, value); // queues that held a batch for this value run it now |
| 1420 | context_.holds().pump_ready(); | 1428 | context_.holds().pump_ready(); |
| 1421 | return true; | 1429 | return true; |
| @@ -1427,7 +1435,9 @@ public: | |||
| 1427 | info.semaphoreCount = 1; | 1435 | info.semaphoreCount = 1; |
| 1428 | info.pSemaphores = &semaphore_; | 1436 | info.pSemaphores = &semaphore_; |
| 1429 | info.pValues = &value; | 1437 | info.pValues = &value; |
| 1430 | return context_.vk.vkWaitSemaphores(context_.device(), &info, timeout_ns) == VK_SUCCESS; | 1438 | const VkResult result = context_.vk.vkWaitSemaphores(context_.device(), &info, timeout_ns); |
| 1439 | if (result == VK_ERROR_DEVICE_LOST) context_.mark_device_lost(); | ||
| 1440 | return result == VK_SUCCESS; | ||
| 1431 | } | 1441 | } |
| 1432 | 1442 | ||
| 1433 | private: | 1443 | private: |