The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

a/vk: Improve error printing in vk_create_device

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2619>

authored by

Jakob Bornecrantz and committed by
Marge Bot
e2092b59 1b1a1f26

+36 -33
+33 -33
src/xrt/auxiliary/vk/vk_bundle_init.c
··· 975 975 return false; 976 976 } 977 977 978 - static bool 978 + static VkResult 979 979 build_device_extensions(struct vk_bundle *vk, 980 980 VkPhysicalDevice physical_device, 981 981 struct u_string_list *required_device_ext_list, ··· 992 992 NULL, // layer_name 993 993 &prop_count, // out_prop_count 994 994 &props); // out_props 995 - if (ret != VK_SUCCESS) { 996 - VK_ERROR(vk, "vk_enumerate_physical_device_extension_properties: %s", vk_result_string(ret)); 997 - return false; 998 - } 995 + VK_CHK_AND_RET(ret, "vk_enumerate_physical_device_extension_properties"); 999 996 1000 997 uint32_t required_device_ext_count = u_string_list_get_size(required_device_ext_list); 1001 998 const char *const *required_device_exts = u_string_list_get_data(required_device_ext_list); ··· 1004 1001 for (uint32_t i = 0; i < required_device_ext_count; i++) { 1005 1002 const char *ext = required_device_exts[i]; 1006 1003 if (!check_extension(vk, props, prop_count, ext)) { 1007 - VK_DEBUG(vk, "VkPhysicalDevice does not support required extension %s", ext); 1004 + VK_ERROR(vk, "VkPhysicalDevice does not support required extension %s", ext); 1008 1005 free(props); 1009 - return false; 1006 + return VK_ERROR_EXTENSION_NOT_PRESENT; 1010 1007 } 1011 1008 VK_DEBUG(vk, "Using required device ext %s", ext); 1012 1009 } ··· 1042 1039 1043 1040 free(props); 1044 1041 1045 - 1046 - return true; 1042 + return VK_SUCCESS; 1047 1043 } 1048 1044 1049 1045 /*! ··· 1325 1321 struct u_string_list *optional_device_ext_list, 1326 1322 const struct vk_device_features *optional_device_features) 1327 1323 { 1324 + struct u_string_list *device_ext_list = NULL; 1328 1325 VkResult ret; 1329 1326 1330 1327 ret = select_physical_device(vk, forced_index); 1331 - if (ret != VK_SUCCESS) { 1332 - return ret; 1333 - } 1328 + VK_CHK_WITH_GOTO(ret, "select_physical_device", err_destroy); 1334 1329 1335 - struct u_string_list *device_ext_list = NULL; 1336 - if (!build_device_extensions(vk, vk->physical_device, required_device_ext_list, optional_device_ext_list, 1337 - &device_ext_list)) { 1338 - return VK_ERROR_EXTENSION_NOT_PRESENT; 1339 - } 1330 + ret = build_device_extensions( // 1331 + vk, // 1332 + vk->physical_device, // 1333 + required_device_ext_list, // 1334 + optional_device_ext_list, // 1335 + &device_ext_list); // 1336 + VK_CHK_WITH_GOTO(ret, "build_device_extensions", err_destroy); 1340 1337 1341 1338 1342 1339 /* ··· 1359 1356 if (!vk->has_EXT_global_priority && // 1360 1357 !vk->has_KHR_global_priority && // 1361 1358 global_priority != VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT) { 1362 - return VK_ERROR_NOT_PERMITTED_EXT; 1359 + ret = VK_ERROR_NOT_PERMITTED_EXT; 1360 + goto err_destroy; 1363 1361 } 1364 1362 1365 1363 vk_reset_queues(vk); ··· 1367 1365 struct vk_queue_family main_queue_family = {0}; 1368 1366 if (only_compute) { 1369 1367 ret = find_queue_family(vk, VK_QUEUE_COMPUTE_BIT, &main_queue_family); 1368 + VK_CHK_WITH_GOTO(ret, "find_queue_family", err_destroy); 1370 1369 } else { 1371 1370 ret = find_graphics_queue_family(vk, &main_queue_family); 1372 - } 1373 - 1374 - if (ret != VK_SUCCESS) { 1375 - return ret; 1371 + VK_CHK_WITH_GOTO(ret, "find_graphics_queue_family", err_destroy); 1376 1372 } 1377 1373 1378 1374 assert(main_queue_family.queue_family.queueCount > 0); ··· 1576 1572 1577 1573 ret = vk->vkCreateDevice(vk->physical_device, &device_create_info, NULL, &vk->device); 1578 1574 1575 + // Destroy the list now. 1579 1576 u_string_list_destroy(&device_ext_list); 1580 1577 1581 - if (ret != VK_SUCCESS) { 1582 - VK_DEBUG(vk, "vkCreateDevice: %s (%d)", vk_result_string(ret), ret); 1583 - if (ret == VK_ERROR_NOT_PERMITTED_EXT) { 1584 - VK_DEBUG(vk, "Is CAP_SYS_NICE set? Try: sudo setcap cap_sys_nice+ep monado-service"); 1585 - } 1586 - return ret; 1578 + if (ret == VK_ERROR_NOT_PERMITTED_EXT) { 1579 + // Don't spam the not permitted returns as we try all of the different priorities. 1580 + VK_DEBUG(vk, "Is CAP_SYS_NICE set? Try: sudo setcap cap_sys_nice+ep monado-service"); 1581 + goto err_destroy; 1587 1582 } 1583 + VK_CHK_WITH_GOTO(ret, "vkCreateDevice", err_destroy); 1588 1584 1589 1585 // Fill in the device features we are interested in. 1590 1586 fill_in_device_features(vk, main_queue.family_index); ··· 1594 1590 1595 1591 // Now setup all of the device specific functions. 1596 1592 ret = vk_get_device_functions(vk); 1597 - if (ret != VK_SUCCESS) { 1598 - goto err_destroy; 1599 - } 1593 + VK_CHK_WITH_GOTO(ret, "vk_get_device_functions", err_destroy); 1600 1594 1601 1595 vk->main_queue = vk_insert_get_queue(vk, &main_queue); 1602 1596 assert(vk->main_queue != NULL); 1597 + 1603 1598 #if defined(VK_KHR_video_encode_queue) 1604 1599 vk->encode_queue = vk_insert_get_queue(vk, &encode_queue); 1605 1600 #endif ··· 1611 1606 return ret; 1612 1607 1613 1608 err_destroy: 1614 - vk->vkDestroyDevice(vk->device, NULL); 1615 - vk->device = NULL; 1609 + if (vk->device != VK_NULL_HANDLE) { 1610 + vk->vkDestroyDevice(vk->device, NULL); 1611 + vk->device = VK_NULL_HANDLE; 1612 + } 1613 + 1614 + // Safe to call even if null. 1615 + u_string_list_destroy(&device_ext_list); 1616 1616 1617 1617 return ret; 1618 1618 }
+3
src/xrt/auxiliary/vk/vk_helpers.h
··· 1078 1078 /*! 1079 1079 * Creates a VkDevice and initialises the VkQueue. 1080 1080 * 1081 + * The @p vk_bundle must have been zero initialized, have the instance functions 1082 + * loaded and a valid instance. 1083 + * 1081 1084 * @ingroup aux_vk 1082 1085 */ 1083 1086 XRT_CHECK_RESULT VkResult