summaryrefslogtreecommitdiff
path: root/common/c_cpp/vkutil.h
diff options
context:
space:
mode:
authorhunter@kvog.sh <hunter@kvog.sh>2026-03-15 17:00:37 -0500
committerhunter@kvog.sh <hunter@kvog.sh>2026-03-15 17:00:37 -0500
commitf409e568ef60940d5dfb2c3479d43dd19882f780 (patch)
tree0a339675115c57727ba72551edd4c53cd5a4e6d3 /common/c_cpp/vkutil.h
parent62b66395da15266c6ec41d7384f237d0e16fbc90 (diff)
Diffstat (limited to 'common/c_cpp/vkutil.h')
-rw-r--r--common/c_cpp/vkutil.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/common/c_cpp/vkutil.h b/common/c_cpp/vkutil.h
index 89c7940..2530831 100644
--- a/common/c_cpp/vkutil.h
+++ b/common/c_cpp/vkutil.h
@@ -1,5 +1,49 @@
#ifndef _DEMOS_VKUTIL_H_
#define _DEMOS_VKUTIL_H_
+static inline const char* VkResultToString(VkResult result)
+{
+ // ref: https://docs.vulkan.org/refpages/latest/refpages/source/VkResult.html
+ switch (result) {
+#define X(_E) case _E: return #_E;
+ X(VK_SUCCESS);
+ X(VK_NOT_READY);
+ X(VK_TIMEOUT);
+ X(VK_EVENT_SET);
+ X(VK_EVENT_RESET);
+ X(VK_INCOMPLETE);
+ X(VK_ERROR_OUT_OF_HOST_MEMORY);
+ X(VK_ERROR_OUT_OF_DEVICE_MEMORY);
+ X(VK_ERROR_INITIALIZATION_FAILED);
+ X(VK_ERROR_DEVICE_LOST);
+ X(VK_ERROR_MEMORY_MAP_FAILED);
+ X(VK_ERROR_LAYER_NOT_PRESENT);
+ X(VK_ERROR_EXTENSION_NOT_PRESENT);
+ X(VK_ERROR_FEATURE_NOT_PRESENT);
+ X(VK_ERROR_INCOMPATIBLE_DRIVER);
+ X(VK_ERROR_TOO_MANY_OBJECTS);
+ X(VK_ERROR_FORMAT_NOT_SUPPORTED);
+ X(VK_ERROR_FRAGMENTED_POOL);
+ X(VK_ERROR_UNKNOWN);
+ X(VK_ERROR_VALIDATION_FAILED);
+ X(VK_ERROR_OUT_OF_POOL_MEMORY);
+ X(VK_ERROR_INVALID_EXTERNAL_HANDLE);
+ X(VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS);
+ X(VK_ERROR_FRAGMENTATION);
+ X(VK_PIPELINE_COMPILE_REQUIRED);
+ X(VK_ERROR_NOT_PERMITTED);
+ X(VK_ERROR_SURFACE_LOST_KHR);
+ X(VK_ERROR_NATIVE_WINDOW_IN_USE_KHR);
+ X(VK_SUBOPTIMAL_KHR);
+ X(VK_ERROR_OUT_OF_DATE_KHR);
+#undef X
+ default: {
+ static char buf[64]; // @@ should be thread-local
+ snprintf(buf, sizeof(buf), "VkResult(%d)", result);
+ return buf;
+ } break;
+ }
+}
+
#endif // _DEMOS_VKUTIL_H_