mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-28 18:46:18 +00:00
ipc: Add support for XR_FB_passthrough
This commit is contained in:
parent
6c03327253
commit
c066774dca
|
@ -424,6 +424,36 @@ ipc_compositor_swapchain_create(struct xrt_compositor *xc,
|
|||
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
|
||||
ipc_compositor_swapchain_import(struct xrt_compositor *xc,
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
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.import_swapchain = ipc_compositor_swapchain_import;
|
||||
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.end_session = ipc_compositor_end_session;
|
||||
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_equirect1 = ipc_compositor_layer_equirect1;
|
||||
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_with_semaphore = ipc_compositor_layer_commit_with_semaphore;
|
||||
icc->base.base.destroy = ipc_compositor_destroy;
|
||||
|
|
|
@ -934,6 +934,30 @@ _update_equirect2_layer(struct xrt_compositor *xc,
|
|||
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
|
||||
_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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -1099,6 +1128,46 @@ ipc_handle_compositor_layer_sync_with_semaphore(volatile struct ipc_client_state
|
|||
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
|
||||
ipc_handle_compositor_set_thread_hint(volatile struct ipc_client_state *ics,
|
||||
enum xrt_thread_hint hint,
|
||||
|
|
|
@ -266,6 +266,20 @@
|
|||
"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": {
|
||||
"in": [
|
||||
{"name": "info", "type": "struct xrt_swapchain_create_info"},
|
||||
|
|
Loading…
Reference in a new issue