The open source OpenXR runtime
0
fork

Configure Feed

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

aux/vk: Add support for VK_EXT_global_priority

authored by

Jakob Bornecrantz and committed by
Jakob Bornecrantz
1b51cbd1 796f3cf7

+55 -7
+10
src/xrt/auxiliary/vk/vk_helpers.c
··· 1051 1051 if (strcmp(ext, VK_GOOGLE_DISPLAY_TIMING_EXTENSION_NAME) == 0) { 1052 1052 vk->has_GOOGLE_display_timing = true; 1053 1053 } 1054 + if (strcmp(ext, VK_EXT_GLOBAL_PRIORITY_EXTENSION_NAME) == 0) { 1055 + vk->has_EXT_global_priority = true; 1056 + } 1054 1057 1055 1058 return true; 1056 1059 } ··· 1131 1134 VkResult 1132 1135 vk_create_device(struct vk_bundle *vk, 1133 1136 int forced_index, 1137 + VkQueueGlobalPriorityEXT global_priorty, 1134 1138 const char *const *required_device_extensions, 1135 1139 size_t num_required_device_extensions, 1136 1140 const char *const *optional_device_extensions, ··· 1165 1169 return ret; 1166 1170 } 1167 1171 1172 + VkDeviceQueueGlobalPriorityCreateInfoEXT priority_info = { 1173 + .sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT, 1174 + .globalPriority = global_priorty, 1175 + }; 1176 + 1168 1177 VkDeviceCreateInfo device_create_info = { 1169 1178 .sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, 1179 + .pNext = vk->has_EXT_global_priority ? &priority_info : NULL, 1170 1180 .queueCreateInfoCount = 1, 1171 1181 .pQueueCreateInfos = &queue_create_info, 1172 1182 .enabledExtensionCount = num_device_extensions,
+2
src/xrt/auxiliary/vk/vk_helpers.h
··· 49 49 struct os_mutex queue_mutex; 50 50 51 51 bool has_GOOGLE_display_timing; 52 + bool has_EXT_global_priority; 52 53 53 54 VkDebugReportCallbackEXT debug_report_cb; 54 55 ··· 363 364 VkResult 364 365 vk_create_device(struct vk_bundle *vk, 365 366 int forced_index, 367 + VkQueueGlobalPriorityEXT global_priorty, 366 368 const char *const *required_device_extensions, 367 369 size_t num_required_device_extensions, 368 370 const char *const *optional_device_extensions,
+43 -7
src/xrt/compositor/main/comp_compositor.c
··· 745 745 746 746 static const char *optional_device_extensions[] = { 747 747 VK_GOOGLE_DISPLAY_TIMING_EXTENSION_NAME, 748 + VK_EXT_GLOBAL_PRIORITY_EXTENSION_NAME, 748 749 }; 749 750 750 751 ··· 882 883 return false; 883 884 } 884 885 885 - ret = vk_create_device(&c->vk, c->settings.selected_gpu_index, required_device_extensions, 886 - ARRAY_SIZE(required_device_extensions), optional_device_extensions, 887 - ARRAY_SIZE(optional_device_extensions)); 886 + const char *prio_strs[3] = { 887 + "realtime", 888 + "high", 889 + "normal", 890 + }; 891 + 892 + VkQueueGlobalPriorityEXT prios[3] = { 893 + VK_QUEUE_GLOBAL_PRIORITY_REALTIME_EXT, // This is the one we really want. 894 + VK_QUEUE_GLOBAL_PRIORITY_HIGH_EXT, // Probably not as good but something. 895 + VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT, // Default fallback. 896 + }; 888 897 889 - if (ret != VK_SUCCESS) { 898 + // No other way then to try to see if realtime is available. 899 + for (size_t i = 0; i < ARRAY_SIZE(prios); i++) { 900 + ret = vk_create_device( // 901 + &c->vk, // 902 + c->settings.selected_gpu_index, // 903 + prios[i], // global_priority 904 + required_device_extensions, // 905 + ARRAY_SIZE(required_device_extensions), // 906 + optional_device_extensions, // 907 + ARRAY_SIZE(optional_device_extensions)); // 908 + 909 + // All ok! 910 + if (ret == VK_SUCCESS) { 911 + COMP_INFO(c, "Created device/queue with %s priority.", prio_strs[i]); 912 + break; 913 + } 914 + 915 + // Try a lower priority. 916 + if (ret == VK_ERROR_NOT_PERMITTED_EXT) { 917 + continue; 918 + } 919 + 920 + // Some other error! 890 921 return false; 891 922 } 892 923 ··· 1068 1099 } 1069 1100 1070 1101 // follow same device selection logic as subsequent calls 1071 - ret = vk_create_device(&temp_vk, c->settings.selected_gpu_index, required_device_extensions, 1072 - ARRAY_SIZE(required_device_extensions), optional_device_extensions, 1073 - ARRAY_SIZE(optional_device_extensions)); 1102 + ret = vk_create_device( // 1103 + &temp_vk, // 1104 + c->settings.selected_gpu_index, // 1105 + VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT, // global_priority 1106 + required_device_extensions, // 1107 + ARRAY_SIZE(required_device_extensions), // 1108 + optional_device_extensions, // 1109 + ARRAY_SIZE(optional_device_extensions)); // 1074 1110 1075 1111 if (ret != VK_SUCCESS) { 1076 1112 COMP_ERROR(c, "Failed to create VkDevice: %s", vk_result_string(ret));