diff --git a/base/vulkandevice.hpp b/base/vulkandevice.hpp index 3f2e5105..18549d98 100644 --- a/base/vulkandevice.hpp +++ b/base/vulkandevice.hpp @@ -32,6 +32,8 @@ namespace vk VkPhysicalDeviceMemoryProperties memoryProperties; /** @brief Queue family properties of the physical device */ std::vector queueFamilyProperties; + /** @brief List of extensions supported by the device */ + std::vector supportedExtensions; /** @brief Default command pool for the graphics queue family index */ VkCommandPool commandPool = VK_NULL_HANDLE; @@ -70,6 +72,21 @@ namespace vk assert(queueFamilyCount > 0); queueFamilyProperties.resize(queueFamilyCount); vkGetPhysicalDeviceQueueFamilyProperties(physicalDevice, &queueFamilyCount, queueFamilyProperties.data()); + + // Get list of supported extensions + uint32_t extCount = 0; + vkEnumerateDeviceExtensionProperties(physicalDevice, nullptr, &extCount, nullptr); + if (extCount > 0) + { + std::vector extensions(extCount); + if (vkEnumerateDeviceExtensionProperties(physicalDevice, nullptr, &extCount, &extensions.front()) == VK_SUCCESS) + { + for (auto ext : extensions) + { + supportedExtensions.push_back(ext.extensionName); + } + } + } } /** @@ -521,5 +538,17 @@ namespace vk } } + /** + * Check if an extension is supported by the (physical device) + * + * @param extension Name of the extension to check + * + * @return True if the extension is supported (present in the list read at device creation time) + */ + bool extensionSupported(std::string extension) + { + return (std::find(supportedExtensions.begin(), supportedExtensions.end(), extension) != supportedExtensions.end()); + } + }; }