diff options
| author | hunter@kvog.sh <hunter@kvog.sh> | 2026-03-15 17:00:37 -0500 |
|---|---|---|
| committer | hunter@kvog.sh <hunter@kvog.sh> | 2026-03-15 17:00:37 -0500 |
| commit | f409e568ef60940d5dfb2c3479d43dd19882f780 (patch) | |
| tree | 0a339675115c57727ba72551edd4c53cd5a4e6d3 /common | |
| parent | 62b66395da15266c6ec41d7384f237d0e16fbc90 (diff) | |
Diffstat (limited to 'common')
| -rw-r--r-- | common/c_cpp/CMakeLists.txt | 5 | ||||
| -rw-r--r-- | common/c_cpp/vkutil.h | 44 |
2 files changed, 49 insertions, 0 deletions
diff --git a/common/c_cpp/CMakeLists.txt b/common/c_cpp/CMakeLists.txt index d629db3..a6f09eb 100644 --- a/common/c_cpp/CMakeLists.txt +++ b/common/c_cpp/CMakeLists.txt @@ -37,6 +37,11 @@ if(NOT MINGW) endif() # ----------------------------------------------------------------------------- +# Include helper files +# ----------------------------------------------------------------------------- +target_include_directories(common INTERFACE "${CMAKE_CURRENT_LIST_DIR}") + +# ----------------------------------------------------------------------------- # Dependency: Dear ImGui # ----------------------------------------------------------------------------- if(DEMO_NEEDS_DEAR_IMGUI) 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_ |