Added function for checking extension support at device level

This commit is contained in:
saschawillems 2016-12-07 21:54:04 +01:00
parent 100d8e40e9
commit f421d17814

View file

@ -32,6 +32,8 @@ namespace vk
VkPhysicalDeviceMemoryProperties memoryProperties;
/** @brief Queue family properties of the physical device */
std::vector<VkQueueFamilyProperties> queueFamilyProperties;
/** @brief List of extensions supported by the device */
std::vector<std::string> 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<VkExtensionProperties> 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());
}
};
}