The open source OpenXR runtime

xrt: Extend xrt_device::get_tracked_views with xrt_view_type

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

authored by

Rafal Karp and committed by
Jakob Bornecrantz
8dea7585 a4d997da

+104 -26
+2
src/xrt/auxiliary/util/u_device.c
··· 461 461 u_device_get_view_poses(struct xrt_device *xdev, 462 462 const struct xrt_vec3 *default_eye_relation, 463 463 int64_t at_timestamp_ns, 464 + enum xrt_view_type view_type, 464 465 uint32_t view_count, 465 466 struct xrt_space_relation *out_head_relation, 466 467 struct xrt_fov *out_fovs, ··· 538 539 u_device_ni_get_view_poses(struct xrt_device *xdev, 539 540 const struct xrt_vec3 *default_eye_relation, 540 541 int64_t at_timestamp_ns, 542 + enum xrt_view_type view_type, 541 543 uint32_t view_count, 542 544 struct xrt_space_relation *out_head_relation, 543 545 struct xrt_fov *out_fovs,
+2
src/xrt/auxiliary/util/u_device.h
··· 171 171 u_device_get_view_poses(struct xrt_device *xdev, 172 172 const struct xrt_vec3 *default_eye_relation, 173 173 int64_t at_timestamp_ns, 174 + enum xrt_view_type view_type, 174 175 uint32_t view_count, 175 176 struct xrt_space_relation *out_head_relation, 176 177 struct xrt_fov *out_fovs, ··· 238 239 u_device_ni_get_view_poses(struct xrt_device *xdev, 239 240 const struct xrt_vec3 *default_eye_relation, 240 241 int64_t at_timestamp_ns, 242 + enum xrt_view_type view_type, 241 243 uint32_t view_count, 242 244 struct xrt_space_relation *out_head_relation, 243 245 struct xrt_fov *out_fovs,
+6 -1
src/xrt/compositor/main/comp_renderer.c
··· 259 259 struct xrt_fov xdev_fovs[XRT_MAX_VIEWS] = XRT_STRUCT_INIT; 260 260 struct xrt_pose xdev_poses[2][XRT_MAX_VIEWS] = XRT_STRUCT_INIT; 261 261 262 + // Determine view type based on view count 263 + enum xrt_view_type view_type = (view_count == 1) ? XRT_VIEW_TYPE_MONO : XRT_VIEW_TYPE_STEREO; 264 + 262 265 int64_t scanout_time_ns = 0; 263 266 if (r->c->xdev->hmd->screens[0].scanout_direction == XRT_SCANOUT_DIRECTION_TOP_TO_BOTTOM) { 264 267 scanout_time_ns = r->c->xdev->hmd->screens[0].scanout_time_ns; ··· 274 277 r->c->xdev, // 275 278 &default_eye_relation, // 276 279 begin_timestamp_ns, // at_timestamp_ns 280 + view_type, // 277 281 view_count, // 278 282 &head_relation[0], // out_head_relation 279 283 xdev_fovs, // out_fovs 280 - xdev_poses[0]); 284 + xdev_poses[0]); // 281 285 if (xret != XRT_SUCCESS) { 282 286 struct u_pp_sink_stack_only sink; 283 287 u_pp_delegate_t dg = u_pp_sink_stack_only_init(&sink); ··· 292 296 r->c->xdev, // 293 297 &default_eye_relation, // 294 298 end_timestamp_ns, // at_timestamp_ns 299 + view_type, // 295 300 view_count, // 296 301 &head_relation[1], // out_head_relation 297 302 xdev_fovs, // out_fovs
+10 -2
src/xrt/compositor/null/null_compositor.c
··· 436 436 437 437 struct xrt_fov fovs[2] = {0}; 438 438 struct xrt_pose poses[2] = {0}; 439 - xrt_result_t xret = 440 - xrt_device_get_view_poses(c->xdev, &default_eye_relation, display_time_ns, 2, &head_relation, fovs, poses); 439 + 440 + xrt_result_t xret = xrt_device_get_view_poses( // 441 + c->xdev, // 442 + &default_eye_relation, // 443 + display_time_ns, // 444 + XRT_VIEW_TYPE_STEREO, // 445 + 2, // 446 + &head_relation, // 447 + fovs, // 448 + poses); // 441 449 if (xret != XRT_SUCCESS) { 442 450 return xret; 443 451 }
+10 -2
src/xrt/drivers/blubur_s1/blubur_s1_hmd.c
··· 157 157 blubur_s1_hmd_get_view_poses(struct xrt_device *xdev, 158 158 const struct xrt_vec3 *default_eye_relation, 159 159 int64_t at_timestamp_ns, 160 + enum xrt_view_type view_type, 160 161 uint32_t view_count, 161 162 struct xrt_space_relation *out_head_relation, 162 163 struct xrt_fov *out_fovs, 163 164 struct xrt_pose *out_poses) 164 165 { 165 - return u_device_get_view_poses(xdev, default_eye_relation, at_timestamp_ns, view_count, out_head_relation, 166 - out_fovs, out_poses); 166 + return u_device_get_view_poses( // 167 + xdev, // 168 + default_eye_relation, // 169 + at_timestamp_ns, // 170 + view_type, // 171 + view_count, // 172 + out_head_relation, // 173 + out_fovs, // 174 + out_poses); // 167 175 } 168 176 169 177 static void
+11 -2
src/xrt/drivers/multi_wrapper/multi.c
··· 196 196 get_view_poses(struct xrt_device *xdev, 197 197 const struct xrt_vec3 *default_eye_relation, 198 198 int64_t at_timestamp_ns, 199 + enum xrt_view_type view_type, 199 200 uint32_t view_count, 200 201 struct xrt_space_relation *out_head_relation, 201 202 struct xrt_fov *out_fovs, ··· 203 204 { 204 205 struct multi_device *d = (struct multi_device *)xdev; 205 206 struct xrt_device *target = d->tracking_override.target; 206 - xrt_result_t xret = xrt_device_get_view_poses(target, default_eye_relation, at_timestamp_ns, view_count, 207 - out_head_relation, out_fovs, out_poses); 207 + 208 + xrt_result_t xret = xrt_device_get_view_poses( // 209 + target, // 210 + default_eye_relation, // 211 + at_timestamp_ns, // 212 + view_type, // 213 + view_count, // 214 + out_head_relation, // 215 + out_fovs, // 216 + out_poses); // 208 217 if (xret != XRT_SUCCESS) { 209 218 return xret; 210 219 }
+2
src/xrt/drivers/north_star/ns_hmd.c
··· 389 389 ns_hmd_get_view_poses(struct xrt_device *xdev, 390 390 const struct xrt_vec3 *default_eye_relation, 391 391 int64_t at_timestamp_ns, 392 + enum xrt_view_type view_type, 392 393 uint32_t view_count, 393 394 struct xrt_space_relation *out_head_relation, 394 395 struct xrt_fov *out_fovs, ··· 402 403 xdev, // 403 404 default_eye_relation, // 404 405 at_timestamp_ns, // 406 + view_type, // 405 407 view_count, // 406 408 out_head_relation, // 407 409 out_fovs, //
+2
src/xrt/drivers/remote/r_hmd.c
··· 78 78 r_hmd_get_view_poses(struct xrt_device *xdev, 79 79 const struct xrt_vec3 *default_eye_relation, 80 80 int64_t at_timestamp_ns, 81 + enum xrt_view_type view_type, 81 82 uint32_t view_count, 82 83 struct xrt_space_relation *out_head_relation, 83 84 struct xrt_fov *out_fovs, ··· 90 91 xdev, // 91 92 default_eye_relation, // 92 93 at_timestamp_ns, // 94 + view_type, // 93 95 view_count, // 94 96 out_head_relation, // 95 97 out_fovs, //
+10 -7
src/xrt/drivers/rift/rift_hmd.c
··· 230 230 rift_hmd_get_view_poses(struct xrt_device *xdev, 231 231 const struct xrt_vec3 *default_eye_relation, 232 232 int64_t at_timestamp_ns, 233 + enum xrt_view_type view_type, 233 234 uint32_t view_count, 234 235 struct xrt_space_relation *out_head_relation, 235 236 struct xrt_fov *out_fovs, ··· 237 238 { 238 239 struct rift_hmd *hmd = rift_hmd(xdev); 239 240 240 - return u_device_get_view_poses(xdev, // 241 - &(struct xrt_vec3){hmd->extra_display_info.icd, 0.0f, 0.0f}, // 242 - at_timestamp_ns, // 243 - view_count, // 244 - out_head_relation, // 245 - out_fovs, // 246 - out_poses); 241 + return u_device_get_view_poses( // 242 + xdev, // 243 + &(struct xrt_vec3){hmd->extra_display_info.icd, 0.0f, 0.0f}, // 244 + at_timestamp_ns, // 245 + view_type, // 246 + view_count, // 247 + out_head_relation, // 248 + out_fovs, // 249 + out_poses); 247 250 } 248 251 249 252 static xrt_result_t
+2
src/xrt/drivers/sample/sample_hmd.c
··· 132 132 sample_hmd_get_view_poses(struct xrt_device *xdev, 133 133 const struct xrt_vec3 *default_eye_relation, 134 134 int64_t at_timestamp_ns, 135 + enum xrt_view_type view_type, 135 136 uint32_t view_count, 136 137 struct xrt_space_relation *out_head_relation, 137 138 struct xrt_fov *out_fovs, ··· 145 146 xdev, // 146 147 default_eye_relation, // 147 148 at_timestamp_ns, // 149 + view_type, // 148 150 view_count, // 149 151 out_head_relation, // 150 152 out_fovs, //
+2
src/xrt/drivers/simula/svr_hmd.c
··· 103 103 svr_hmd_get_view_poses(struct xrt_device *xdev, 104 104 const struct xrt_vec3 *default_eye_relation, 105 105 int64_t at_timestamp_ns, 106 + enum xrt_view_type view_type, 106 107 uint32_t view_count, 107 108 struct xrt_space_relation *out_head_relation, 108 109 struct xrt_fov *out_fovs, ··· 115 116 xdev, // 116 117 default_eye_relation, // 117 118 at_timestamp_ns, // 119 + view_type, // 118 120 view_count, // 119 121 out_head_relation, // 120 122 out_fovs, //
+2
src/xrt/drivers/steamvr_lh/device.cpp
··· 605 605 xrt_result_t 606 606 HmdDevice::get_view_poses(const xrt_vec3 *default_eye_relation, 607 607 uint64_t at_timestamp_ns, 608 + xrt_view_type view_type, 608 609 uint32_t view_count, 609 610 xrt_space_relation *out_head_relation, 610 611 xrt_fov *out_fovs, ··· 617 618 this, // 618 619 &eye_relation, // 619 620 at_timestamp_ns, // 621 + view_type, // 620 622 view_count, // 621 623 out_head_relation, // 622 624 out_fovs, //
+1
src/xrt/drivers/steamvr_lh/device.hpp
··· 176 176 xrt_result_t 177 177 get_view_poses(const xrt_vec3 *default_eye_relation, 178 178 uint64_t at_timestamp_ns, 179 + xrt_view_type view_type, 179 180 uint32_t view_count, 180 181 xrt_space_relation *out_head_relation, 181 182 xrt_fov *out_fovs,
+2
src/xrt/drivers/survive/survive_driver.c
··· 530 530 survive_device_get_view_poses(struct xrt_device *xdev, 531 531 const struct xrt_vec3 *default_eye_relation, 532 532 int64_t at_timestamp_ns, 533 + enum xrt_view_type view_type, 533 534 uint32_t view_count, 534 535 struct xrt_space_relation *out_head_relation, 535 536 struct xrt_fov *out_fovs, ··· 554 555 xdev, // 555 556 &eye_relation, // 556 557 at_timestamp_ns, // 558 + view_type, // 557 559 view_count, // 558 560 out_head_relation, // 559 561 out_fovs, //
+2
src/xrt/drivers/vive/vive_device.c
··· 212 212 vive_device_get_view_poses(struct xrt_device *xdev, 213 213 const struct xrt_vec3 *default_eye_relation, 214 214 int64_t at_timestamp_ns, 215 + enum xrt_view_type view_type, 215 216 uint32_t view_count, 216 217 struct xrt_space_relation *out_head_relation, 217 218 struct xrt_fov *out_fovs, ··· 226 227 xdev, // 227 228 default_eye_relation, // 228 229 at_timestamp_ns, // 230 + view_type, // 229 231 view_count, // 230 232 out_head_relation, // 231 233 out_fovs, //
-9
src/xrt/include/xrt/xrt_compositor.h
··· 858 858 * 859 859 */ 860 860 861 - /*! 862 - * View type to be rendered to by the compositor. 863 - */ 864 - enum xrt_view_type 865 - { 866 - XRT_VIEW_TYPE_MONO = 1, 867 - XRT_VIEW_TYPE_STEREO = 2, 868 - }; 869 - 870 861 enum xrt_compositor_frame_point 871 862 { 872 863 XRT_COMPOSITOR_FRAME_POINT_WOKE, //!< The client woke up after waiting.
+9
src/xrt/include/xrt/xrt_defines.h
··· 2119 2119 }; 2120 2120 2121 2121 /*! 2122 + * View type to be rendered to by the compositor. 2123 + */ 2124 + enum xrt_view_type 2125 + { 2126 + XRT_VIEW_TYPE_MONO = 1, 2127 + XRT_VIEW_TYPE_STEREO = 2, 2128 + }; 2129 + 2130 + /*! 2122 2131 * Domain type. 2123 2132 * Use for performance level setting 2124 2133 * Which hardware should be boost/decrease
+12 -2
src/xrt/include/xrt/xrt_device.h
··· 550 550 * input. 551 551 * @param[in] at_timestamp_ns This is when the caller wants the poses and FOVs to be from. 552 552 * @param[in] view_count Number of views. 553 + * @param[in] view_type Type of view configuration (mono or stereo). 553 554 * @param[out] out_head_relation 554 555 * The head pose in the device tracking space. 555 556 * Combine with @p out_poses to get the views in ··· 567 568 xrt_result_t (*get_view_poses)(struct xrt_device *xdev, 568 569 const struct xrt_vec3 *default_eye_relation, 569 570 int64_t at_timestamp_ns, 571 + enum xrt_view_type view_type, 570 572 uint32_t view_count, 571 573 struct xrt_space_relation *out_head_relation, 572 574 struct xrt_fov *out_fovs, ··· 918 920 xrt_device_get_view_poses(struct xrt_device *xdev, 919 921 const struct xrt_vec3 *default_eye_relation, 920 922 int64_t at_timestamp_ns, 923 + enum xrt_view_type view_type, 921 924 uint32_t view_count, 922 925 struct xrt_space_relation *out_head_relation, 923 926 struct xrt_fov *out_fovs, 924 927 struct xrt_pose *out_poses) 925 928 { 926 - return xdev->get_view_poses(xdev, default_eye_relation, at_timestamp_ns, view_count, out_head_relation, 927 - out_fovs, out_poses); 929 + return xdev->get_view_poses( // 930 + xdev, // 931 + default_eye_relation, // 932 + at_timestamp_ns, // 933 + view_type, // 934 + view_count, // 935 + out_head_relation, // 936 + out_fovs, // 937 + out_poses); // 928 938 } 929 939 930 940 /*!
+5
src/xrt/ipc/client/ipc_client_hmd.c
··· 66 66 call_get_view_poses_raw(ipc_client_hmd_t *ich, 67 67 const struct xrt_vec3 *default_eye_relation, 68 68 int64_t at_timestamp_ns, 69 + enum xrt_view_type view_type, 69 70 uint32_t view_count, 70 71 struct xrt_space_relation *out_head_relation, 71 72 struct xrt_fov *out_fovs, ··· 82 83 ich->device_id, // 83 84 default_eye_relation, // 84 85 at_timestamp_ns, // 86 + view_type, // 85 87 view_count); // 86 88 IPC_CHK_WITH_GOTO(ich->ipc_c, xret, "ipc_send_device_get_view_poses_locked", out); 87 89 ··· 131 133 ipc_client_hmd_get_view_poses(struct xrt_device *xdev, 132 134 const struct xrt_vec3 *default_eye_relation, 133 135 int64_t at_timestamp_ns, 136 + enum xrt_view_type view_type, 134 137 uint32_t view_count, 135 138 struct xrt_space_relation *out_head_relation, 136 139 struct xrt_fov *out_fovs, ··· 148 151 ich->device_id, // 149 152 default_eye_relation, // 150 153 at_timestamp_ns, // 154 + view_type, // 151 155 view_count, // 152 156 &info); // 153 157 IPC_CHK_AND_RET(ich->ipc_c, xret, "ipc_call_device_get_view_poses_2"); ··· 164 168 ich, // 165 169 default_eye_relation, // 166 170 at_timestamp_ns, // 171 + view_type, // 167 172 view_count, // 168 173 out_head_relation, // 169 174 out_fovs, //
+5
src/xrt/ipc/server/ipc_server_handler.c
··· 2045 2045 uint32_t id, 2046 2046 const struct xrt_vec3 *fallback_eye_relation, 2047 2047 int64_t at_timestamp_ns, 2048 + enum xrt_view_type view_type, 2048 2049 uint32_t view_count) 2049 2050 { 2050 2051 struct ipc_message_channel *imc = (struct ipc_message_channel *)&ics->imc; ··· 2074 2075 xdev, // 2075 2076 fallback_eye_relation, // 2076 2077 at_timestamp_ns, // 2078 + view_type, // 2077 2079 view_count, // 2078 2080 &reply.head_relation, // 2079 2081 fovs, // ··· 2119 2121 uint32_t id, 2120 2122 const struct xrt_vec3 *default_eye_relation, 2121 2123 int64_t at_timestamp_ns, 2124 + enum xrt_view_type view_type, 2122 2125 uint32_t view_count, 2123 2126 struct ipc_info_get_view_poses_2 *out_info) 2124 2127 { ··· 2126 2129 uint32_t device_id = id; 2127 2130 struct xrt_device *xdev = NULL; 2128 2131 GET_XDEV_OR_RETURN(ics, device_id, xdev); 2132 + 2129 2133 return xrt_device_get_view_poses( // 2130 2134 xdev, // 2131 2135 default_eye_relation, // 2132 2136 at_timestamp_ns, // 2137 + view_type, // 2133 2138 view_count, // 2134 2139 &out_info->head_relation, // 2135 2140 out_info->fovs, //
+2
src/xrt/ipc/shared/proto.json
··· 438 438 {"name": "id", "type": "uint32_t"}, 439 439 {"name": "fallback_eye_relation", "type": "struct xrt_vec3"}, 440 440 {"name": "at_timestamp_ns", "type": "int64_t"}, 441 + {"name": "view_type", "type": "enum xrt_view_type"}, 441 442 {"name": "view_count", "type": "uint32_t"} 442 443 ], 443 444 "out": [ ··· 451 452 {"name": "id", "type": "uint32_t"}, 452 453 {"name": "fallback_eye_relation", "type": "struct xrt_vec3"}, 453 454 {"name": "at_timestamp_ns", "type": "int64_t"}, 455 + {"name": "view_type", "type": "enum xrt_view_type"}, 454 456 {"name": "view_count", "type": "uint32_t"} 455 457 ], 456 458 "out": [
+3
src/xrt/state_trackers/oxr/oxr_session.c
··· 690 690 struct xrt_fov fovs[XRT_MAX_VIEWS] = {0}; 691 691 struct xrt_pose poses[XRT_MAX_VIEWS] = {0}; 692 692 693 + enum xrt_view_type view_type = view_count == 1 ? XRT_VIEW_TYPE_MONO : XRT_VIEW_TYPE_STEREO; 694 + 693 695 xrt_result_t xret = xrt_device_get_view_poses( // 694 696 xdev, // 695 697 &default_eye_relation, // 696 698 xdisplay_time, // 699 + view_type, // 697 700 view_count, // 698 701 &T_xdev_head, // 699 702 fovs, //
+2 -1
src/xrt/state_trackers/steamvr_drv/ovrd_driver.cpp
··· 1108 1108 1109 1109 //! @todo more than 2 views 1110 1110 struct xrt_space_relation head_relation; 1111 - xrt_device_get_view_poses(xdev, &ipd_vec, now_ns, 2, &head_relation, m_fovs, m_view_pose); 1111 + xrt_device_get_view_poses(xdev, &ipd_vec, now_ns, XRT_VIEW_TYPE_STEREO, 2, &head_relation, m_fovs, 1112 + m_view_pose); 1112 1113 1113 1114 //! @todo more versatile IPD calculation 1114 1115 float actual_ipd = -m_view_pose[0].position.x + m_view_pose[1].position.x;