upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorabilliontokens <39147239+abilliontokens@users.noreply.github.com>2026-11-24 07:45:22 +0300
committerLen1k <102464172+Len1k@users.noreply.github.com>2026-11-24 07:45:22 +0300
commita44e66e9a384a334501ea363ea6efee2ab868cbe (patch)
tree31efa19c6e216e44852dd4e8f7556a3943a5ec91 /runtime
parentd2cd6c0d970083eee4d7b40daabb2480a77b1790 (diff)
Runtime: propagate device loss found by the retire-ticket progress query
VulkanContext::completed_retire_ticket() queried each pending submission's timeline semaphore with vkGetSemaphoreCounterValue but treated every non-VK_SUCCESS result as "not completed yet". A VK_ERROR_DEVICE_LOST seen there was swallowed, so the context was never marked lost and the queue went on to acquire, record and submit new command buffers. Every other counter query in the layer (the queue's own progress query in VulkanQueue::completed(), VulkanFence::completed(), the wait and submit paths) already calls mark_device_lost() on VK_ERROR_DEVICE_LOST; this one was the exception. acquire() runs completed_retire_ticket() before recycle_finished()'s completed(), so whichever query runs first observes the loss. When the retire-ticket query is the first to see it, it consumes the error and the queue's own query then reads a healthy counter. That is why vk_queue_query_sync's section 5 (00832c18) failed on the RX 9070 XT / AMD 26.11.2 but passed on NVIDIA: the retire ticket is still pending there, so its query runs first. Mark the context lost here too, outside submit_mutex_ as submit() does, and report no completed ticket so nothing is retired against a lost device. Fixes D3D-599. (cherry picked from commit 3a21e3aea481bb9f9d9bfe9360c5b972fb19f7bb)
Diffstat (limited to 'runtime')
-rw-r--r--runtime/src/vulkan_backend.h23
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) {