Add a VK::toError function to simplify vulkan error handling.#1085
Add a VK::toError function to simplify vulkan error handling.#1085manon-traverse wants to merge 1 commit intollvm:mainfrom
Conversation
| return llvm::createStringError("%s (VkResult = %d)", Msg.data(), | ||
| static_cast<int>(Result)); |
There was a problem hiding this comment.
Not sure how much more effort it is to stringify the error codes (or at least a few common ones), and/or to translate a few common ones to std::error_code. HR::toError()` seems to do it but not sure if that yields any advantage or if anything "relies" on it...
There was a problem hiding this comment.
HR::toError just stores it as an integer under std::system_category. The only thing in practice is that the error number is logged. This kind of does the same thing.
| //===- OffloadTest/Support/VkError.h - Vulkan Error Utils ---------*- C++ | ||
| //-*-===// |
There was a problem hiding this comment.
I think clang-format mangled this.
| // | ||
| // | ||
| //===----------------------------------------------------------------------===// |
There was a problem hiding this comment.
No need for the empty comment block
| #include <vulkan/vulkan.h> | ||
|
|
||
| #include "llvm/Support/Error.h" |
There was a problem hiding this comment.
Doesn't really matter, but I think we usually put the LLVM includes before the more system-y ones
Error handling on Vulkan was a bit manual and verbose, with random error codes being assigned. This PR simplifies this using a
VK::toErrorfunction (similar to theHR::toErrorfunction). This way, we preserve the original VkResult in the error message and don't have arbitrarily chosen error codes.