diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2020-03-27 06:50:27 +0100 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2020-03-27 07:21:04 +0100 |
commit | 3f0b7673f070dca3b5487f81f29667c1da9e11e2 (patch) | |
tree | fd6c0c0f029b75e44d6e8ef6e061b941ae8850ce /src/video_core/renderer_vulkan/wrapper.h | |
parent | renderer_vulkan/wrapper: Add ToString function for VkResult (diff) | |
download | yuzu-3f0b7673f070dca3b5487f81f29667c1da9e11e2.tar yuzu-3f0b7673f070dca3b5487f81f29667c1da9e11e2.tar.gz yuzu-3f0b7673f070dca3b5487f81f29667c1da9e11e2.tar.bz2 yuzu-3f0b7673f070dca3b5487f81f29667c1da9e11e2.tar.lz yuzu-3f0b7673f070dca3b5487f81f29667c1da9e11e2.tar.xz yuzu-3f0b7673f070dca3b5487f81f29667c1da9e11e2.tar.zst yuzu-3f0b7673f070dca3b5487f81f29667c1da9e11e2.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_vulkan/wrapper.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/video_core/renderer_vulkan/wrapper.h b/src/video_core/renderer_vulkan/wrapper.h index 8ecc1b5a3..b13d3882e 100644 --- a/src/video_core/renderer_vulkan/wrapper.h +++ b/src/video_core/renderer_vulkan/wrapper.h @@ -80,7 +80,37 @@ private: std::size_t num = 0; }; +/// Vulkan exception generated from a VkResult. +class Exception final : public std::exception { +public: + /// Construct the exception with a result. + /// @pre result != VK_SUCCESS + explicit Exception(VkResult result_) : result{result_} {} + virtual ~Exception() = default; + + const char* what() const noexcept override; + +private: + VkResult result; +}; + /// Converts a VkResult enum into a rodata string const char* ToString(VkResult) noexcept; +/// Throws a Vulkan exception if result is not success. +inline void Check(VkResult result) { + if (result != VK_SUCCESS) { + throw Exception(result); + } +} + +/// Throws a Vulkan exception if result is an error. +/// @return result +inline VkResult Filter(VkResult result) { + if (result < 0) { + throw Exception(result); + } + return result; +} + } // namespace Vulkan::vk |