wren
Vulkan-based game engine
Loading...
Searching...
No Matches
result.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <boost/describe.hpp>
4#include <boost/preprocessor.hpp>
5#include <vulkan/vulkan.hpp>
6#include <vulkan/vulkan_enums.hpp>
7#include <vulkan/vulkan_to_string.hpp>
9
10namespace vk {
11
13 Result, eSuccess, eNotReady, eTimeout, eEventSet, eEventReset, eIncomplete,
14 eErrorOutOfHostMemory, eErrorOutOfDeviceMemory, eErrorInitializationFailed,
15 eErrorDeviceLost, eErrorMemoryMapFailed, eErrorLayerNotPresent,
16 eErrorExtensionNotPresent, eErrorFeatureNotPresent,
17 eErrorIncompatibleDriver, eErrorTooManyObjects, eErrorFormatNotSupported,
18 eErrorFragmentedPool, eErrorUnknown, eErrorOutOfPoolMemory,
19 eErrorOutOfPoolMemoryKHR, eErrorInvalidExternalHandle,
20 eErrorInvalidExternalHandleKHR, eErrorFragmentation, eErrorFragmentationEXT,
21 eErrorInvalidOpaqueCaptureAddress, eErrorInvalidDeviceAddressEXT,
22 eErrorInvalidOpaqueCaptureAddressKHR, ePipelineCompileRequired,
23 eErrorPipelineCompileRequiredEXT, ePipelineCompileRequiredEXT,
24 eErrorSurfaceLostKHR, eErrorNativeWindowInUseKHR, eSuboptimalKHR,
25 eErrorOutOfDateKHR, eErrorIncompatibleDisplayKHR, eErrorValidationFailedEXT,
26 eErrorInvalidShaderNV, eErrorImageUsageNotSupportedKHR,
27 eErrorVideoPictureLayoutNotSupportedKHR,
28 eErrorVideoProfileOperationNotSupportedKHR,
29 eErrorVideoProfileFormatNotSupportedKHR,
30 eErrorVideoProfileCodecNotSupportedKHR,
31 eErrorVideoStdVersionNotSupportedKHR,
32 eErrorInvalidDrmFormatModifierPlaneLayoutEXT, eErrorNotPermittedKHR,
33 eErrorNotPermittedEXT, eThreadIdleKHR, eThreadDoneKHR,
34 eOperationDeferredKHR, eOperationNotDeferredKHR,
35 eErrorCompressionExhaustedEXT);
36
37DEFINE_ERROR_IMPL("VulkanError", Result)
38
39} // namespace vk
40
41namespace wren {
42DEFINE_ERROR("VulkanError", VulkanErrors, NoDevicesFound,
43 QueueFamilyNotSupported)
44}
45
46#define VK_TRY_RESULT_1(unique, expr) \
47 auto [unique, BOOST_PP_CAT(unique, _out)] = expr; \
48 if (unique != ::vk::Result::eSuccess) \
49 return std::unexpected(make_error_code(unique));
50
51#define VK_TRY_RESULT_2(unique, out, expr) \
52 auto [unique, out] = expr; \
53 if (unique != ::vk::Result::eSuccess) \
54 return std::unexpected(make_error_code(unique));
55
56#define VK_TRY_RESULT(...) \
57 BOOST_PP_OVERLOAD(VK_TRY_RESULT_, __VA_ARGS__) \
58 (RESULT_UNIQUE_NAME(), __VA_ARGS__)
59
60#define VK_TIE_RESULT_IMPL(unique, out, expr) \
61 ::vk::Result unique = ::vk::Result::eSuccess; \
62 std::tie(unique, out) = expr; \
63 if (unique != ::vk::Result::eSuccess) \
64 return std::unexpected(make_error_code(unique));
65
66#define VK_TIE_RESULT(...) VK_TIE_RESULT_IMPL(RESULT_UNIQUE_NAME(), __VA_ARGS__)
67
68#define VK_CHECK_RESULT_IMPL(unique, expr) \
69 ::vk::Result unique = (expr); \
70 if ((unique) != ::vk::Result::eSuccess) \
71 return std::unexpected(make_error_code(unique));
72
73#define VK_CHECK_RESULT(expr) VK_CHECK_RESULT_IMPL(RESULT_UNIQUE_NAME(), (expr))
74
75// TODO Decprecate
76
77// NOLINTNEXTLINE
78#define VK_ERR_PROP(out, err) \
79 auto [LINEIZE(res, __LINE__), out] = err; \
80 if (LINEIZE(res, __LINE__) != ::vk::Result::eSuccess) \
81 return std::unexpected(make_error_code(LINEIZE(res, __LINE__)));
82
83// NOLINTNEXTLINE
84#define VK_ERR_PROP_VOID(err) \
85 ::vk::Result LINEIZE(res, __LINE__) = err; \
86 if (LINEIZE(res, __LINE__) != ::vk::Result::eSuccess) \
87 return std::unexpected(make_error_code(LINEIZE(res, __LINE__)));
88
89// NOLINTNEXTLINE
90#define VK_TIE_ERR_PROP(out, err) \
91 ::vk::Result LINEIZE(res, __LINE__) = ::vk::Result::eSuccess; \
92 std::tie(LINEIZE(res, __LINE__), out) = err; \
93 if (LINEIZE(res, __LINE__) != ::vk::Result::eSuccess) \
94 return std::unexpected(make_error_code(LINEIZE(res, __LINE__)));
Definition ui.hpp:5
BOOST_DESCRIBE_ENUM(Result, eSuccess, eNotReady, eTimeout, eEventSet, eEventReset, eIncomplete, eErrorOutOfHostMemory, eErrorOutOfDeviceMemory, eErrorInitializationFailed, eErrorDeviceLost, eErrorMemoryMapFailed, eErrorLayerNotPresent, eErrorExtensionNotPresent, eErrorFeatureNotPresent, eErrorIncompatibleDriver, eErrorTooManyObjects, eErrorFormatNotSupported, eErrorFragmentedPool, eErrorUnknown, eErrorOutOfPoolMemory, eErrorOutOfPoolMemoryKHR, eErrorInvalidExternalHandle, eErrorInvalidExternalHandleKHR, eErrorFragmentation, eErrorFragmentationEXT, eErrorInvalidOpaqueCaptureAddress, eErrorInvalidDeviceAddressEXT, eErrorInvalidOpaqueCaptureAddressKHR, ePipelineCompileRequired, eErrorPipelineCompileRequiredEXT, ePipelineCompileRequiredEXT, eErrorSurfaceLostKHR, eErrorNativeWindowInUseKHR, eSuboptimalKHR, eErrorOutOfDateKHR, eErrorIncompatibleDisplayKHR, eErrorValidationFailedEXT, eErrorInvalidShaderNV, eErrorImageUsageNotSupportedKHR, eErrorVideoPictureLayoutNotSupportedKHR, eErrorVideoProfileOperationNotSupportedKHR, eErrorVideoProfileFormatNotSupportedKHR, eErrorVideoProfileCodecNotSupportedKHR, eErrorVideoStdVersionNotSupportedKHR, eErrorInvalidDrmFormatModifierPlaneLayoutEXT, eErrorNotPermittedKHR, eErrorNotPermittedEXT, eThreadIdleKHR, eThreadDoneKHR, eOperationDeferredKHR, eOperationNotDeferredKHR, eErrorCompressionExhaustedEXT)
Definition editor_scene.hpp:5
#define DEFINE_ERROR_IMPL(CAT_NAME, ERROR_ENUM)
This macro creates the hooks into std::error_code for a given error enum.
Definition result.hpp:60
#define DEFINE_ERROR(cat_name, name,...)
Definition result.hpp:88