From 403f694bf90455f13b115ea7cf58495f58bde6cc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Tue, 15 Jun 2021 08:33:51 +0200 Subject: [PATCH] phyinfo extension check --- include/vkh.h | 2 ++ src/vkh_phyinfo.c | 19 ++++++++++++++++++- src/vkh_phyinfo.h | 3 +++ 3 files changed, 23 insertions(+), 1 deletion(-) 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 } -- 2.47.3