27 int idx = SkTSearch<VulkanExtensions::Info, SkString, VulkanExtensions::Info::Less>(
34inline bool extension_compare(
const VulkanExtensions::Info&
a,
const VulkanExtensions::Info&
b) {
35 return strcmp(
a.fName.c_str(),
b.fName.c_str()) < 0;
41 VkPhysicalDevice physDev,
42 uint32_t instanceExtensionCount,
43 const char*
const* instanceExtensions,
44 uint32_t deviceExtensionCount,
45 const char*
const* deviceExtensions) {
46 for (uint32_t
i = 0;
i < instanceExtensionCount; ++
i) {
47 const char* extension = instanceExtensions[
i];
49 if (
find_info(fExtensions, extension) < 0) {
50 fExtensions.push_back() =
Info(extension);
51 SkTQSort(fExtensions.begin(), fExtensions.end(), extension_compare);
54 for (uint32_t
i = 0;
i < deviceExtensionCount; ++
i) {
55 const char* extension = deviceExtensions[
i];
57 if (
find_info(fExtensions, extension) < 0) {
58 fExtensions.push_back() =
Info(extension);
59 SkTQSort(fExtensions.begin(), fExtensions.end(), extension_compare);
62 this->getSpecVersions(std::move(getProc),
instance, physDev);
65#define GET_PROC(F, inst) \
66 PFN_vk##F grVk##F = (PFN_vk ## F) getProc("vk" #F, inst, VK_NULL_HANDLE)
68void VulkanExtensions::getSpecVersions(
const VulkanGetProc& getProc,
70 VkPhysicalDevice physDevice) {
80 SkASSERT(grVkEnumerateInstanceExtensionProperties);
84 uint32_t extensionCount = 0;
85 res = grVkEnumerateInstanceExtensionProperties(
nullptr, &extensionCount,
nullptr);
90 res = grVkEnumerateInstanceExtensionProperties(
nullptr, &extensionCount,
extensions);
95 for (uint32_t
i = 0;
i < extensionCount; ++
i) {
98 fExtensions[idx].fSpecVersion =
extensions[
i].specVersion;
107 SkASSERT(grVkEnumerateDeviceExtensionProperties);
111 res = grVkEnumerateDeviceExtensionProperties(physDevice,
nullptr, &extensionCount,
nullptr);
116 res = grVkEnumerateDeviceExtensionProperties(physDevice,
nullptr, &extensionCount,
extensions);
121 for (uint32_t
i = 0;
i < extensionCount; ++
i) {
124 fExtensions[idx].fSpecVersion =
extensions[
i].specVersion;
132 return idx >= 0 && fExtensions[idx].fSpecVersion >= minVersion;
void SkTQSort(T *begin, T *end, const C &lessThan)
#define GET_PROC(F, inst)
void init(VulkanGetProc, VkInstance, VkPhysicalDevice, uint32_t instanceExtensionCount, const char *const *instanceExtensions, uint32_t deviceExtensionCount, const char *const *deviceExtensions)
bool hasExtension(const char[], uint32_t minVersion) const
static int find_info(const TArray< VulkanExtensions::Info > &infos, const char ext[])
std::function< PFN_vkVoidFunction(const char *, VkInstance, VkDevice)> VulkanGetProc