]> O.S.I.I.S - jp/vkhelpers.git/commitdiff
phyinfo extension check
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 15 Jun 2021 06:33:51 +0000 (08:33 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Tue, 15 Jun 2021 06:33:51 +0000 (08:33 +0200)
include/vkh.h
src/vkh_phyinfo.c
src/vkh_phyinfo.h

index 2d9af36eabdc499f45e912c2522bfe817991311f..d6bc5a7eee6bd2afcf2db39037f465ddbb08f735 100644 (file)
@@ -38,6 +38,7 @@ typedef enum VmaMemoryUsage VmaMemoryUsage;
 #include <assert.h>
 #include <stdbool.h>
 #include <stdint.h>
+#include <string.h>
 
 #define _USE_MATH_DEFINES   //to have M_PI* defined with MSVC
 #include <math.h>
@@ -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 *
  *************/
index 9140e3bea26181ab550ba1279a9e5e20b8149b50..d3dceb55fef0db9167e55f812166d99614e75517 100644 (file)
@@ -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; i<phy->extensionCount; i++) {
+               if (strcmp(name, phy->pExtensionProperties[i].extensionName)==0) {
+                       if (properties != NULL)
+                               properties = &phy->pExtensionProperties[i];
+                       return true;
+               }
+       }
+       properties = NULL;
+       return false;
+}
index c3e10769924d43c2b7378bc31f3bd89bedba3c77..3a7261f74013f3c2e37834f143264c78f9bc6b28 100644 (file)
@@ -41,6 +41,9 @@ typedef struct _vkh_phy_t{
 
        uint32_t                            qCreateInfosCount;
        VkDeviceQueueCreateInfo*            qCreateInfos;
+
+       VkExtensionProperties*                          pExtensionProperties;
+       uint32_t                                                        extensionCount;
 }vkh_phy_t;
 #ifdef __cplusplus
 }