From: Jean-Philippe Bruyère Date: Tue, 15 Jun 2021 06:33:51 +0000 (+0200) Subject: phyinfo extension check X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=403f694bf90455f13b115ea7cf58495f58bde6cc;p=jp%2Fvkhelpers.git phyinfo extension check --- diff --git a/include/vkh.h b/include/vkh.h index 2d9af36..d6bc5a7 100644 --- a/include/vkh.h +++ b/include/vkh.h @@ -38,6 +38,7 @@ typedef enum VmaMemoryUsage VmaMemoryUsage; #include #include #include +#include #define _USE_MATH_DEFINES //to have M_PI* defined with MSVC #include @@ -97,6 +98,7 @@ bool phy_info_create_graphic_queues (VkhPhyInfo phy, uint32_t queueCount, cons bool vkh_phyinfo_create_transfer_queues (VkhPhyInfo phy, uint32_t queueCount, const float* queue_priorities, VkDeviceQueueCreateInfo* const qInfo); bool vkh_phyinfo_create_compute_queues (VkhPhyInfo phy, uint32_t queueCount, const float* queue_priorities, VkDeviceQueueCreateInfo* const qInfo); +bool vkh_phyinfo_try_get_extension_properties (VkhPhyInfo phy, const char* name, const VkExtensionProperties* properties); /************* * VkhDevice * *************/ diff --git a/src/vkh_phyinfo.c b/src/vkh_phyinfo.c index 9140e3b..d3dceb5 100644 --- a/src/vkh_phyinfo.c +++ b/src/vkh_phyinfo.c @@ -89,7 +89,8 @@ VkhPhyInfo vkh_phyinfo_create (VkPhysicalDevice phy, VkSurfaceKHR surface) { } void vkh_phyinfo_destroy (VkhPhyInfo phy) { - + if (phy->pExtensionProperties != NULL) + free(phy->pExtensionProperties); free(phy->queues); free(phy); } @@ -184,3 +185,19 @@ bool vkh_phy_info_create_graphic_queues (VkhPhyInfo phy, uint32_t queueCount, co } return false; } +bool vkh_phyinfo_try_get_extension_properties (VkhPhyInfo phy, const char* name, const VkExtensionProperties* properties) { + if (phy->pExtensionProperties == NULL) { + VK_CHECK_RESULT(vkEnumerateDeviceExtensionProperties(phy->phy, NULL, &phy->extensionCount, NULL)); + phy->pExtensionProperties = (VkExtensionProperties*)malloc(phy->extensionCount * sizeof(VkExtensionProperties)); + VK_CHECK_RESULT(vkEnumerateDeviceExtensionProperties(phy->phy, NULL, &phy->extensionCount, phy->pExtensionProperties)); + } + for (uint32_t i=0; iextensionCount; i++) { + if (strcmp(name, phy->pExtensionProperties[i].extensionName)==0) { + if (properties != NULL) + properties = &phy->pExtensionProperties[i]; + return true; + } + } + properties = NULL; + return false; +} diff --git a/src/vkh_phyinfo.h b/src/vkh_phyinfo.h index c3e1076..3a7261f 100644 --- a/src/vkh_phyinfo.h +++ b/src/vkh_phyinfo.h @@ -41,6 +41,9 @@ typedef struct _vkh_phy_t{ uint32_t qCreateInfosCount; VkDeviceQueueCreateInfo* qCreateInfos; + + VkExtensionProperties* pExtensionProperties; + uint32_t extensionCount; }vkh_phy_t; #ifdef __cplusplus }