From 912f38455cb9468fce45dd171f4e673da8ba3f9e Mon Sep 17 00:00:00 2001 From: saschawillems Date: Sat, 4 Feb 2017 13:35:40 +0100 Subject: [PATCH] Device type string conversion function --- base/vulkantools.cpp | 14 ++++++++++++++ base/vulkantools.h | 5 ++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/base/vulkantools.cpp b/base/vulkantools.cpp index f5b9a41b..e36ab365 100644 --- a/base/vulkantools.cpp +++ b/base/vulkantools.cpp @@ -44,6 +44,20 @@ namespace vkTools } } + std::string physicalDeviceTypeString(VkPhysicalDeviceType type) + { + switch (type) + { +#define STR(r) case VK_PHYSICAL_DEVICE_TYPE_ ##r: return #r + STR(OTHER); + STR(INTEGRATED_GPU); + STR(DISCRETE_GPU); + STR(VIRTUAL_GPU); +#undef STR + default: return "UNKNOWN_DEVICE_TYPE"; + } + } + VkBool32 getSupportedDepthFormat(VkPhysicalDevice physicalDevice, VkFormat *depthFormat) { // Since all depth formats may be optional, we need to find a suitable depth format to use diff --git a/base/vulkantools.h b/base/vulkantools.h index 348b5295..c319b0a1 100644 --- a/base/vulkantools.h +++ b/base/vulkantools.h @@ -60,9 +60,12 @@ namespace vkTools { - // Return string representation of a vulkan error string + /** @brief Returns an error code as a string */ std::string errorString(VkResult errorCode); + /** @brief Returns the device type as a string */ + std::string physicalDeviceTypeString(VkPhysicalDeviceType type); + // Selected a suitable supported depth format starting with 32 bit down to 16 bit // Returns false if none of the depth formats in the list is supported by the device VkBool32 getSupportedDepthFormat(VkPhysicalDevice physicalDevice, VkFormat *depthFormat);