tangled
alpha
login
or
join now
matrixfurry.com
/
monado
0
fork
atom
The open source OpenXR runtime
0
fork
atom
overview
issues
pulls
pipelines
ipc: Add support for XR_FB_passthrough
dengkail
2 years ago
c066774d
6c033272
+137
3 changed files
expand all
collapse all
unified
split
src
xrt
ipc
client
ipc_client_compositor.c
server
ipc_server_handler.c
shared
proto.json
+54
src/xrt/ipc/client/ipc_client_compositor.c
···
425
425
}
426
426
427
427
static xrt_result_t
428
428
+
ipc_compositor_create_passthrough(struct xrt_compositor *xc, const struct xrt_passthrough_create_info *info)
429
429
+
{
430
430
+
struct ipc_client_compositor *icc = ipc_client_compositor(xc);
431
431
+
xrt_result_t xret;
432
432
+
433
433
+
xret = ipc_call_compositor_create_passthrough(icc->ipc_c, info);
434
434
+
IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_compositor_create_passthrough");
435
435
+
}
436
436
+
437
437
+
static xrt_result_t
438
438
+
ipc_compositor_create_passthrough_layer(struct xrt_compositor *xc, const struct xrt_passthrough_layer_create_info *info)
439
439
+
{
440
440
+
struct ipc_client_compositor *icc = ipc_client_compositor(xc);
441
441
+
xrt_result_t xret;
442
442
+
443
443
+
xret = ipc_call_compositor_create_passthrough_layer(icc->ipc_c, info);
444
444
+
IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_compositor_create_passthrough_layer");
445
445
+
}
446
446
+
447
447
+
static xrt_result_t
448
448
+
ipc_compositor_destroy_passthrough(struct xrt_compositor *xc)
449
449
+
{
450
450
+
struct ipc_client_compositor *icc = ipc_client_compositor(xc);
451
451
+
xrt_result_t xret;
452
452
+
453
453
+
xret = ipc_call_compositor_destroy_passthrough(icc->ipc_c);
454
454
+
IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_compositor_destroy_passthrough");
455
455
+
}
456
456
+
457
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
722
+
ipc_compositor_layer_passthrough(struct xrt_compositor *xc, struct xrt_device *xdev, const struct xrt_layer_data *data)
723
723
+
{
724
724
+
struct ipc_client_compositor *icc = ipc_client_compositor(xc);
725
725
+
726
726
+
assert(data->type == XRT_LAYER_PASSTHROUGH);
727
727
+
728
728
+
struct ipc_shared_memory *ism = icc->ipc_c->ism;
729
729
+
struct ipc_layer_slot *slot = &ism->slots[icc->layers.slot_id];
730
730
+
struct ipc_layer_entry *layer = &slot->layers[icc->layers.layer_count];
731
731
+
732
732
+
layer->xdev_id = 0; //! @todo Real id.
733
733
+
layer->data = *data;
734
734
+
735
735
+
// Increment the number of layers.
736
736
+
icc->layers.layer_count++;
737
737
+
738
738
+
return XRT_SUCCESS;
739
739
+
}
740
740
+
741
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
883
+
icc->base.base.create_passthrough = ipc_compositor_create_passthrough;
884
884
+
icc->base.base.create_passthrough_layer = ipc_compositor_create_passthrough_layer;
885
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
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
938
+
_update_passthrough_layer(struct xrt_compositor *xc,
939
939
+
volatile struct ipc_client_state *ics,
940
940
+
volatile struct ipc_layer_entry *layer,
941
941
+
uint32_t i)
942
942
+
{
943
943
+
// xdev
944
944
+
uint32_t xdevi = layer->xdev_id;
945
945
+
946
946
+
struct xrt_device *xdev = get_xdev(ics, xdevi);
947
947
+
948
948
+
if (xdev == NULL) {
949
949
+
U_LOG_E("Invalid xdev for passthrough layer #%u!", i);
950
950
+
return false;
951
951
+
}
952
952
+
953
953
+
// Cast away volatile.
954
954
+
struct xrt_layer_data *data = (struct xrt_layer_data *)&layer->data;
955
955
+
956
956
+
xrt_comp_layer_passthrough(xc, xdev, data);
957
957
+
958
958
+
return true;
959
959
+
}
960
960
+
961
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
1002
+
return false;
1003
1003
+
}
1004
1004
+
break;
1005
1005
+
case XRT_LAYER_PASSTHROUGH:
1006
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
1127
+
1128
1128
+
return XRT_SUCCESS;
1129
1129
+
}
1130
1130
+
1131
1131
+
xrt_result_t
1132
1132
+
ipc_handle_compositor_create_passthrough(volatile struct ipc_client_state *ics,
1133
1133
+
const struct xrt_passthrough_create_info *info)
1134
1134
+
{
1135
1135
+
IPC_TRACE_MARKER();
1136
1136
+
1137
1137
+
if (ics->xc == NULL) {
1138
1138
+
return XRT_ERROR_IPC_SESSION_NOT_CREATED;
1139
1139
+
}
1140
1140
+
1141
1141
+
return xrt_comp_create_passthrough(ics->xc, info);
1142
1142
+
}
1143
1143
+
1144
1144
+
xrt_result_t
1145
1145
+
ipc_handle_compositor_create_passthrough_layer(volatile struct ipc_client_state *ics,
1146
1146
+
const struct xrt_passthrough_layer_create_info *info)
1147
1147
+
{
1148
1148
+
IPC_TRACE_MARKER();
1149
1149
+
1150
1150
+
if (ics->xc == NULL) {
1151
1151
+
return XRT_ERROR_IPC_SESSION_NOT_CREATED;
1152
1152
+
}
1153
1153
+
1154
1154
+
return xrt_comp_create_passthrough_layer(ics->xc, info);
1155
1155
+
}
1156
1156
+
1157
1157
+
xrt_result_t
1158
1158
+
ipc_handle_compositor_destroy_passthrough(volatile struct ipc_client_state *ics)
1159
1159
+
{
1160
1160
+
IPC_TRACE_MARKER();
1161
1161
+
1162
1162
+
if (ics->xc == NULL) {
1163
1163
+
return XRT_ERROR_IPC_SESSION_NOT_CREATED;
1164
1164
+
}
1165
1165
+
1166
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
269
+
"compositor_create_passthrough": {
270
270
+
"in": [
271
271
+
{"name": "info", "type": "struct xrt_passthrough_create_info"}
272
272
+
]
273
273
+
},
274
274
+
275
275
+
"compositor_create_passthrough_layer": {
276
276
+
"in": [
277
277
+
{"name": "info", "type": "struct xrt_passthrough_layer_create_info"}
278
278
+
]
279
279
+
},
280
280
+
281
281
+
"compositor_destroy_passthrough": {},
282
282
+
269
283
"swapchain_import": {
270
284
"in": [
271
285
{"name": "info", "type": "struct xrt_swapchain_create_info"},