The open source OpenXR runtime
0
fork

Configure Feed

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

ipc: Add get_visibility_mask

authored by

Simon Zeni and committed by
Jakob Bornecrantz
5656f86c 1ec26ded

+102
+9
src/xrt/ipc/client/ipc_client_device.c
··· 139 139 IPC_CHK_ONLY_PRINT(icd->ipc_c, xret, "ipc_call_device_set_output"); 140 140 } 141 141 142 + static void 143 + ipc_client_device_get_visibility_mask(struct xrt_device *xdev, 144 + enum xrt_visibility_mask_type type, 145 + struct xrt_visibility_mask **out_mask) 146 + { 147 + assert(false); 148 + } 149 + 142 150 /*! 143 151 * @public @memberof ipc_client_device 144 152 */ ··· 158 166 icd->base.get_hand_tracking = ipc_client_device_get_hand_tracking; 159 167 icd->base.get_view_poses = ipc_client_device_get_view_poses; 160 168 icd->base.set_output = ipc_client_device_set_output; 169 + icd->base.get_visibility_mask = ipc_client_device_get_visibility_mask; 161 170 icd->base.destroy = ipc_client_device_destroy; 162 171 163 172 // Start copying the information from the isdev.
+40
src/xrt/ipc/client/ipc_client_hmd.c
··· 252 252 return available; 253 253 } 254 254 255 + static void 256 + ipc_client_hmd_get_visibility_mask(struct xrt_device *xdev, 257 + enum xrt_visibility_mask_type type, 258 + struct xrt_visibility_mask **out_mask) 259 + { 260 + ipc_client_hmd_t *ich = ipc_client_hmd(xdev); 261 + struct ipc_connection *ipc_c = ich->ipc_c; 262 + struct xrt_visibility_mask *mask = NULL; 263 + xrt_result_t xret; 264 + 265 + ipc_client_connection_lock(ipc_c); 266 + 267 + xret = ipc_send_device_get_visibility_mask_locked(ipc_c, ich->device_id, type); 268 + IPC_CHK_WITH_GOTO(ipc_c, xret, "ipc_send_device_get_visibility_mask_locked", err_mask_unlock); 269 + 270 + uint32_t mask_size; 271 + xret = ipc_receive_device_get_visibility_mask_locked(ipc_c, &mask_size); 272 + IPC_CHK_WITH_GOTO(ipc_c, xret, "ipc_receive_device_get_visibility_mask_locked", err_mask_unlock); 273 + 274 + mask = U_CALLOC_WITH_CAST(struct xrt_visibility_mask, mask_size); 275 + if (mask == NULL) { 276 + IPC_ERROR(ich->ipc_c, "failed to allocate xrt_visibility_mask"); 277 + goto err_mask_unlock; 278 + } 279 + 280 + xret = ipc_receive(&ipc_c->imc, mask, mask_size); 281 + IPC_CHK_WITH_GOTO(ipc_c, xret, "ipc_receive", err_mask_free); 282 + 283 + *out_mask = mask; 284 + ipc_client_connection_unlock(ipc_c); 285 + 286 + return; 287 + 288 + err_mask_free: 289 + free(mask); 290 + err_mask_unlock: 291 + ipc_client_connection_unlock(ipc_c); 292 + } 293 + 255 294 /*! 256 295 * @public @memberof ipc_client_hmd 257 296 */ ··· 273 312 ich->base.compute_distortion = ipc_client_hmd_compute_distortion; 274 313 ich->base.destroy = ipc_client_hmd_destroy; 275 314 ich->base.is_form_factor_available = ipc_client_hmd_is_form_factor_available; 315 + ich->base.get_visibility_mask = ipc_client_hmd_get_visibility_mask; 276 316 277 317 // Start copying the information from the isdev. 278 318 ich->base.tracking_origin = xtrack;
+42
src/xrt/ipc/server/ipc_server_handler.c
··· 11 11 12 12 #include "util/u_misc.h" 13 13 #include "util/u_handles.h" 14 + #include "util/u_visibility_mask.h" 14 15 #include "util/u_trace_marker.h" 15 16 16 17 #include "server/ipc_server.h" ··· 1554 1555 1555 1556 // Set the output. 1556 1557 xrt_device_set_output(xdev, name, value); 1558 + 1559 + return XRT_SUCCESS; 1560 + } 1561 + 1562 + xrt_result_t 1563 + ipc_handle_device_get_visibility_mask(volatile struct ipc_client_state *ics, 1564 + uint32_t device_id, 1565 + enum xrt_visibility_mask_type type) 1566 + { 1567 + struct ipc_message_channel *imc = (struct ipc_message_channel *)&ics->imc; 1568 + struct ipc_device_get_visibility_mask_reply reply = XRT_STRUCT_INIT; 1569 + struct ipc_server *s = ics->server; 1570 + xrt_result_t xret; 1571 + 1572 + // @todo verify 1573 + struct xrt_device *xdev = get_xdev(ics, device_id); 1574 + struct xrt_visibility_mask *mask = NULL; 1575 + if (xdev->get_visibility_mask) { 1576 + xdev->get_visibility_mask(xdev, type, &mask); 1577 + } else { 1578 + u_visibility_mask_get_default(type, &mask); 1579 + } 1580 + 1581 + if (mask == NULL) { 1582 + IPC_ERROR(s, "Failed to get visibility mask"); 1583 + reply.mask_size = 0; 1584 + } else { 1585 + reply.mask_size = xrt_visibility_mask_get_size(mask); 1586 + } 1587 + 1588 + xret = ipc_send(imc, &reply, sizeof(reply)); 1589 + if (xret != XRT_SUCCESS) { 1590 + IPC_ERROR(s, "Failed to send reply"); 1591 + return xret; 1592 + } 1593 + 1594 + xret = ipc_send(imc, mask, reply.mask_size); 1595 + if (xret != XRT_SUCCESS) { 1596 + IPC_ERROR(s, "Failed to send mask"); 1597 + return xret; 1598 + } 1557 1599 1558 1600 return XRT_SUCCESS; 1559 1601 }
+11
src/xrt/ipc/shared/proto.json
··· 354 354 ] 355 355 }, 356 356 357 + "device_get_visibility_mask": { 358 + "varlen": true, 359 + "in": [ 360 + {"name": "id", "type": "uint32_t"}, 361 + {"name": "type", "type": "enum xrt_visibility_mask_type"} 362 + ], 363 + "out": [ 364 + {"name": "mask_size", "type": "uint32_t"} 365 + ] 366 + }, 367 + 357 368 "device_is_form_factor_available": { 358 369 "in": [ 359 370 {"name": "id", "type": "uint32_t"},