SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
Formatters.h
1#pragma once
2
3#include "spark/base/Macros.h"
4
5#include "vulkan/vulkan.h"
6
7#include <format>
8
9SPARK_WARNING_PUSH
10SPARK_DISABLE_CLANG_WARNING(-Wswitch) // warning: enumeration value `VK_ERROR_INVALID_VIDEO_STD_PARAMETERS_KHR` not handled in switch
11SPARK_DISABLE_GCC_WARNING(-Wswitch) // warning: enumeration value `VK_ERROR_INVALID_VIDEO_STD_PARAMETERS_KHR` not handled in switch
12
13template <>
14struct std::formatter<VkResult> : std::formatter<string_view>
15{
16 static constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
17
18 static constexpr auto format(const VkResult& result, auto& ctx)
19 {
20 switch (result)
21 {
22 case VK_SUCCESS:
23 return std::format_to(ctx.out(), "VK_SUCCESS");
24 case VK_NOT_READY:
25 return std::format_to(ctx.out(), "VK_NOT_READY");
26 case VK_TIMEOUT:
27 return std::format_to(ctx.out(), "VK_TIMEOUT");
28 case VK_EVENT_SET:
29 return std::format_to(ctx.out(), "VK_EVENT_SET");
30 case VK_EVENT_RESET:
31 return std::format_to(ctx.out(), "VK_EVENT_RESET");
32 case VK_INCOMPLETE:
33 return std::format_to(ctx.out(), "VK_INCOMPLETE");
34 case VK_ERROR_OUT_OF_HOST_MEMORY:
35 return std::format_to(ctx.out(), "VK_ERROR_OUT_OF_HOST_MEMORY");
36 case VK_ERROR_OUT_OF_DEVICE_MEMORY:
37 return std::format_to(ctx.out(), "VK_ERROR_OUT_OF_DEVICE_MEMORY");
38 case VK_ERROR_INITIALIZATION_FAILED:
39 return std::format_to(ctx.out(), "VK_ERROR_INITIALIZATION_FAILED");
40 case VK_ERROR_DEVICE_LOST:
41 return std::format_to(ctx.out(), "VK_ERROR_DEVICE_LOST");
42 case VK_ERROR_MEMORY_MAP_FAILED:
43 return std::format_to(ctx.out(), "VK_ERROR_MEMORY_MAP_FAILED");
44 case VK_ERROR_LAYER_NOT_PRESENT:
45 return std::format_to(ctx.out(), "VK_ERROR_LAYER_NOT_PRESENT");
46 case VK_ERROR_EXTENSION_NOT_PRESENT:
47 return std::format_to(ctx.out(), "VK_ERROR_EXTENSION_NOT_PRESENT");
48 case VK_ERROR_FEATURE_NOT_PRESENT:
49 return std::format_to(ctx.out(), "VK_ERROR_FEATURE_NOT_PRESENT");
50 case VK_ERROR_INCOMPATIBLE_DRIVER:
51 return std::format_to(ctx.out(), "VK_ERROR_INCOMPATIBLE_DRIVER");
52 case VK_ERROR_TOO_MANY_OBJECTS:
53 return std::format_to(ctx.out(), "VK_ERROR_TOO_MANY_OBJECTS");
54 case VK_ERROR_FORMAT_NOT_SUPPORTED:
55 return std::format_to(ctx.out(), "VK_ERROR_FORMAT_NOT_SUPPORTED");
56 case VK_ERROR_FRAGMENTED_POOL:
57 return std::format_to(ctx.out(), "VK_ERROR_FRAGMENTED_POOL");
58 case VK_ERROR_UNKNOWN:
59 return std::format_to(ctx.out(), "VK_ERROR_UNKNOWN");
60 case VK_ERROR_OUT_OF_POOL_MEMORY:
61 return std::format_to(ctx.out(), "VK_ERROR_OUT_OF_POOL_MEMORY");
62 case VK_ERROR_INVALID_EXTERNAL_HANDLE:
63 return std::format_to(ctx.out(), "VK_ERROR_INVALID_EXTERNAL_HANDLE");
64 case VK_ERROR_FRAGMENTATION:
65 return std::format_to(ctx.out(), "VK_ERROR_FRAGMENTATION");
66 case VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS:
67 return std::format_to(ctx.out(), "VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS");
68 case VK_ERROR_SURFACE_LOST_KHR:
69 return std::format_to(ctx.out(), "VK_ERROR_SURFACE_LOST_KHR");
70 case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR:
71 return std::format_to(ctx.out(), "VK_ERROR_NATIVE_WINDOW_IN_USE_KHR");
72 case VK_SUBOPTIMAL_KHR:
73 return std::format_to(ctx.out(), "VK_SUBOPTIMAL_KHR");
74 case VK_ERROR_OUT_OF_DATE_KHR:
75 return std::format_to(ctx.out(), "VK_ERROR_OUT_OF_DATE_KHR");
76 case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR:
77 return std::format_to(ctx.out(), "VK_ERROR_INCOMPATIBLE_DISPLAY_KHR");
78 case VK_ERROR_VALIDATION_FAILED_EXT:
79 return std::format_to(ctx.out(), "VK_ERROR_VALIDATION_FAILED_EXT");
80 case VK_ERROR_INVALID_SHADER_NV:
81 return std::format_to(ctx.out(), "VK_ERROR_INVALID_SHADER_NV");
82 case VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT:
83 return std::format_to(ctx.out(), "VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT");
84 case VK_ERROR_NOT_PERMITTED_EXT:
85 return std::format_to(ctx.out(), "VK_ERROR_NOT_PERMITTED_EXT");
86 case VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT:
87 return std::format_to(ctx.out(), "VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT");
88 case VK_PIPELINE_COMPILE_REQUIRED:
89 return std::format_to(ctx.out(), "VK_PIPELINE_COMPILE_REQUIRED");
90 case VK_ERROR_IMAGE_USAGE_NOT_SUPPORTED_KHR:
91 return std::format_to(ctx.out(), "VK_ERROR_IMAGE_USAGE_NOT_SUPPORTED_KHR");
92 case VK_ERROR_VIDEO_PICTURE_LAYOUT_NOT_SUPPORTED_KHR:
93 return std::format_to(ctx.out(), "VK_ERROR_VIDEO_PICTURE_LAYOUT_NOT_SUPPORTED_KHR");
94 case VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR:
95 return std::format_to(ctx.out(), "VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR");
96 case VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR:
97 return std::format_to(ctx.out(), "VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR");
98 case VK_ERROR_VIDEO_PROFILE_CODEC_NOT_SUPPORTED_KHR:
99 return std::format_to(ctx.out(), "VK_ERROR_VIDEO_PROFILE_CODEC_NOT_SUPPORTED_KHR");
100 case VK_ERROR_VIDEO_STD_VERSION_NOT_SUPPORTED_KHR:
101 return std::format_to(ctx.out(), "VK_ERROR_VIDEO_STD_VERSION_NOT_SUPPORTED_KHR");
102#ifdef VK_ENABLE_BETA_EXTENSIONS
103 case VK_ERROR_INVALID_VIDEO_STD_PARAMETERS_KHR:
104 return std::format_to(ctx.out(), "VK_ERROR_INVALID_VIDEO_STD_PARAMETERS_KHR");
105#endif
106 case VK_THREAD_IDLE_KHR:
107 return std::format_to(ctx.out(), "VK_THREAD_IDLE_KHR");
108 case VK_THREAD_DONE_KHR:
109 return std::format_to(ctx.out(), "VK_THREAD_DONE_KHR");
110 case VK_OPERATION_DEFERRED_KHR:
111 return std::format_to(ctx.out(), "VK_OPERATION_DEFERRED_KHR");
112 case VK_OPERATION_NOT_DEFERRED_KHR:
113 return std::format_to(ctx.out(), "VK_OPERATION_NOT_DEFERRED_KHR");
114 case VK_ERROR_COMPRESSION_EXHAUSTED_EXT:
115 return std::format_to(ctx.out(), "VK_ERROR_COMPRESSION_EXHAUSTED_EXT");
116 case VK_ERROR_INCOMPATIBLE_SHADER_BINARY_EXT:
117 return std::format_to(ctx.out(), "VK_ERROR_INCOMPATIBLE_SHADER_BINARY_EXT");
118 case VK_RESULT_MAX_ENUM:
119 break;
120 }
121
122 return std::format_to(ctx.out(), "Unknown VkResult: {}", static_cast<int>(result));
123 }
124};
125
126SPARK_WARNING_POP