From cc34ac795892ed95864fa7967525f3d2fdb196e2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Wed, 8 Dec 2021 05:58:25 +0100 Subject: [PATCH] check instance extensions support before activation in VkvgDevice --- src/vkvg_device.c | 20 ++++++++++++++------ src/vkvg_device_internal.c | 17 +++++++++++++++++ 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; iphy, 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 -- 2.47.3