The open source OpenXR runtime
0
fork

Configure Feed

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

u/space_overseer: Notify the device about reference space usage

+67 -4
+67 -4
src/xrt/auxiliary/util/u_space_overseer.c
··· 95 95 struct xrt_session_event_sink *broadcast; 96 96 97 97 /*! 98 + * The notify device, usually the head device. Used to notify when 99 + * reference spaces are used and not used. Must not change during 100 + * runtime. 101 + */ 102 + struct xrt_device *notify; 103 + 104 + /*! 98 105 * Can we do a recenter of the local and local_floor spaces, protected 99 106 * by the lock. 100 107 * ··· 133 140 case XRT_SPACE_REFERENCE_TYPE_STAGE: return "stage"; 134 141 case XRT_SPACE_REFERENCE_TYPE_UNBOUNDED: return "unbounded"; 135 142 } 143 + } 144 + 145 + static struct u_space * 146 + get_semantic_space(struct u_space_overseer *uso, enum xrt_reference_space_type type) 147 + { 148 + switch (type) { 149 + case XRT_SPACE_REFERENCE_TYPE_VIEW: return u_space(uso->base.semantic.view); 150 + case XRT_SPACE_REFERENCE_TYPE_LOCAL: return u_space(uso->base.semantic.local); 151 + case XRT_SPACE_REFERENCE_TYPE_LOCAL_FLOOR: return u_space(uso->base.semantic.local_floor); 152 + case XRT_SPACE_REFERENCE_TYPE_STAGE: return u_space(uso->base.semantic.stage); 153 + case XRT_SPACE_REFERENCE_TYPE_UNBOUNDED: return u_space(uso->base.semantic.unbounded); 154 + } 155 + 156 + return NULL; 136 157 } 137 158 138 159 /*! ··· 220 241 221 242 /* 222 243 * 244 + * Reference space to device notification code. 245 + * 246 + */ 247 + 248 + static void 249 + notify_ref_space_usage_device(struct u_space_overseer *uso, enum xrt_reference_space_type type, bool used) 250 + { 251 + struct xrt_device *xdev = NULL; 252 + enum xrt_input_name name = 0; 253 + 254 + struct u_space *uspace = get_semantic_space(uso, type); 255 + if (uspace == NULL) { 256 + // This is weird, should always be a space. 257 + return; 258 + } 259 + 260 + if (uspace->type == U_SPACE_TYPE_POSE) { 261 + xdev = uspace->pose.xdev; 262 + name = uspace->pose.xname; 263 + } else { 264 + xdev = uso->notify; 265 + } 266 + 267 + if (xdev == NULL || !xdev->ref_space_usage_supported) { 268 + return; 269 + } 270 + 271 + xrt_device_ref_space_usage(xdev, type, name, used); 272 + } 273 + 274 + 275 + /* 276 + * 223 277 * Graph traversing functions. 224 278 * 225 279 */ ··· 513 567 514 568 U_LOG_D("Ref-space %s in use", type_to_small_string(type)); 515 569 570 + 516 571 /* 517 - * This space intentionally left blank for future expansion, 518 - * use it for adding new functionality on used/unused switches. 572 + * We have a reference space that was not in use but is now in used. 519 573 */ 574 + 575 + // Notify any device that might want to know about it. 576 + notify_ref_space_usage_device(uso, type, true); 520 577 521 578 return XRT_SUCCESS; 522 579 } ··· 536 593 537 594 U_LOG_D("Ref-space %s no longer in use", type_to_small_string(type)); 538 595 596 + 539 597 /* 540 - * This space intentionally left blank for future expansion, 541 - * use it for adding new functionality on used/unused switches. 598 + * We have a reference space that was in use but is no longer used. 542 599 */ 600 + 601 + // Notify any device that might want to know about it. 602 + notify_ref_space_usage_device(uso, type, false); 543 603 544 604 return XRT_SUCCESS; 545 605 } ··· 772 832 // Setup view space if we have a head. 773 833 if (head != NULL) { 774 834 u_space_overseer_create_pose_space(uso, head, XRT_INPUT_GENERIC_HEAD_POSE, &uso->base.semantic.view); 835 + 836 + // Set the head to the notify device, for reference space usage. 837 + uso->notify = head; 775 838 } 776 839 } 777 840