Skip to content

Commit b025a97

Browse files
Make chk() exit only if VkResult is a fatal error
Vulkan defines negative VkResult values as fatal errors.
1 parent 9fdd761 commit b025a97

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

source/main.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
static inline void chk(VkResult result) {
2929
if (result != VK_SUCCESS) {
3030
std::cerr << "Vulkan call returned an error (" << result << ")\n";
31-
exit(result);
31+
if (result < VK_SUCCESS){
32+
exit(result);
33+
}
3234
}
3335
}
3436
static inline void chk(bool result) {
@@ -429,7 +431,7 @@ int main()
429431
// Sync
430432
chk(vkWaitForFences(device, 1, &fences[frameIndex], true, UINT64_MAX));
431433
chk(vkResetFences(device, 1, &fences[frameIndex]));
432-
vkAcquireNextImageKHR(device, swapchain, UINT64_MAX, presentSemaphores[frameIndex], VK_NULL_HANDLE, &imageIndex);
434+
chk(vkAcquireNextImageKHR(device, swapchain, UINT64_MAX, presentSemaphores[frameIndex], VK_NULL_HANDLE, &imageIndex));
433435
// Update shader data
434436
shaderData.projection = glm::perspective(glm::radians(45.0f), (float)window.getSize().x / (float)window.getSize().y, 0.1f, 32.0f);
435437
shaderData.view = glm::translate(glm::mat4(1.0f), camPos);
@@ -627,4 +629,4 @@ int main()
627629
vmaDestroyAllocator(allocator);
628630
vkDestroyDevice(device, nullptr);
629631
vkDestroyInstance(instance, nullptr);
630-
}
632+
}

0 commit comments

Comments
 (0)