The open source OpenXR runtime

ipc: Add support for XR_FB_passthrough

dengkail c066774d 6c033272

+137
+54
src/xrt/ipc/client/ipc_client_compositor.c
··· 425 425 } 426 426 427 427 static xrt_result_t 428 + ipc_compositor_create_passthrough(struct xrt_compositor *xc, const struct xrt_passthrough_create_info *info) 429 + { 430 + struct ipc_client_compositor *icc = ipc_client_compositor(xc); 431 + xrt_result_t xret; 432 + 433 + xret = ipc_call_compositor_create_passthrough(icc->ipc_c, info); 434 + IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_compositor_create_passthrough"); 435 + } 436 + 437 + static xrt_result_t 438 + ipc_compositor_create_passthrough_layer(struct xrt_compositor *xc, const struct xrt_passthrough_layer_create_info *info) 439 + { 440 + struct ipc_client_compositor *icc = ipc_client_compositor(xc); 441 + xrt_result_t xret; 442 + 443 + xret = ipc_call_compositor_create_passthrough_layer(icc->ipc_c, info); 444 + IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_compositor_create_passthrough_layer"); 445 + } 446 + 447 + static xrt_result_t 448 + ipc_compositor_destroy_passthrough(struct xrt_compositor *xc) 449 + { 450 + struct ipc_client_compositor *icc = ipc_client_compositor(xc); 451 + xrt_result_t xret; 452 + 453 + xret = ipc_call_compositor_destroy_passthrough(icc->ipc_c); 454 + IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_compositor_destroy_passthrough"); 455 + } 456 + 457 + static xrt_result_t 428 458 ipc_compositor_swapchain_import(struct xrt_compositor *xc, 429 459 const struct xrt_swapchain_create_info *info, 430 460 struct xrt_image_native *native_images, ··· 689 719 } 690 720 691 721 static xrt_result_t 722 + ipc_compositor_layer_passthrough(struct xrt_compositor *xc, struct xrt_device *xdev, const struct xrt_layer_data *data) 723 + { 724 + struct ipc_client_compositor *icc = ipc_client_compositor(xc); 725 + 726 + assert(data->type == XRT_LAYER_PASSTHROUGH); 727 + 728 + struct ipc_shared_memory *ism = icc->ipc_c->ism; 729 + struct ipc_layer_slot *slot = &ism->slots[icc->layers.slot_id]; 730 + struct ipc_layer_entry *layer = &slot->layers[icc->layers.layer_count]; 731 + 732 + layer->xdev_id = 0; //! @todo Real id. 733 + layer->data = *data; 734 + 735 + // Increment the number of layers. 736 + icc->layers.layer_count++; 737 + 738 + return XRT_SUCCESS; 739 + } 740 + 741 + static xrt_result_t 692 742 ipc_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle) 693 743 { 694 744 struct ipc_client_compositor *icc = ipc_client_compositor(xc); ··· 830 880 icc->base.base.create_swapchain = ipc_compositor_swapchain_create; 831 881 icc->base.base.import_swapchain = ipc_compositor_swapchain_import; 832 882 icc->base.base.create_semaphore = ipc_compositor_semaphore_create; 883 + icc->base.base.create_passthrough = ipc_compositor_create_passthrough; 884 + icc->base.base.create_passthrough_layer = ipc_compositor_create_passthrough_layer; 885 + icc->base.base.destroy_passthrough = ipc_compositor_destroy_passthrough; 833 886 icc->base.base.begin_session = ipc_compositor_begin_session; 834 887 icc->base.base.end_session = ipc_compositor_end_session; 835 888 icc->base.base.wait_frame = ipc_compositor_wait_frame; ··· 843 896 icc->base.base.layer_cylinder = ipc_compositor_layer_cylinder; 844 897 icc->base.base.layer_equirect1 = ipc_compositor_layer_equirect1; 845 898 icc->base.base.layer_equirect2 = ipc_compositor_layer_equirect2; 899 + icc->base.base.layer_passthrough = ipc_compositor_layer_passthrough; 846 900 icc->base.base.layer_commit = ipc_compositor_layer_commit; 847 901 icc->base.base.layer_commit_with_semaphore = ipc_compositor_layer_commit_with_semaphore; 848 902 icc->base.base.destroy = ipc_compositor_destroy;
+69
src/xrt/ipc/server/ipc_server_handler.c
··· 935 935 } 936 936 937 937 static bool 938 + _update_passthrough_layer(struct xrt_compositor *xc, 939 + volatile struct ipc_client_state *ics, 940 + volatile struct ipc_layer_entry *layer, 941 + uint32_t i) 942 + { 943 + // xdev 944 + uint32_t xdevi = layer->xdev_id; 945 + 946 + struct xrt_device *xdev = get_xdev(ics, xdevi); 947 + 948 + if (xdev == NULL) { 949 + U_LOG_E("Invalid xdev for passthrough layer #%u!", i); 950 + return false; 951 + } 952 + 953 + // Cast away volatile. 954 + struct xrt_layer_data *data = (struct xrt_layer_data *)&layer->data; 955 + 956 + xrt_comp_layer_passthrough(xc, xdev, data); 957 + 958 + return true; 959 + } 960 + 961 + static bool 938 962 _update_layers(volatile struct ipc_client_state *ics, struct xrt_compositor *xc, struct ipc_layer_slot *slot) 939 963 { 940 964 IPC_TRACE_MARKER(); ··· 975 999 break; 976 1000 case XRT_LAYER_EQUIRECT2: 977 1001 if (!_update_equirect2_layer(xc, ics, layer, i)) { 1002 + return false; 1003 + } 1004 + break; 1005 + case XRT_LAYER_PASSTHROUGH: 1006 + if (!_update_passthrough_layer(xc, ics, layer, i)) { 978 1007 return false; 979 1008 } 980 1009 break; ··· 1095 1124 ics->server->current_slot_index = *out_free_slot_id; 1096 1125 1097 1126 os_mutex_unlock(&ics->server->global_state.lock); 1127 + 1128 + return XRT_SUCCESS; 1129 + } 1130 + 1131 + xrt_result_t 1132 + ipc_handle_compositor_create_passthrough(volatile struct ipc_client_state *ics, 1133 + const struct xrt_passthrough_create_info *info) 1134 + { 1135 + IPC_TRACE_MARKER(); 1136 + 1137 + if (ics->xc == NULL) { 1138 + return XRT_ERROR_IPC_SESSION_NOT_CREATED; 1139 + } 1140 + 1141 + return xrt_comp_create_passthrough(ics->xc, info); 1142 + } 1143 + 1144 + xrt_result_t 1145 + ipc_handle_compositor_create_passthrough_layer(volatile struct ipc_client_state *ics, 1146 + const struct xrt_passthrough_layer_create_info *info) 1147 + { 1148 + IPC_TRACE_MARKER(); 1149 + 1150 + if (ics->xc == NULL) { 1151 + return XRT_ERROR_IPC_SESSION_NOT_CREATED; 1152 + } 1153 + 1154 + return xrt_comp_create_passthrough_layer(ics->xc, info); 1155 + } 1156 + 1157 + xrt_result_t 1158 + ipc_handle_compositor_destroy_passthrough(volatile struct ipc_client_state *ics) 1159 + { 1160 + IPC_TRACE_MARKER(); 1161 + 1162 + if (ics->xc == NULL) { 1163 + return XRT_ERROR_IPC_SESSION_NOT_CREATED; 1164 + } 1165 + 1166 + xrt_comp_destroy_passthrough(ics->xc); 1098 1167 1099 1168 return XRT_SUCCESS; 1100 1169 }
+14
src/xrt/ipc/shared/proto.json
··· 266 266 "out_handles": {"type": "xrt_graphics_buffer_handle_t"} 267 267 }, 268 268 269 + "compositor_create_passthrough": { 270 + "in": [ 271 + {"name": "info", "type": "struct xrt_passthrough_create_info"} 272 + ] 273 + }, 274 + 275 + "compositor_create_passthrough_layer": { 276 + "in": [ 277 + {"name": "info", "type": "struct xrt_passthrough_layer_create_info"} 278 + ] 279 + }, 280 + 281 + "compositor_destroy_passthrough": {}, 282 + 269 283 "swapchain_import": { 270 284 "in": [ 271 285 {"name": "info", "type": "struct xrt_swapchain_create_info"},