ipc+comp: Even more make layers the same

This commit is contained in:
Jakob Bornecrantz 2020-06-09 18:22:29 +01:00 committed by Jakob Bornecrantz
parent 08d81e5950
commit 5912964ded
5 changed files with 106 additions and 81 deletions

View file

@ -319,16 +319,18 @@ compositor_layer_stereo_projection(struct xrt_compositor *xc,
uint32_t layer_id = c->slots[slot_id].num_layers;
struct comp_layer *layer = &c->slots[slot_id].layers[layer_id];
layer->stereo.l.sc = comp_swapchain(l_sc);
layer->stereo.l.image_index = l_image_index;
layer->stereo.l.array_index = l_array_index;
layer->stereo.r.sc = comp_swapchain(r_sc);
layer->stereo.r.image_index = r_image_index;
layer->stereo.r.array_index = r_array_index;
struct comp_layer_data *data = &layer->data;
layer->scs[0] = comp_swapchain(l_sc);
layer->scs[1] = comp_swapchain(r_sc);
layer->flags = layer_flags;
layer->flip_y = flip_y;
layer->type = XRT_LAYER_STEREO_PROJECTION;
data->stereo.l.image_index = l_image_index;
data->stereo.l.array_index = l_array_index;
data->stereo.r.image_index = r_image_index;
data->stereo.r.array_index = r_array_index;
data->flags = layer_flags;
data->flip_y = flip_y;
data->type = XRT_LAYER_STEREO_PROJECTION;
c->slots[slot_id].num_layers++;
return XRT_SUCCESS;
@ -356,17 +358,20 @@ compositor_layer_quad(struct xrt_compositor *xc,
uint32_t layer_id = c->slots[slot_id].num_layers;
struct comp_layer *layer = &c->slots[slot_id].layers[layer_id];
layer->quad.sc = comp_swapchain(sc);
layer->quad.visibility = visibility;
layer->quad.image_index = image_index;
layer->quad.rect = *rect;
layer->quad.array_index = array_index;
layer->quad.pose = *pose;
layer->quad.size = *size;
struct comp_layer_data *data = &layer->data;
layer->scs[0] = comp_swapchain(sc);
layer->scs[0] = NULL;
layer->flags = layer_flags;
layer->flip_y = flip_y;
layer->type = XRT_LAYER_QUAD;
data->quad.visibility = visibility;
data->quad.image_index = image_index;
data->quad.rect = *rect;
data->quad.array_index = array_index;
data->quad.pose = *pose;
data->quad.size = *size;
data->flags = layer_flags;
data->flip_y = flip_y;
data->type = XRT_LAYER_QUAD;
c->slots[slot_id].num_layers++;
return XRT_SUCCESS;
@ -388,24 +393,25 @@ compositor_layer_commit(struct xrt_compositor *xc)
for (uint32_t i = 0; i < num_layers; i++) {
struct comp_layer *layer = &c->slots[slot_id].layers[i];
switch (layer->type) {
struct comp_layer_data *data = &layer->data;
switch (data->type) {
case XRT_LAYER_QUAD: {
struct comp_layer_quad *quad = &layer->quad;
struct comp_layer_quad *quad = &layer->data.quad;
struct comp_swapchain_image *image;
image = &quad->sc->images[quad->image_index];
image = &layer->scs[0]->images[quad->image_index];
comp_renderer_set_quad_layer(c->r, image, &quad->pose,
&quad->size, layer->flip_y,
&quad->size, data->flip_y,
i, quad->array_index);
} break;
case XRT_LAYER_STEREO_PROJECTION: {
struct comp_layer_stereo *stereo = &layer->stereo;
struct comp_layer_stereo *stereo = &data->stereo;
struct comp_swapchain_image *right;
struct comp_swapchain_image *left;
left = &stereo->l.sc->images[stereo->l.image_index];
right = &stereo->l.sc->images[stereo->r.image_index];
left = &layer->scs[0]->images[stereo->l.image_index];
right = &layer->scs[1]->images[stereo->r.image_index];
comp_renderer_set_projection_layer(
c->r, left, right, layer->flip_y, i,
c->r, left, right, data->flip_y, i,
stereo->l.array_index, stereo->r.array_index);
} break;
}

View file

@ -86,12 +86,11 @@ struct comp_swapchain
*/
struct comp_layer_quad
{
struct comp_swapchain *sc;
enum xrt_layer_eye_visibility visibility;
uint32_t image_index;
uint32_t array_index;
enum xrt_layer_eye_visibility visibility;
struct xrt_rect rect;
struct xrt_pose pose;
struct xrt_vec2 size;
@ -107,12 +106,25 @@ struct comp_layer_stereo
{
struct
{
struct comp_swapchain *sc;
uint32_t image_index;
uint32_t array_index;
} l, r;
};
struct comp_layer_data
{
enum xrt_layer_type type;
enum xrt_layer_composition_flags flags;
int64_t timestamp;
bool flip_y;
union {
struct comp_layer_quad quad;
struct comp_layer_stereo stereo;
};
};
/*!
* A single layer.
*
@ -121,14 +133,9 @@ struct comp_layer_stereo
*/
struct comp_layer
{
int64_t timestamp;
enum xrt_layer_composition_flags flags;
enum xrt_layer_type type;
bool flip_y;
union {
struct comp_layer_quad quad;
struct comp_layer_stereo stereo;
};
struct comp_swapchain *scs[2];
struct comp_layer_data data;
};
/*!

View file

@ -364,30 +364,32 @@ ipc_compositor_layer_stereo_projection(
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_layer_stereo_projection *stereo = &layer->stereo;
struct ipc_layer_data *data = &layer->data;
struct ipc_layer_stereo_projection *stereo = &data->stereo;
struct ipc_client_swapchain *l = ipc_client_swapchain(l_sc);
struct ipc_client_swapchain *r = ipc_client_swapchain(r_sc);
stereo->l.swapchain_id = l->id;
layer->xdev_id = 0; //! @todo Real id.
layer->swapchain_ids[0] = l->id;
layer->swapchain_ids[1] = r->id;
data->type = XRT_LAYER_STEREO_PROJECTION;
data->name = name;
data->timestamp = timestamp;
data->flags = layer_flags;
data->flip_y = flip_y;
stereo->l.image_index = l_image_index;
stereo->l.rect = *l_rect;
stereo->l.array_index = l_array_index;
stereo->l.fov = *l_fov;
stereo->l.pose = *l_pose;
stereo->r.swapchain_id = r->id;
stereo->r.image_index = r_image_index;
stereo->r.rect = *r_rect;
stereo->r.array_index = r_array_index;
stereo->r.fov = *r_fov;
stereo->r.pose = *r_pose;
layer->xdev_id = 0; //! @todo Real id.
layer->name = name;
layer->timestamp = timestamp;
layer->layer_flags = layer_flags;
layer->flip_y = flip_y;
layer->type = XRT_LAYER_STEREO_PROJECTION;
// Increment the number of layers.
icc->layers.num_layers++;
@ -414,23 +416,26 @@ ipc_compositor_layer_quad(struct xrt_compositor *xc,
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_layer_quad *quad = &layer->quad;
struct ipc_layer_data *data = &layer->data;
struct ipc_layer_quad *quad = &data->quad;
struct ipc_client_swapchain *ics = ipc_client_swapchain(sc);
quad->swapchain_id = ics->id;
layer->xdev_id = 0; //! @todo Real id.
layer->swapchain_ids[0] = ics->id;
layer->swapchain_ids[1] = -1;
data->type = XRT_LAYER_QUAD;
data->name = name;
data->timestamp = timestamp;
data->flags = layer_flags;
data->flip_y = flip_y;
quad->image_index = image_index;
quad->rect = *rect;
quad->array_index = array_index;
quad->pose = *pose;
quad->size = *size;
layer->xdev_id = 0; //! @todo Real id.
layer->name = name;
layer->timestamp = timestamp;
layer->layer_flags = layer_flags;
layer->flip_y = flip_y;
layer->type = XRT_LAYER_QUAD;
// Increment the number of layers.
icc->layers.num_layers++;

View file

@ -77,7 +77,6 @@ struct ipc_layer_stereo_projection
{
struct
{
uint32_t swapchain_id;
uint32_t image_index;
uint32_t array_index;
@ -89,7 +88,7 @@ struct ipc_layer_stereo_projection
struct ipc_layer_quad
{
uint32_t swapchain_id;
enum xrt_layer_eye_visibility visibility;
uint32_t image_index;
uint32_t array_index;
@ -99,14 +98,12 @@ struct ipc_layer_quad
struct xrt_vec2 size;
};
struct ipc_layer_entry
struct ipc_layer_data
{
uint64_t timestamp;
uint32_t xdev_id;
enum xrt_input_name name;
enum xrt_layer_composition_flags layer_flags;
enum xrt_layer_type type;
enum xrt_input_name name;
uint64_t timestamp;
enum xrt_layer_composition_flags flags;
bool flip_y;
union {
@ -115,6 +112,14 @@ struct ipc_layer_entry
};
};
struct ipc_layer_entry
{
uint32_t xdev_id;
uint32_t swapchain_ids[2];
struct ipc_layer_data data;
};
struct ipc_layer_slot
{
enum xrt_blend_mode env_blend_mode;

View file

@ -103,32 +103,34 @@ ipc_handle_compositor_layer_sync(volatile struct ipc_client_state *cs,
struct ipc_layer_slot *slot = &ism->slots[slot_id];
for (uint32_t i = 0; i < slot->num_layers; i++) {
cs->render_state.layers[i].type = slot->layers[i].type;
cs->render_state.layers[i].type = slot->layers[i].data.type;
struct ipc_layer_entry *sl = &slot->layers[i];
volatile struct ipc_layer_render_state *rl =
&cs->render_state.layers[i];
rl->flip_y = sl->flip_y;
rl->flip_y = sl->data.flip_y;
switch (slot->layers[i].type) {
switch (slot->layers[i].data.type) {
case XRT_LAYER_STEREO_PROJECTION:
rl->stereo.l.swapchain_index =
sl->stereo.l.swapchain_id;
rl->stereo.l.image_index = sl->stereo.l.image_index;
rl->stereo.r.swapchain_index =
sl->stereo.r.swapchain_id;
rl->stereo.r.image_index = sl->stereo.r.image_index;
rl->stereo.l.array_index = sl->stereo.l.array_index;
rl->stereo.r.array_index = sl->stereo.r.array_index;
rl->stereo.l.swapchain_index = sl->swapchain_ids[0];
rl->stereo.l.image_index =
sl->data.stereo.l.image_index;
rl->stereo.r.swapchain_index = sl->swapchain_ids[1];
rl->stereo.r.image_index =
sl->data.stereo.r.image_index;
rl->stereo.l.array_index =
sl->data.stereo.l.array_index;
rl->stereo.r.array_index =
sl->data.stereo.r.array_index;
break;
case XRT_LAYER_QUAD:
rl->quad.swapchain_index = sl->quad.swapchain_id;
rl->quad.image_index = sl->quad.image_index;
rl->quad.pose = sl->quad.pose;
rl->quad.size = sl->quad.size;
rl->quad.array_index = sl->quad.array_index;
rl->quad.swapchain_index = sl->swapchain_ids[0];
rl->quad.image_index = sl->data.quad.image_index;
rl->quad.pose = sl->data.quad.pose;
rl->quad.size = sl->data.quad.size;
rl->quad.array_index = sl->data.quad.array_index;
break;
}
}