ipc: Add support for depth projection

This commit is contained in:
Jakob Bornecrantz 2020-08-25 14:52:22 +01:00
parent 9bd725a800
commit efac59a1d8
3 changed files with 98 additions and 4 deletions

View file

@ -489,6 +489,42 @@ ipc_compositor_layer_stereo_projection(struct xrt_compositor *xc,
layer->xdev_id = 0; //! @todo Real id.
layer->swapchain_ids[0] = l->id;
layer->swapchain_ids[1] = r->id;
layer->swapchain_ids[2] = -1;
layer->swapchain_ids[3] = -1;
layer->data = *data;
// Increment the number of layers.
icc->layers.num_layers++;
return XRT_SUCCESS;
}
static xrt_result_t
ipc_compositor_layer_stereo_projection_depth(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *l_xsc,
struct xrt_swapchain *r_xsc,
struct xrt_swapchain *l_d_xsc,
struct xrt_swapchain *r_d_xsc,
struct xrt_layer_data *data)
{
struct ipc_client_compositor *icc = ipc_client_compositor(xc);
assert(data->type == XRT_LAYER_STEREO_PROJECTION_DEPTH);
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.num_layers];
struct ipc_client_swapchain *l = ipc_client_swapchain(l_xsc);
struct ipc_client_swapchain *r = ipc_client_swapchain(r_xsc);
struct ipc_client_swapchain *l_d = ipc_client_swapchain(l_d_xsc);
struct ipc_client_swapchain *r_d = ipc_client_swapchain(r_d_xsc);
layer->xdev_id = 0; //! @todo Real id.
layer->swapchain_ids[0] = l->id;
layer->swapchain_ids[1] = r->id;
layer->swapchain_ids[2] = l_d->id;
layer->swapchain_ids[3] = r_d->id;
layer->data = *data;
// Increment the number of layers.
@ -506,16 +542,18 @@ handle_layer(struct xrt_compositor *xc,
{
struct ipc_client_compositor *icc = ipc_client_compositor(xc);
assert(data->type == type);
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.num_layers];
struct ipc_client_swapchain *ics = ipc_client_swapchain(xsc);
assert(data->type == type);
layer->xdev_id = 0; //! @todo Real id.
layer->swapchain_ids[0] = ics->id;
layer->swapchain_ids[1] = -1;
layer->swapchain_ids[2] = -1;
layer->swapchain_ids[3] = -1;
layer->data = *data;
// Increment the number of layers.
@ -738,6 +776,8 @@ ipc_client_compositor_create(struct ipc_connection *ipc_c,
c->base.base.layer_begin = ipc_compositor_layer_begin;
c->base.base.layer_stereo_projection =
ipc_compositor_layer_stereo_projection;
c->base.base.layer_stereo_projection_depth =
ipc_compositor_layer_stereo_projection_depth;
c->base.base.layer_quad = ipc_compositor_layer_quad;
c->base.base.layer_cube = ipc_compositor_layer_cube;
c->base.base.layer_cylinder = ipc_compositor_layer_cylinder;

View file

@ -98,7 +98,7 @@ struct ipc_layer_entry
*
* How many are actually used depends on the value of @p data.type
*/
uint32_t swapchain_ids[2];
uint32_t swapchain_ids[4];
/*!
* All basic (trivially-serializable) data associated with a layer,

View file

@ -628,6 +628,50 @@ _update_projection_layer(struct xrt_compositor *xc,
return true;
}
static bool
_update_projection_layer_depth(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;
// left
uint32_t l_xsci = layer->swapchain_ids[0];
// right
uint32_t r_xsci = layer->swapchain_ids[1];
// left
uint32_t l_d_xsci = layer->swapchain_ids[2];
// right
uint32_t r_d_xsci = layer->swapchain_ids[3];
struct xrt_device *xdev = ics->server->xdevs[xdevi];
struct xrt_swapchain *l_xcs = ics->xscs[l_xsci];
struct xrt_swapchain *r_xcs = ics->xscs[r_xsci];
struct xrt_swapchain *l_d_xcs = ics->xscs[l_d_xsci];
struct xrt_swapchain *r_d_xcs = ics->xscs[r_d_xsci];
if (l_xcs == NULL || r_xcs == NULL || l_d_xcs == NULL ||
r_d_xcs == NULL) {
fprintf(stderr,
"ERROR: Invalid swap chain for projection layer.\n");
return false;
}
if (xdev == NULL) {
fprintf(stderr, "ERROR: Invalid xdev for projection layer.\n");
return false;
}
// Cast away volatile.
struct xrt_layer_data *data = (struct xrt_layer_data *)&layer->data;
xrt_comp_layer_stereo_projection_depth(xc, xdev, l_xcs, r_xcs, l_d_xcs,
r_d_xcs, data);
return true;
}
static bool
do_single(struct xrt_compositor *xc,
volatile struct ipc_client_state *ics,
@ -807,6 +851,12 @@ _update_layers(struct ipc_server *s, struct xrt_compositor *xc)
return false;
}
break;
case XRT_LAYER_STEREO_PROJECTION_DEPTH:
if (!_update_projection_layer_depth(xc, ics,
layer, i)) {
return false;
}
break;
case XRT_LAYER_QUAD:
if (!_update_quad_layer(xc, ics, layer, i)) {
return false;
@ -829,7 +879,11 @@ _update_layers(struct ipc_server *s, struct xrt_compositor *xc)
return false;
}
break;
default: break;
default:
fprintf(stderr,
"ERROR: Unhandled layer type '%i'!\n",
layer->data.type);
break;
}
}
}