The open source OpenXR runtime

xrt: refactor vk queue mutex into mutex per queue

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

+218 -93
+99 -30
src/xrt/auxiliary/vk/vk_bundle_init.c
··· 230 230 */ 231 231 232 232 static void 233 - fill_in_device_features(struct vk_bundle *vk) 233 + fill_in_device_features(struct vk_bundle *vk, const uint32_t queue_family_index) 234 234 { 235 235 /* 236 236 * Device properties. ··· 252 252 uint32_t count = 0; 253 253 vk->vkGetPhysicalDeviceQueueFamilyProperties(vk->physical_device, &count, NULL); 254 254 assert(count != 0); 255 - assert(count > vk->main_queue.family_index); 255 + assert(count > queue_family_index); 256 256 257 257 VkQueueFamilyProperties *props = U_TYPED_ARRAY_CALLOC(VkQueueFamilyProperties, count); 258 258 vk->vkGetPhysicalDeviceQueueFamilyProperties(vk->physical_device, &count, props); 259 259 260 - vk->features.timestamp_valid_bits = props[vk->main_queue.family_index].timestampValidBits; 260 + vk->features.timestamp_valid_bits = props[queue_family_index].timestampValidBits; 261 261 free(props); 262 262 } 263 263 ··· 1237 1237 device_features->video_maintenance_1); // 1238 1238 } 1239 1239 1240 + static inline void 1241 + vk_reset_queues(struct vk_bundle *vk) 1242 + { 1243 + const struct vk_queue_pair null_queue_pair = VK_NULL_QUEUE_PAIR; 1244 + 1245 + for (uint32_t i = 0; i < ARRAY_SIZE(vk->queues); ++i) { 1246 + struct vk_bundle_queue *q = &vk->queues[i]; 1247 + q->queue = VK_NULL_HANDLE; 1248 + q->index = null_queue_pair.index; 1249 + q->family_index = null_queue_pair.family_index; 1250 + } 1251 + } 1252 + 1253 + static struct vk_bundle_queue * 1254 + vk_insert_get_queue(struct vk_bundle *vk, const struct vk_queue_pair *new_queue) 1255 + { 1256 + if (vk == NULL || // 1257 + new_queue == NULL || // 1258 + new_queue->index == (uint32_t)-1 || // 1259 + new_queue->family_index == VK_QUEUE_FAMILY_IGNORED) { 1260 + return NULL; 1261 + } 1262 + 1263 + /* 1264 + * The same queue can be used for different uses, but we need to have 1265 + * one mutex per queue, so look up if the queue has already been added. 1266 + */ 1267 + for (uint32_t i = 0; i < VK_BUNDLE_MAX_QUEUES; ++i) { 1268 + struct vk_bundle_queue *q = &vk->queues[i]; 1269 + if (q->queue != VK_NULL_HANDLE && // 1270 + new_queue->index == q->index && // 1271 + new_queue->family_index == q->family_index) { 1272 + return q; 1273 + } 1274 + } 1275 + 1276 + // Find the first unused queue bundle. 1277 + for (uint32_t i = 0; i < VK_BUNDLE_MAX_QUEUES; ++i) { 1278 + struct vk_bundle_queue *q = &vk->queues[i]; 1279 + if (q->queue != VK_NULL_HANDLE) { 1280 + continue; 1281 + } 1282 + 1283 + q->index = new_queue->index; 1284 + q->family_index = new_queue->family_index; 1285 + 1286 + vk->vkGetDeviceQueue(vk->device, q->family_index, q->index, &q->queue); 1287 + return q; 1288 + } 1289 + 1290 + VK_ERROR(vk, "failed to find a free queue, max queues reached"); 1291 + return NULL; 1292 + } 1293 + 1240 1294 1241 1295 /* 1242 1296 * ··· 1296 1350 return VK_ERROR_NOT_PERMITTED_EXT; 1297 1351 } 1298 1352 1299 - vk->main_queue = VK_BUNDLE_NULL_QUEUE; 1353 + vk_reset_queues(vk); 1354 + 1355 + struct vk_queue_pair main_queue = VK_NULL_QUEUE_PAIR; 1300 1356 if (only_compute) { 1301 - ret = find_queue_family(vk, VK_QUEUE_COMPUTE_BIT, &vk->main_queue.family_index); 1357 + ret = find_queue_family(vk, VK_QUEUE_COMPUTE_BIT, &main_queue.family_index); 1302 1358 } else { 1303 - ret = find_graphics_queue_family(vk, &vk->main_queue.family_index); 1359 + ret = find_graphics_queue_family(vk, &main_queue.family_index); 1304 1360 } 1305 1361 1306 1362 if (ret != VK_SUCCESS) { ··· 1318 1374 uint32_t queue_create_info_count = 1; 1319 1375 1320 1376 // Compute or Graphics queue 1321 - vk->main_queue.index = 0; 1377 + main_queue.index = 0; 1322 1378 queue_create_info[0].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; 1323 1379 queue_create_info[0].pNext = NULL; 1324 1380 queue_create_info[0].queueCount = 1; 1325 - queue_create_info[0].queueFamilyIndex = vk->main_queue.family_index; 1381 + queue_create_info[0].queueFamilyIndex = main_queue.family_index; 1326 1382 queue_create_info[0].pQueuePriorities = &queue_priority; 1327 1383 1328 1384 #ifdef VK_KHR_video_encode_queue 1329 1385 // Video encode queue 1330 - vk->encode_queue = VK_BUNDLE_NULL_QUEUE; 1386 + struct vk_queue_pair encode_queue = VK_NULL_QUEUE_PAIR; 1331 1387 if (u_string_list_contains(device_ext_list, VK_KHR_VIDEO_ENCODE_QUEUE_EXTENSION_NAME)) { 1332 - ret = find_queue_family(vk, VK_QUEUE_VIDEO_ENCODE_BIT_KHR, &vk->encode_queue.family_index); 1388 + ret = find_queue_family(vk, VK_QUEUE_VIDEO_ENCODE_BIT_KHR, &encode_queue.family_index); 1333 1389 if (ret == VK_SUCCESS) { 1334 - vk->encode_queue.index = 0; 1390 + encode_queue.index = 0; 1335 1391 queue_create_info[queue_create_info_count].sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; 1336 1392 queue_create_info[queue_create_info_count].pNext = NULL; 1337 1393 queue_create_info[queue_create_info_count].queueCount = 1; 1338 - queue_create_info[queue_create_info_count].queueFamilyIndex = vk->encode_queue.family_index; 1394 + queue_create_info[queue_create_info_count].queueFamilyIndex = encode_queue.family_index; 1339 1395 queue_create_info[queue_create_info_count].pQueuePriorities = &queue_priority; 1340 1396 queue_create_info_count++; 1341 - VK_DEBUG(vk, "Creating video encode queue, family index %d", vk->encode_queue.family_index); 1397 + VK_DEBUG(vk, "Creating video encode queue, family index %d", encode_queue.family_index); 1342 1398 } 1343 1399 } 1344 1400 #endif ··· 1503 1559 } 1504 1560 1505 1561 // Fill in the device features we are interested in. 1506 - fill_in_device_features(vk); 1562 + fill_in_device_features(vk, main_queue.family_index); 1507 1563 1508 1564 // We fill in these here as we want to be sure we have selected the physical device fully. 1509 1565 fill_in_external_object_properties(vk); ··· 1513 1569 if (ret != VK_SUCCESS) { 1514 1570 goto err_destroy; 1515 1571 } 1516 - vk->vkGetDeviceQueue(vk->device, vk->main_queue.family_index, vk->main_queue.index, &vk->main_queue.queue); 1572 + 1573 + vk->main_queue = vk_insert_get_queue(vk, &main_queue); 1574 + assert(vk->main_queue != NULL); 1517 1575 #if defined(VK_KHR_video_encode_queue) 1518 - if (vk->encode_queue.family_index != VK_QUEUE_FAMILY_IGNORED) { 1519 - vk->vkGetDeviceQueue(vk->device, vk->encode_queue.family_index, vk->encode_queue.index, 1520 - &vk->encode_queue.queue); 1521 - } 1576 + vk->encode_queue = vk_insert_get_queue(vk, &encode_queue); 1522 1577 #endif 1523 1578 1524 1579 // Need to do this after functions have been gotten. ··· 1537 1592 VkResult 1538 1593 vk_init_mutex(struct vk_bundle *vk) 1539 1594 { 1540 - if (os_mutex_init(&vk->queue_mutex) < 0) { 1541 - return VK_ERROR_INITIALIZATION_FAILED; 1595 + assert(vk != NULL); 1596 + 1597 + for (uint32_t i = 0; i < ARRAY_SIZE(vk->queues); ++i) { 1598 + struct vk_bundle_queue *q = &vk->queues[i]; 1599 + 1600 + if (os_mutex_init(&q->mutex) < 0) { 1601 + VK_ERROR(vk, "failed to initialize queue mutex"); 1602 + return VK_ERROR_INITIALIZATION_FAILED; 1603 + } 1542 1604 } 1543 1605 return VK_SUCCESS; 1544 1606 } ··· 1546 1608 VkResult 1547 1609 vk_deinit_mutex(struct vk_bundle *vk) 1548 1610 { 1549 - os_mutex_destroy(&vk->queue_mutex); 1611 + assert(vk != NULL); 1612 + 1613 + for (uint32_t i = 0; i < ARRAY_SIZE(vk->queues); ++i) { 1614 + struct vk_bundle_queue *q = &vk->queues[i]; 1615 + os_mutex_destroy(&q->mutex); 1616 + q->mutex = (struct os_mutex){0}; 1617 + } 1550 1618 return VK_SUCCESS; 1551 1619 } 1552 - 1553 1620 1554 1621 /* 1555 1622 * ··· 1578 1645 U_ZERO(vk); 1579 1646 vk->log_level = log_level; 1580 1647 1648 + vk_reset_queues(vk); 1649 + 1581 1650 ret = vk_get_loader_functions(vk, vkGetInstanceProcAddr); 1582 1651 if (ret != VK_SUCCESS) { 1583 1652 goto err_memset; ··· 1586 1655 vk->instance = instance; 1587 1656 vk->physical_device = physical_device; 1588 1657 vk->device = device; 1589 - vk->main_queue.family_index = queue_family_index; 1590 - vk->main_queue.index = queue_index; 1591 - #ifdef VK_KHR_video_encode_queue 1592 - vk->encode_queue = VK_BUNDLE_NULL_QUEUE; 1593 - #endif 1594 1658 1595 1659 // Fill in all instance functions. 1596 1660 ret = vk_get_instance_functions(vk); ··· 1628 1692 } 1629 1693 #endif 1630 1694 1695 + const struct vk_queue_pair main_queue = { 1696 + .family_index = queue_family_index, 1697 + .index = queue_index, 1698 + }; 1631 1699 // Fill in the device features we are interested in. 1632 - fill_in_device_features(vk); 1700 + fill_in_device_features(vk, main_queue.family_index); 1633 1701 1634 1702 // Fill in external object properties. 1635 1703 fill_in_external_object_properties(vk); ··· 1640 1708 goto err_memset; 1641 1709 } 1642 1710 1643 - vk->vkGetDeviceQueue(vk->device, vk->main_queue.family_index, vk->main_queue.index, &vk->main_queue.queue); 1711 + vk->main_queue = vk_insert_get_queue(vk, &main_queue); 1712 + assert(vk->main_queue != NULL); 1644 1713 1645 1714 vk->has_EXT_debug_utils = false; 1646 1715 if (debug_utils_enabled) {
+2 -2
src/xrt/auxiliary/vk/vk_cmd.c
··· 83 83 { 84 84 VkResult ret; 85 85 86 - os_mutex_lock(&vk->queue_mutex); 86 + vk_queue_lock(queue); 87 87 ret = vk->vkQueueSubmit(queue->queue, count, infos, fence); 88 - os_mutex_unlock(&vk->queue_mutex); 88 + vk_queue_unlock(queue); 89 89 90 90 if (ret != VK_SUCCESS) { 91 91 VK_ERROR(vk, "vkQueueSubmit: %s", vk_result_string(ret));
+1 -1
src/xrt/auxiliary/vk/vk_cmd_pool.h
··· 72 72 static inline XRT_CHECK_RESULT VkResult 73 73 vk_cmd_pool_init(struct vk_bundle *vk, struct vk_cmd_pool *pool, VkCommandPoolCreateFlags flags) 74 74 { 75 - return vk_cmd_pool_init_for_queue(vk, pool, flags, &vk->main_queue); 75 + return vk_cmd_pool_init_for_queue(vk, pool, flags, vk->main_queue); 76 76 } 77 77 78 78 /*!
+51 -10
src/xrt/auxiliary/vk/vk_helpers.h
··· 33 33 extern "C" { 34 34 #endif 35 35 36 + #define VK_BUNDLE_MAX_QUEUES 2 36 37 37 38 /* 38 39 * ··· 40 41 * 41 42 */ 42 43 43 - struct vk_bundle_queue 44 + struct vk_queue_pair 44 45 { 45 - //! The Vulkan queue handle 46 - VkQueue queue; 47 46 //! The queue family index 48 47 uint32_t family_index; 49 48 //! The queue (instance) index 50 49 uint32_t index; 51 50 }; 52 51 53 - #define VK_BUNDLE_NULL_QUEUE \ 54 - XRT_C11_COMPOUND(struct vk_bundle_queue) \ 52 + #define VK_NULL_QUEUE_PAIR \ 53 + XRT_C11_COMPOUND(struct vk_queue_pair) \ 55 54 { \ 56 - .queue = VK_NULL_HANDLE, .family_index = VK_QUEUE_FAMILY_IGNORED, .index = (uint32_t)-1, \ 55 + .family_index = VK_QUEUE_FAMILY_IGNORED, .index = (uint32_t)-1, \ 57 56 } 58 57 58 + struct vk_bundle_queue 59 + { 60 + //! The Vulkan queue handle 61 + VkQueue queue; 62 + //! The queue family index 63 + uint32_t family_index; 64 + //! The queue (instance) index 65 + uint32_t index; 66 + //! The queue mutex - @see vk_queue_lock, vk_queue_unlock 67 + struct os_mutex mutex; 68 + }; 69 + 59 70 /*! 60 71 * A bundle of Vulkan functions and objects, used by both @ref comp and @ref 61 72 * comp_client. Note that they both have different instances of the object, and ··· 72 83 VkPhysicalDevice physical_device; 73 84 int physical_device_index; 74 85 VkDevice device; 75 - struct vk_bundle_queue main_queue; 86 + 87 + /*! 88 + * @brief queues - a free list of **unique** queues 89 + * 90 + * One per uniquely identifiable vk queue (family x instance index), 91 + * duplicate entries must not be stored. 92 + * 93 + * Should not be used directly, @see main_queue, encode_queue 94 + */ 95 + struct vk_bundle_queue queues[VK_BUNDLE_MAX_QUEUES]; 96 + 97 + struct vk_bundle_queue *main_queue; 76 98 #if defined(VK_KHR_video_encode_queue) 77 - struct vk_bundle_queue encode_queue; 99 + struct vk_bundle_queue *encode_queue; 78 100 #endif 79 - 80 - struct os_mutex queue_mutex; 81 101 82 102 struct 83 103 { ··· 1086 1106 */ 1087 1107 VkResult 1088 1108 vk_deinit_mutex(struct vk_bundle *vk); 1109 + 1110 + static inline void 1111 + vk_queue_lock(struct vk_bundle_queue *q) 1112 + { 1113 + assert(q != NULL); 1114 + os_mutex_lock(&q->mutex); 1115 + } 1116 + 1117 + static inline int 1118 + vk_queue_trylock(struct vk_bundle_queue *q) 1119 + { 1120 + assert(q != NULL); 1121 + return os_mutex_trylock(&q->mutex); 1122 + } 1123 + 1124 + static inline void 1125 + vk_queue_unlock(struct vk_bundle_queue *q) 1126 + { 1127 + assert(q != NULL); 1128 + os_mutex_unlock(&q->mutex); 1129 + } 1089 1130 1090 1131 /*! 1091 1132 * Initialize a bundle with objects given to us by client code,
+23 -8
src/xrt/auxiliary/vk/vk_print.c
··· 39 39 } while (false) 40 40 41 41 static inline void 42 - print_queue(u_pp_delegate_t dg, const char *prefix, const struct vk_bundle_queue *queue) 42 + print_queue_non_null(u_pp_delegate_t dg, const char *prefix, const struct vk_bundle_queue *queue) 43 43 { 44 + assert(queue != NULL); 44 45 PNT("%squeue.queue: %p", prefix, (const void *)queue->queue); 45 46 PNT("%squeue.index: %d", prefix, (int32_t)queue->index); 46 47 PNT("%squeue.family_index: %d", prefix, (int32_t)queue->family_index); 48 + } 49 + 50 + static inline void 51 + print_queue(u_pp_delegate_t dg, const char *prefix, const struct vk_bundle_queue *queue) 52 + { 53 + if (queue != NULL) { 54 + print_queue_non_null(dg, prefix, queue); 55 + } else { 56 + const struct vk_queue_pair null_queue_pair = VK_NULL_QUEUE_PAIR; 57 + 58 + struct vk_bundle_queue null_queue = { 59 + .queue = VK_NULL_HANDLE, 60 + .family_index = null_queue_pair.family_index, 61 + .index = null_queue_pair.index, 62 + }; 63 + print_queue_non_null(dg, prefix, &null_queue); 64 + } 47 65 } 48 66 49 67 /* ··· 288 306 void 289 307 vk_print_queues_info(const struct vk_bundle *vk, enum u_logging_level log_level) 290 308 { 291 - struct vk_bundle_queue encode_queue = VK_BUNDLE_NULL_QUEUE; 292 - #if defined(VK_KHR_video_encode_queue) 293 - encode_queue = vk->encode_queue; 294 - #endif 295 - 296 309 struct u_pp_sink_stack_only sink; 297 310 u_pp_delegate_t dg = u_pp_sink_stack_only_init(&sink); 298 311 299 312 P("Selected Queues/Families:"); 300 - print_queue(dg, "main_", &vk->main_queue); 301 - print_queue(dg, "encode_", &encode_queue); 313 + print_queue(dg, "main_", vk->main_queue); 314 + #if defined(VK_KHR_video_encode_queue) 315 + print_queue(dg, "encode_", vk->encode_queue); 316 + #endif 302 317 303 318 U_LOG_IFL(log_level, vk->log_level, "%s", sink.buffer); 304 319 }
+7 -7
src/xrt/auxiliary/vk/vk_sync_objects.c
··· 142 142 * Submit fence. 143 143 */ 144 144 145 - os_mutex_lock(&vk->queue_mutex); 145 + vk_queue_lock(vk->main_queue); 146 146 147 - ret = vk->vkQueueSubmit( // 148 - vk->main_queue.queue, // queue 149 - 0, // submitCount 150 - NULL, // pSubmits 151 - fence); // fence 147 + ret = vk->vkQueueSubmit( // 148 + vk->main_queue->queue, // queue 149 + 0, // submitCount 150 + NULL, // pSubmits 151 + fence); // fence 152 152 153 - os_mutex_unlock(&vk->queue_mutex); 153 + vk_queue_unlock(vk->main_queue); 154 154 155 155 if (ret != VK_SUCCESS) { 156 156 VK_ERROR(vk, "vkQueueSubmit: %s", vk_result_string(ret));
+9 -9
src/xrt/compositor/client/comp_vk_client.c
··· 178 178 .pSignalSemaphores = semaphores, 179 179 }; 180 180 181 - ret = vk->vkQueueSubmit( // 182 - vk->main_queue.queue, // queue 183 - 1, // submitCount 184 - &submit_info, // pSubmits 185 - VK_NULL_HANDLE); // fence 181 + ret = vk->vkQueueSubmit( // 182 + vk->main_queue->queue, // queue 183 + 1, // submitCount 184 + &submit_info, // pSubmits 185 + VK_NULL_HANDLE); // fence 186 186 if (ret != VK_SUCCESS) { 187 187 VK_ERROR(vk, "vkQueueSubmit: %s", vk_result_string(ret)); 188 188 *out_xret = XRT_ERROR_VULKAN; ··· 245 245 COMP_TRACE_IDENT(device_wait_idle); 246 246 247 247 // Last course of action fallback. 248 - os_mutex_lock(&vk->queue_mutex); 249 - vk->vkQueueWaitIdle(vk->main_queue.queue); 250 - os_mutex_unlock(&vk->queue_mutex); 248 + vk_queue_lock(vk->main_queue); 249 + vk->vkQueueWaitIdle(vk->main_queue->queue); 250 + vk_queue_unlock(vk->main_queue); 251 251 } 252 252 253 253 *out_xret = xrt_comp_layer_commit(&c->xcn->base, XRT_GRAPHICS_SYNC_HANDLE_INVALID); ··· 738 738 .dstAccessMask = 0, 739 739 .oldLayout = barrier_optimal_layout, 740 740 .newLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, 741 - .srcQueueFamilyIndex = vk->main_queue.family_index, 741 + .srcQueueFamilyIndex = vk->main_queue->family_index, 742 742 .dstQueueFamilyIndex = VK_QUEUE_FAMILY_EXTERNAL, 743 743 .image = sc->base.images[i], 744 744 .subresourceRange = subresource_range,
+11 -11
src/xrt/compositor/main/comp_renderer.c
··· 159 159 COMP_TRACE_MARKER(); 160 160 struct vk_bundle *vk = &r->c->base.vk; 161 161 162 - os_mutex_lock(&vk->queue_mutex); 163 - vk->vkQueueWaitIdle(vk->main_queue.queue); 164 - os_mutex_unlock(&vk->queue_mutex); 162 + vk_queue_lock(vk->main_queue); 163 + vk->vkQueueWaitIdle(vk->main_queue->queue); 164 + vk_queue_unlock(vk->main_queue); 165 165 } 166 166 167 167 static void ··· 665 665 * us avoid taking a lot of locks. The queue lock will be taken by 666 666 * @ref vk_cmd_submit_locked tho. 667 667 */ 668 - ret = vk_cmd_submit_locked(vk, &vk->main_queue, 1, &comp_submit_info, r->fences[r->acquired_buffer]); 668 + ret = vk_cmd_submit_locked(vk, vk->main_queue, 1, &comp_submit_info, r->fences[r->acquired_buffer]); 669 669 670 670 // We have now completed the submit, even if we failed. 671 671 comp_target_mark_submit_end(ct, frame_id, os_monotonic_get_ns()); ··· 741 741 assert(!comp_frame_is_invalid_locked(&r->c->frame.rendering)); 742 742 uint64_t render_complete_signal_value = (uint64_t)r->c->frame.rendering.id; 743 743 744 - ret = comp_target_present( // 745 - r->c->target, // 746 - r->c->base.vk.main_queue.queue, // 747 - r->acquired_buffer, // 748 - render_complete_signal_value, // 749 - desired_present_time_ns, // 750 - present_slop_ns); // 744 + ret = comp_target_present( // 745 + r->c->target, // 746 + r->c->base.vk.main_queue->queue, // 747 + r->acquired_buffer, // 748 + render_complete_signal_value, // 749 + desired_present_time_ns, // 750 + present_slop_ns); // 751 751 r->acquired_buffer = -1; 752 752 753 753 if (ret == VK_ERROR_OUT_OF_DATE_KHR || ret == VK_SUBOPTIMAL_KHR) {
+3 -3
src/xrt/compositor/main/comp_target_swapchain.c
··· 682 682 // Can we create swapchains from the surface on this device and queue. 683 683 ret = vk->vkGetPhysicalDeviceSurfaceSupportKHR( // 684 684 vk->physical_device, // physicalDevice 685 - vk->main_queue.family_index, // queueFamilyIndex 685 + vk->main_queue->family_index, // queueFamilyIndex 686 686 cts->surface.handle, // surface 687 687 &supported); // pSupported 688 688 if (ret != VK_SUCCESS) { ··· 923 923 924 924 925 925 // Need to take the queue lock for present. 926 - os_mutex_lock(&vk->queue_mutex); 926 + vk_queue_lock(vk->main_queue); 927 927 VkResult ret = vk->vkQueuePresentKHR(queue, &present_info); 928 - os_mutex_unlock(&vk->queue_mutex); 928 + vk_queue_unlock(vk->main_queue); 929 929 930 930 931 931 #ifdef VK_EXT_display_control
+6 -6
src/xrt/compositor/main/comp_window_peek.c
··· 266 266 267 267 struct vk_bundle *vk = get_vk(w); 268 268 269 - os_mutex_lock(&vk->queue_mutex); 269 + vk_queue_lock(vk->main_queue); 270 270 vk->vkDeviceWaitIdle(vk->device); 271 - os_mutex_unlock(&vk->queue_mutex); 271 + vk_queue_unlock(vk->main_queue); 272 272 273 273 vk_cmd_pool_lock(&w->pool); 274 274 vk->vkFreeCommandBuffers(vk->device, w->pool.pool, 1, &w->cmd); ··· 434 434 }; 435 435 436 436 // Done writing commands, submit to queue. 437 - ret = vk_cmd_submit_locked(vk, &vk->main_queue, 1, &submit, VK_NULL_HANDLE); 437 + ret = vk_cmd_submit_locked(vk, vk->main_queue, 1, &submit, VK_NULL_HANDLE); 438 438 439 439 // Done submitting commands, unlock pool. 440 440 vk_cmd_pool_unlock(&w->pool); ··· 456 456 .pResults = NULL, 457 457 }; 458 458 459 - os_mutex_lock(&vk->queue_mutex); 460 - ret = vk->vkQueuePresentKHR(vk->main_queue.queue, &present); 461 - os_mutex_unlock(&vk->queue_mutex); 459 + vk_queue_lock(vk->main_queue); 460 + ret = vk->vkQueuePresentKHR(vk->main_queue->queue, &present); 461 + vk_queue_unlock(vk->main_queue); 462 462 463 463 if (ret != VK_SUCCESS) { 464 464 VK_ERROR(vk, "Error: could not present to queue.\n");
+2 -2
src/xrt/compositor/render/render_resources.c
··· 595 595 VkCommandPoolCreateInfo command_pool_info = { 596 596 .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, 597 597 .flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT, 598 - .queueFamilyIndex = vk->main_queue.family_index, 598 + .queueFamilyIndex = vk->main_queue->family_index, 599 599 }; 600 600 601 601 ret = vk->vkCreateCommandPool(vk->device, &command_pool_info, NULL, &r->cmd_pool); ··· 657 657 r->mock.color.image); // dst 658 658 VK_CHK_WITH_RET(ret, "prepare_mock_image_locked", false); 659 659 660 - ret = vk_cmd_end_submit_wait_and_free_cmd_buffer_locked(vk, &vk->main_queue, r->cmd_pool, cmd); 660 + ret = vk_cmd_end_submit_wait_and_free_cmd_buffer_locked(vk, vk->main_queue, r->cmd_pool, cmd); 661 661 VK_CHK_WITH_RET(ret, "vk_cmd_end_submit_wait_and_free_cmd_buffer_locked", false); 662 662 663 663 // No need to wait, submit waits on the fence.
+2 -2
src/xrt/compositor/util/comp_swapchain.c
··· 283 283 * validation doesn't complain. This is done during image destruction so 284 284 * isn't time critical. 285 285 */ 286 - os_mutex_lock(&vk->queue_mutex); 286 + vk_queue_lock(vk->main_queue); 287 287 vk->vkDeviceWaitIdle(vk->device); 288 - os_mutex_unlock(&vk->queue_mutex); 288 + vk_queue_unlock(vk->main_queue); 289 289 290 290 // The field array_size is shared, only reset once both are freed. 291 291 image_view_array_cleanup(vk, image->array_size, &image->views.alpha);
+2 -2
tests/tests_comp_client_vulkan.cpp
··· 152 152 vk->has_KHR_image_format_list, // image_format_list_enabled 153 153 false, // debug_utils_enabled 154 154 false, // renderdoc_enabled 155 - vk->main_queue.family_index, // 156 - vk->main_queue.index); 155 + vk->main_queue->family_index, // 156 + vk->main_queue->index); 157 157 struct xrt_compositor *xc = &xcvk->base; 158 158 159 159 SECTION("CreateSwapchain calls native create")