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) {
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,
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