diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2021-12-08 05:58:25 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2021-12-08 05:58:25 +0100 |
| commit | cc34ac795892ed95864fa7967525f3d2fdb196e2 (patch) | |
| tree | 34c4daa3ae8d7a3ebe3cb8cc1d6d7d00d779bae1 /src | |
| parent | 9c1980b702071ce6f1ed4e22281179383fdc4f4e (diff) | |
check instance extensions support before activation in VkvgDevice
Diffstat (limited to 'src')
| -rw-r--r-- | src/vkvg_device.c | 20 | ||||
| -rw-r--r-- | src/vkvg_device_internal.c | 17 | ||||
| -rw-r--r-- | src/vkvg_device_internal.h | 5 |
3 files changed, 36 insertions, 6 deletions
diff --git a/src/vkvg_device.c b/src/vkvg_device.c index 43f561a..1326b71 100644 --- a/src/vkvg_device.c +++ b/src/vkvg_device.c @@ -28,18 +28,26 @@ VkvgDevice vkvg_device_create(VkSampleCountFlags samples, bool deferredResolve) { const char* enabledExts [10]; uint32_t enabledExtsCount = 0, phyCount = 0; + _instance_extensions_check_init (); + #if defined(DEBUG) && defined (VKVG_DBG_UTILS) - enabledExts[enabledExtsCount++] = "VK_EXT_debug_utils"; + bool dbgUtilsSupported = _instance_extension_supported("VK_EXT_debug_utils"); + if (dbgUtilsSupported) + enabledExts[enabledExtsCount++] = "VK_EXT_debug_utils"; #endif - enabledExts[enabledExtsCount++] = "VK_KHR_get_physical_device_properties2"; + if (_instance_extension_supported("VK_KHR_get_physical_device_properties2")) + enabledExts[enabledExtsCount++] = "VK_KHR_get_physical_device_properties2"; + + _instance_extensions_check_release(); VkhApp app = vkh_app_create("vkvg", 0, NULL, enabledExtsCount, enabledExts); #if defined(DEBUG) && defined (VKVG_DBG_UTILS) - vkh_app_enable_debug_messenger(app - , VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT - , VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT - , NULL); + if (dbgUtilsSupported) + vkh_app_enable_debug_messenger(app + , VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT + , VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT + , NULL); #endif VkhPhyInfo* phys = vkh_app_get_phyinfos (app, &phyCount, VK_NULL_HANDLE); if (phyCount == 0) { diff --git a/src/vkvg_device_internal.c b/src/vkvg_device_internal.c index 84a64eb..602323e 100644 --- a/src/vkvg_device_internal.c +++ b/src/vkvg_device_internal.c @@ -501,6 +501,23 @@ void _check_best_image_tiling (VkvgDevice dev, VkFormat format) { LOG(VKVG_LOG_ERR, "vkvg create device failed: image format not supported: %d\n", format); } +static VkExtensionProperties* instExtProps; +static uint32_t instExtCount; +bool _instance_extension_supported (const char* instanceName) { + for (uint32_t i=0; i<instExtCount; i++) { + if (!strcmp(instExtProps[i].extensionName, instanceName)) + return true; + } + return false; +} +void _instance_extensions_check_init () { + VK_CHECK_RESULT(vkEnumerateInstanceExtensionProperties(NULL, &instExtCount, NULL)); + instExtProps =(VkExtensionProperties*)malloc(instExtCount * sizeof(VkExtensionProperties)); + VK_CHECK_RESULT(vkEnumerateInstanceExtensionProperties(NULL, &instExtCount, instExtProps)); +} +void _instance_extensions_check_release () { + free (instExtProps); +} void _dump_image_format_properties (VkvgDevice dev, VkFormat format) { /*VkImageFormatProperties imgProps; VK_CHECK_RESULT(vkGetPhysicalDeviceImageFormatProperties(dev->phy, diff --git a/src/vkvg_device_internal.h b/src/vkvg_device_internal.h index b317841..0cbc953 100644 --- a/src/vkvg_device_internal.h +++ b/src/vkvg_device_internal.h @@ -117,4 +117,9 @@ void _flush_all_contexes (VkvgDevice dev); void _wait_idle (VkvgDevice dev); void _wait_and_reset_device_fence (VkvgDevice dev); void _submit_cmd (VkvgDevice dev, VkCommandBuffer* cmd, VkFence fence); + +bool _instance_extension_supported (const char* instanceName); +void _instance_extensions_check_init (); +void _instance_extensions_check_release (); + #endif |