Skip to content

Commit

Permalink
Add three extension capability support check (#4626)
Browse files Browse the repository at this point in the history
* Add some extension capability for vma
  • Loading branch information
whyb authored Apr 15, 2023
1 parent 1936142 commit 772b13a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ class GpuInfoPrivate
int support_VK_KHR_8bit_storage;
int support_VK_KHR_16bit_storage;
int support_VK_KHR_bind_memory2;
int support_VK_KHR_buffer_device_address;
int support_VK_KHR_create_renderpass2;
int support_VK_KHR_dedicated_allocation;
int support_VK_KHR_descriptor_update_template;
Expand All @@ -244,7 +245,9 @@ class GpuInfoPrivate
int support_VK_KHR_swapchain;
int support_VK_EXT_descriptor_indexing;
int support_VK_EXT_memory_budget;
int support_VK_EXT_memory_priority;
int support_VK_EXT_queue_family_foreign;
int support_VK_AMD_device_coherent_memory;
#if __ANDROID_API__ >= 26
int support_VK_ANDROID_external_memory_android_hardware_buffer;
#endif // __ANDROID_API__ >= 26
Expand Down Expand Up @@ -536,6 +539,11 @@ int GpuInfo::support_VK_KHR_bind_memory2() const
return d->support_VK_KHR_bind_memory2;
}

int GpuInfo::support_VK_KHR_buffer_device_address() const
{
return d->support_VK_KHR_buffer_device_address;
}

int GpuInfo::support_VK_KHR_create_renderpass2() const
{
return d->support_VK_KHR_create_renderpass2;
Expand Down Expand Up @@ -626,11 +634,21 @@ int GpuInfo::support_VK_EXT_memory_budget() const
return d->support_VK_EXT_memory_budget;
}

int GpuInfo::support_VK_EXT_memory_priority() const
{
return d->support_VK_EXT_memory_priority;
}

int GpuInfo::support_VK_EXT_queue_family_foreign() const
{
return d->support_VK_EXT_queue_family_foreign;
}

int GpuInfo::support_VK_AMD_device_coherent_memory() const
{
return d->support_VK_AMD_device_coherent_memory;
}

#if __ANDROID_API__ >= 26
int GpuInfo::support_VK_ANDROID_external_memory_android_hardware_buffer() const
{
Expand Down Expand Up @@ -1320,6 +1338,7 @@ int create_gpu_instance()
gpu_info.support_VK_KHR_8bit_storage = 0;
gpu_info.support_VK_KHR_16bit_storage = 0;
gpu_info.support_VK_KHR_bind_memory2 = 0;
gpu_info.support_VK_KHR_buffer_device_address = 0;
gpu_info.support_VK_KHR_create_renderpass2 = 0;
gpu_info.support_VK_KHR_dedicated_allocation = 0;
gpu_info.support_VK_KHR_descriptor_update_template = 0;
Expand All @@ -1338,7 +1357,9 @@ int create_gpu_instance()
gpu_info.support_VK_KHR_swapchain = 0;
gpu_info.support_VK_EXT_descriptor_indexing = 0;
gpu_info.support_VK_EXT_memory_budget = 0;
gpu_info.support_VK_EXT_memory_priority = 0;
gpu_info.support_VK_EXT_queue_family_foreign = 0;
gpu_info.support_VK_AMD_device_coherent_memory = 0;
#if __ANDROID_API__ >= 26
gpu_info.support_VK_ANDROID_external_memory_android_hardware_buffer = 0;
#endif // __ANDROID_API__ >= 26
Expand All @@ -1354,6 +1375,8 @@ int create_gpu_instance()
gpu_info.support_VK_KHR_16bit_storage = exp.specVersion;
else if (strcmp(exp.extensionName, "VK_KHR_bind_memory2") == 0)
gpu_info.support_VK_KHR_bind_memory2 = exp.specVersion;
else if (strcmp(exp.extensionName, "VK_KHR_buffer_device_address") == 0)
gpu_info.support_VK_KHR_buffer_device_address = exp.specVersion;
else if (strcmp(exp.extensionName, "VK_KHR_create_renderpass2") == 0)
gpu_info.support_VK_KHR_create_renderpass2 = exp.specVersion;
else if (strcmp(exp.extensionName, "VK_KHR_dedicated_allocation") == 0)
Expand Down Expand Up @@ -1390,8 +1413,12 @@ int create_gpu_instance()
gpu_info.support_VK_EXT_descriptor_indexing = exp.specVersion;
else if (strcmp(exp.extensionName, "VK_EXT_memory_budget") == 0)
gpu_info.support_VK_EXT_memory_budget = exp.specVersion;
else if (strcmp(exp.extensionName, "VK_EXT_memory_priority") == 0)
gpu_info.support_VK_EXT_memory_priority = exp.specVersion;
else if (strcmp(exp.extensionName, "VK_EXT_queue_family_foreign") == 0)
gpu_info.support_VK_EXT_queue_family_foreign = exp.specVersion;
else if (strcmp(exp.extensionName, "VK_AMD_device_coherent_memory") == 0)
gpu_info.support_VK_AMD_device_coherent_memory = exp.specVersion;
#if __ANDROID_API__ >= 26
else if (strcmp(exp.extensionName, "VK_ANDROID_external_memory_android_hardware_buffer") == 0)
gpu_info.support_VK_ANDROID_external_memory_android_hardware_buffer = exp.specVersion;
Expand Down Expand Up @@ -1931,6 +1958,8 @@ VulkanDevice::VulkanDevice(int device_index)
enabledExtensions.push_back("VK_KHR_16bit_storage");
if (info.support_VK_KHR_bind_memory2())
enabledExtensions.push_back("VK_KHR_bind_memory2");
if (info.support_VK_KHR_buffer_device_address())
enabledExtensions.push_back("VK_KHR_buffer_device_address");
if (info.support_VK_KHR_create_renderpass2())
enabledExtensions.push_back("VK_KHR_create_renderpass2");
if (info.support_VK_KHR_dedicated_allocation())
Expand Down Expand Up @@ -1967,8 +1996,12 @@ VulkanDevice::VulkanDevice(int device_index)
enabledExtensions.push_back("VK_EXT_descriptor_indexing");
if (info.support_VK_EXT_memory_budget())
enabledExtensions.push_back("VK_EXT_memory_budget");
if (info.support_VK_EXT_memory_priority())
enabledExtensions.push_back("VK_EXT_memory_priority");
if (info.support_VK_EXT_queue_family_foreign())
enabledExtensions.push_back("VK_EXT_queue_family_foreign");
if (info.support_VK_AMD_device_coherent_memory())
enabledExtensions.push_back("VK_AMD_device_coherent_memory");
#if __ANDROID_API__ >= 26
if (info.support_VK_ANDROID_external_memory_android_hardware_buffer())
enabledExtensions.push_back("VK_ANDROID_external_memory_android_hardware_buffer");
Expand Down
3 changes: 3 additions & 0 deletions src/gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class NCNN_EXPORT GpuInfo
int support_VK_KHR_8bit_storage() const;
int support_VK_KHR_16bit_storage() const;
int support_VK_KHR_bind_memory2() const;
int support_VK_KHR_buffer_device_address() const;
int support_VK_KHR_create_renderpass2() const;
int support_VK_KHR_dedicated_allocation() const;
int support_VK_KHR_descriptor_update_template() const;
Expand All @@ -185,7 +186,9 @@ class NCNN_EXPORT GpuInfo
int support_VK_KHR_swapchain() const;
int support_VK_EXT_descriptor_indexing() const;
int support_VK_EXT_memory_budget() const;
int support_VK_EXT_memory_priority() const;
int support_VK_EXT_queue_family_foreign() const;
int support_VK_AMD_device_coherent_memory() const;
#if __ANDROID_API__ >= 26
int support_VK_ANDROID_external_memory_android_hardware_buffer() const;
#endif // __ANDROID_API__ >= 26
Expand Down

0 comments on commit 772b13a

Please sign in to comment.