Skip to content

Commit 980336f

Browse files
committed
feat(vulkan): improve error handling for Vulkan queue submission
- Added handling for VK_ERROR_DEVICE_LOST during queue submission to prevent application termination. - Enhanced logging to provide clearer diagnostics for GPU driver issues and potential rendering artifacts. - Maintained standard error handling for other Vulkan submission errors to ensure robust operation.
1 parent 39c94f1 commit 980336f

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

.cursor/trace.log

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,33 @@
197197
{"attempt":1}
198198
{"retry":1,"result":2,"image_index":1}
199199
{"attempt":2}
200+
{"attempt":0}
201+
{"retry":0,"result":2,"image_index":1}
202+
{"attempt":1}
203+
{"retry":1,"result":2,"image_index":1}
204+
{"attempt":2}
205+
{"retry":2,"result":2,"image_index":1}
206+
{"attempt":0}
207+
{"retry":0,"result":2,"image_index":1}
208+
{"attempt":1}
209+
{"retry":1,"result":2,"image_index":1}
210+
{"attempt":2}
211+
{"retry":2,"result":2,"image_index":1}
212+
{"attempt":0}
213+
{"retry":0,"result":2,"image_index":1}
214+
{"attempt":1}
215+
{"retry":1,"result":2,"image_index":1}
216+
{"attempt":2}
217+
{"retry":2,"result":2,"image_index":1}
218+
{"attempt":0}
219+
{"retry":0,"result":2,"image_index":1}
220+
{"attempt":1}
221+
{"retry":1,"result":2,"image_index":1}
222+
{"attempt":2}
223+
{"retry":2,"result":2,"image_index":1}
224+
{"attempt":0}
225+
{"retry":0,"result":2,"image_index":1}
226+
{"attempt":1}
227+
{"retry":1,"result":2,"image_index":1}
228+
{"attempt":2}
229+
{"retry":2,"result":2,"image_index":1}

src/renderers/vulkan/vk.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,18 @@ void end_command_buffer(VkCommandBuffer command_buffer, const char *location)
935935
submit_info.signalSemaphoreCount = 0;
936936
submit_info.pSignalSemaphores = NULL;
937937

938-
VK_CHECK( qvkQueueSubmit( vk.queue, 1, &submit_info, VK_NULL_HANDLE ) );
938+
// Handle device lost gracefully instead of terminating
939+
VkResult submit_result = qvkQueueSubmit( vk.queue, 1, &submit_info, VK_NULL_HANDLE );
940+
if (submit_result != VK_SUCCESS) {
941+
if (submit_result == VK_ERROR_DEVICE_LOST) {
942+
ri.Printf(PRINT_ERROR, "Vulkan: Device lost during queue submit - GPU driver issue\n");
943+
ri.Printf(PRINT_ERROR, "Vulkan: This may cause rendering artifacts or instability\n");
944+
// Don't terminate - let vk_queue_wait_idle handle cleanup
945+
} else {
946+
// For other errors, use the standard error handling
947+
VK_CHECK(submit_result);
948+
}
949+
}
939950

940951
vk_queue_wait_idle();
941952

0 commit comments

Comments
 (0)