ipc: Add support for XR_FB_passthrough

This commit is contained in:
dengkail 2024-02-29 11:16:17 +08:00
parent 6c03327253
commit c066774dca
3 changed files with 137 additions and 0 deletions

View file

@ -424,6 +424,36 @@ ipc_compositor_swapchain_create(struct xrt_compositor *xc,
return xret; return xret;
} }
static xrt_result_t
ipc_compositor_create_passthrough(struct xrt_compositor *xc, const struct xrt_passthrough_create_info *info)
{
struct ipc_client_compositor *icc = ipc_client_compositor(xc);
xrt_result_t xret;
xret = ipc_call_compositor_create_passthrough(icc->ipc_c, info);
IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_compositor_create_passthrough");
}
static xrt_result_t
ipc_compositor_create_passthrough_layer(struct xrt_compositor *xc, const struct xrt_passthrough_layer_create_info *info)
{
struct ipc_client_compositor *icc = ipc_client_compositor(xc);
xrt_result_t xret;
xret = ipc_call_compositor_create_passthrough_layer(icc->ipc_c, info);
IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_compositor_create_passthrough_layer");
}
static xrt_result_t
ipc_compositor_destroy_passthrough(struct xrt_compositor *xc)
{
struct ipc_client_compositor *icc = ipc_client_compositor(xc);
xrt_result_t xret;
xret = ipc_call_compositor_destroy_passthrough(icc->ipc_c);
IPC_CHK_ALWAYS_RET(icc->ipc_c, xret, "ipc_call_compositor_destroy_passthrough");
}
static xrt_result_t static xrt_result_t
ipc_compositor_swapchain_import(struct xrt_compositor *xc, ipc_compositor_swapchain_import(struct xrt_compositor *xc,
const struct xrt_swapchain_create_info *info, const struct xrt_swapchain_create_info *info,
@ -688,6 +718,26 @@ ipc_compositor_layer_equirect2(struct xrt_compositor *xc,
return handle_layer(xc, xdev, xsc, data, XRT_LAYER_EQUIRECT2); return handle_layer(xc, xdev, xsc, data, XRT_LAYER_EQUIRECT2);
} }
static xrt_result_t
ipc_compositor_layer_passthrough(struct xrt_compositor *xc, struct xrt_device *xdev, const struct xrt_layer_data *data)
{
struct ipc_client_compositor *icc = ipc_client_compositor(xc);
assert(data->type == XRT_LAYER_PASSTHROUGH);
struct ipc_shared_memory *ism = icc->ipc_c->ism;
struct ipc_layer_slot *slot = &ism->slots[icc->layers.slot_id];
struct ipc_layer_entry *layer = &slot->layers[icc->layers.layer_count];
layer->xdev_id = 0; //! @todo Real id.
layer->data = *data;
// Increment the number of layers.
icc->layers.layer_count++;
return XRT_SUCCESS;
}
static xrt_result_t static xrt_result_t
ipc_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle) ipc_compositor_layer_commit(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle)
{ {
@ -830,6 +880,9 @@ ipc_compositor_init(struct ipc_client_compositor *icc, struct xrt_compositor_nat
icc->base.base.create_swapchain = ipc_compositor_swapchain_create; icc->base.base.create_swapchain = ipc_compositor_swapchain_create;
icc->base.base.import_swapchain = ipc_compositor_swapchain_import; icc->base.base.import_swapchain = ipc_compositor_swapchain_import;
icc->base.base.create_semaphore = ipc_compositor_semaphore_create; icc->base.base.create_semaphore = ipc_compositor_semaphore_create;
icc->base.base.create_passthrough = ipc_compositor_create_passthrough;
icc->base.base.create_passthrough_layer = ipc_compositor_create_passthrough_layer;
icc->base.base.destroy_passthrough = ipc_compositor_destroy_passthrough;
icc->base.base.begin_session = ipc_compositor_begin_session; icc->base.base.begin_session = ipc_compositor_begin_session;
icc->base.base.end_session = ipc_compositor_end_session; icc->base.base.end_session = ipc_compositor_end_session;
icc->base.base.wait_frame = ipc_compositor_wait_frame; icc->base.base.wait_frame = ipc_compositor_wait_frame;
@ -843,6 +896,7 @@ ipc_compositor_init(struct ipc_client_compositor *icc, struct xrt_compositor_nat
icc->base.base.layer_cylinder = ipc_compositor_layer_cylinder; icc->base.base.layer_cylinder = ipc_compositor_layer_cylinder;
icc->base.base.layer_equirect1 = ipc_compositor_layer_equirect1; icc->base.base.layer_equirect1 = ipc_compositor_layer_equirect1;
icc->base.base.layer_equirect2 = ipc_compositor_layer_equirect2; icc->base.base.layer_equirect2 = ipc_compositor_layer_equirect2;
icc->base.base.layer_passthrough = ipc_compositor_layer_passthrough;
icc->base.base.layer_commit = ipc_compositor_layer_commit; icc->base.base.layer_commit = ipc_compositor_layer_commit;
icc->base.base.layer_commit_with_semaphore = ipc_compositor_layer_commit_with_semaphore; icc->base.base.layer_commit_with_semaphore = ipc_compositor_layer_commit_with_semaphore;
icc->base.base.destroy = ipc_compositor_destroy; icc->base.base.destroy = ipc_compositor_destroy;

View file

@ -934,6 +934,30 @@ _update_equirect2_layer(struct xrt_compositor *xc,
return true; return true;
} }
static bool
_update_passthrough_layer(struct xrt_compositor *xc,
volatile struct ipc_client_state *ics,
volatile struct ipc_layer_entry *layer,
uint32_t i)
{
// xdev
uint32_t xdevi = layer->xdev_id;
struct xrt_device *xdev = get_xdev(ics, xdevi);
if (xdev == NULL) {
U_LOG_E("Invalid xdev for passthrough layer #%u!", i);
return false;
}
// Cast away volatile.
struct xrt_layer_data *data = (struct xrt_layer_data *)&layer->data;
xrt_comp_layer_passthrough(xc, xdev, data);
return true;
}
static bool static bool
_update_layers(volatile struct ipc_client_state *ics, struct xrt_compositor *xc, struct ipc_layer_slot *slot) _update_layers(volatile struct ipc_client_state *ics, struct xrt_compositor *xc, struct ipc_layer_slot *slot)
{ {
@ -978,6 +1002,11 @@ _update_layers(volatile struct ipc_client_state *ics, struct xrt_compositor *xc,
return false; return false;
} }
break; break;
case XRT_LAYER_PASSTHROUGH:
if (!_update_passthrough_layer(xc, ics, layer, i)) {
return false;
}
break;
default: U_LOG_E("Unhandled layer type '%i'!", layer->data.type); break; default: U_LOG_E("Unhandled layer type '%i'!", layer->data.type); break;
} }
} }
@ -1099,6 +1128,46 @@ ipc_handle_compositor_layer_sync_with_semaphore(volatile struct ipc_client_state
return XRT_SUCCESS; return XRT_SUCCESS;
} }
xrt_result_t
ipc_handle_compositor_create_passthrough(volatile struct ipc_client_state *ics,
const struct xrt_passthrough_create_info *info)
{
IPC_TRACE_MARKER();
if (ics->xc == NULL) {
return XRT_ERROR_IPC_SESSION_NOT_CREATED;
}
return xrt_comp_create_passthrough(ics->xc, info);
}
xrt_result_t
ipc_handle_compositor_create_passthrough_layer(volatile struct ipc_client_state *ics,
const struct xrt_passthrough_layer_create_info *info)
{
IPC_TRACE_MARKER();
if (ics->xc == NULL) {
return XRT_ERROR_IPC_SESSION_NOT_CREATED;
}
return xrt_comp_create_passthrough_layer(ics->xc, info);
}
xrt_result_t
ipc_handle_compositor_destroy_passthrough(volatile struct ipc_client_state *ics)
{
IPC_TRACE_MARKER();
if (ics->xc == NULL) {
return XRT_ERROR_IPC_SESSION_NOT_CREATED;
}
xrt_comp_destroy_passthrough(ics->xc);
return XRT_SUCCESS;
}
xrt_result_t xrt_result_t
ipc_handle_compositor_set_thread_hint(volatile struct ipc_client_state *ics, ipc_handle_compositor_set_thread_hint(volatile struct ipc_client_state *ics,
enum xrt_thread_hint hint, enum xrt_thread_hint hint,

View file

@ -266,6 +266,20 @@
"out_handles": {"type": "xrt_graphics_buffer_handle_t"} "out_handles": {"type": "xrt_graphics_buffer_handle_t"}
}, },
"compositor_create_passthrough": {
"in": [
{"name": "info", "type": "struct xrt_passthrough_create_info"}
]
},
"compositor_create_passthrough_layer": {
"in": [
{"name": "info", "type": "struct xrt_passthrough_layer_create_info"}
]
},
"compositor_destroy_passthrough": {},
"swapchain_import": { "swapchain_import": {
"in": [ "in": [
{"name": "info", "type": "struct xrt_swapchain_create_info"}, {"name": "info", "type": "struct xrt_swapchain_create_info"},