diff options
Diffstat (limited to 'runtime/src/vulkan_backend.h')
| -rw-r--r-- | runtime/src/vulkan_backend.h | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/runtime/src/vulkan_backend.h b/runtime/src/vulkan_backend.h index e3e4defe8..b1c9463ec 100644 --- a/runtime/src/vulkan_backend.h +++ b/runtime/src/vulkan_backend.h | |||
| @@ -1483,12 +1483,23 @@ public: | |||
| 1483 | void note_bindless_upload() { bindless_upload_pending_ = true; } | 1483 | void note_bindless_upload() { bindless_upload_pending_ = true; } |
| 1484 | 1484 | ||
| 1485 | std::uint64_t completed_retire_ticket() { | 1485 | std::uint64_t completed_retire_ticket() { |
| 1486 | std::lock_guard lock(submit_mutex_); | 1486 | bool lost = false; |
| 1487 | if (is_device_lost()) return 0; | 1487 | std::uint64_t ticket = 0; |
| 1488 | return retire_tickets_.completed([this](VkSemaphore semaphore, std::uint64_t value) { | 1488 | { |
| 1489 | std::uint64_t done = 0; | 1489 | std::lock_guard lock(submit_mutex_); |
| 1490 | return vk.vkGetSemaphoreCounterValue(device_, semaphore, &done) == VK_SUCCESS && done >= value; | 1490 | if (is_device_lost()) return 0; |
| 1491 | }); | 1491 | ticket = retire_tickets_.completed([this, &lost](VkSemaphore semaphore, std::uint64_t value) { |
| 1492 | std::uint64_t done = 0; | ||
| 1493 | const VkResult result = vk.vkGetSemaphoreCounterValue(device_, semaphore, &done); | ||
| 1494 | if (result == VK_ERROR_DEVICE_LOST) lost = true; | ||
| 1495 | return result == VK_SUCCESS && done >= value; | ||
| 1496 | }); | ||
| 1497 | } | ||
| 1498 | // Outside submit_mutex_, as in submit(): notifying the fence dispatcher can run callbacks that submit. | ||
| 1499 | // A DEVICE_LOST seen here is the first Vulkan operation to discover it; it must not be mistaken for | ||
| 1500 | // "this ticket has not completed". | ||
| 1501 | if (lost) mark_device_lost(); | ||
| 1502 | return lost ? 0 : ticket; | ||
| 1492 | } | 1503 | } |
| 1493 | 1504 | ||
| 1494 | void drain_deleted_resources(std::uint64_t current_ticket) { | 1505 | void drain_deleted_resources(std::uint64_t current_ticket) { |