evan 2026.1.4
Evan
Loading...
Searching...
No Matches
Error.hpp
1/*
2** ETIB PROJECT, 2026
3** evan
4** File description:
5** Error
6*/
7
8#pragma once
9
10#include "evan/EvanPlatform.hpp"
11
12namespace evan
13{
25 enum class Error {
26 Ok = 0,
27
28 // Recoverable — the consumer should react and keep running.
29 Suboptimal, // VK_SUBOPTIMAL_KHR: presentable, recreate soon
30 SwapchainOutOfDate, // VK_ERROR_OUT_OF_DATE_KHR: recreate swapchain
31 NotReady, // VK_NOT_READY / XR session not running / invalid
32 // time
33 Unsupported, // feature/capability unavailable on this build or
34 // device (e.g. AR on a desktop build)
35
36 // Fatal — the consumer should stop cleanly.
37 DeviceLost, // VK_ERROR_DEVICE_LOST
38 RuntimeLost, // XR_ERROR_SESSION_LOST / XR_ERROR_INSTANCE_LOST /
39 // XR_SESSION_STATE_LOSS_PENDING
40 OutOfMemory, // VK_ERROR_OUT_OF_{HOST,DEVICE}_MEMORY
41 RuntimeError // anything else / GLFW errors
42 };
43
47 [[nodiscard]] constexpr bool isOk(Error error)
48 {
49 return error == Error::Ok;
50 }
51
56 [[nodiscard]] constexpr bool isFatal(Error error)
57 {
58 switch (error) {
59 case Error::Ok:
60 case Error::Suboptimal:
61 case Error::SwapchainOutOfDate:
62 case Error::NotReady:
63 case Error::Unsupported:
64 return false;
65 case Error::DeviceLost:
66 case Error::RuntimeLost:
67 case Error::OutOfMemory:
68 case Error::RuntimeError:
69 return true;
70 }
71 return true;
72 }
73
77 [[nodiscard]] constexpr bool isRecoverable(Error error)
78 {
79 return !isOk(error) && !isFatal(error);
80 }
81
89 template<typename T> struct Result {
90 Error code = Error::Ok;
91 T value {};
92 };
93
100 [[nodiscard]] Error mapVkResult(VkResult result);
101} // namespace evan
Small result wrapper used by helpers that must return both a status and a value (e....
Definition Error.hpp:89