diff --git a/base/vulkantools.cpp b/base/vulkantools.cpp index 722410d1..8bdd9135 100644 --- a/base/vulkantools.cpp +++ b/base/vulkantools.cpp @@ -53,7 +53,6 @@ namespace vkTools { switch (errorCode) { - // todo : update to SDK 0.10.1 #define STR(r) case VK_ ##r: return #r STR(NOT_READY); STR(TIMEOUT); @@ -67,13 +66,34 @@ namespace vkTools STR(ERROR_MEMORY_MAP_FAILED); STR(ERROR_LAYER_NOT_PRESENT); STR(ERROR_EXTENSION_NOT_PRESENT); + STR(ERROR_FEATURE_NOT_PRESENT); STR(ERROR_INCOMPATIBLE_DRIVER); + STR(ERROR_TOO_MANY_OBJECTS); + STR(ERROR_FORMAT_NOT_SUPPORTED); + STR(ERROR_SURFACE_LOST_KHR); + STR(ERROR_NATIVE_WINDOW_IN_USE_KHR); + STR(SUBOPTIMAL_KHR); + STR(ERROR_OUT_OF_DATE_KHR); + STR(ERROR_INCOMPATIBLE_DISPLAY_KHR); + STR(ERROR_VALIDATION_FAILED_EXT); + STR(ERROR_INVALID_SHADER_NV); #undef STR default: return "UNKNOWN_ERROR"; } } + VkResult checkResult(VkResult result) + { + if (result != VK_SUCCESS) + { + std::string errorMsg = "Fatal : VkResult returned " + errorString(result) + "!"; + std::cout << errorMsg << std::endl; + assert(result == VK_SUCCESS); + } + return result; + } + VkBool32 getSupportedDepthFormat(VkPhysicalDevice physicalDevice, VkFormat *depthFormat) { // Since all depth formats may be optional, we need to find a suitable depth format to use diff --git a/base/vulkantools.h b/base/vulkantools.h index 83bd785c..dd9351de 100644 --- a/base/vulkantools.h +++ b/base/vulkantools.h @@ -19,6 +19,7 @@ #include #include #include +#include #ifdef _WIN32 #include #include @@ -37,7 +38,9 @@ namespace vkTools VkBool32 checkDeviceExtensionPresent(VkPhysicalDevice physicalDevice, const char* extensionName); // Return string representation of a vulkan error string std::string errorString(VkResult errorCode); - + // Asserts and outputs the error message if the result is not VK_SUCCESS + VkResult checkResult(VkResult result); + // Selected a suitable supported depth format starting with 32 bit down to 16 bit // Returns false if none of the depth formats in the list is supported by the device VkBool32 getSupportedDepthFormat(VkPhysicalDevice physicalDevice, VkFormat *depthFormat);