mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-21 06:01:43 +00:00
ipc: Remove structs that effectively duplicate xrt_layer_data
The only non-duplicate members are the swapchain IDs, so store those in their own array as already done elsewhere in the codebase.
This commit is contained in:
parent
f407fb9461
commit
b6b5052d48
|
@ -85,41 +85,11 @@ struct ipc_swapchain_data
|
||||||
bool active;
|
bool active;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ipc_quad_render_state
|
|
||||||
{
|
|
||||||
uint32_t swapchain_index;
|
|
||||||
|
|
||||||
struct xrt_sub_image sub;
|
|
||||||
|
|
||||||
enum xrt_layer_eye_visibility visibility;
|
|
||||||
struct xrt_pose pose;
|
|
||||||
struct xrt_vec2 size;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ipc_stereo_projection_render_state
|
|
||||||
{
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
uint32_t swapchain_index;
|
|
||||||
struct xrt_sub_image sub;
|
|
||||||
} l, r;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ipc_layer_render_state
|
|
||||||
{
|
|
||||||
enum xrt_layer_composition_flags flags;
|
|
||||||
enum xrt_layer_type type;
|
|
||||||
bool flip_y;
|
|
||||||
|
|
||||||
union {
|
|
||||||
struct ipc_quad_render_state quad;
|
|
||||||
struct ipc_stereo_projection_render_state stereo;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Render state for a client.
|
* Render state for a client.
|
||||||
*
|
*
|
||||||
|
* @todo De-dupe with @ref ipc_layer_slot? has everything but rendering
|
||||||
|
*
|
||||||
* @ingroup ipc_server
|
* @ingroup ipc_server
|
||||||
*/
|
*/
|
||||||
struct ipc_render_state
|
struct ipc_render_state
|
||||||
|
@ -127,7 +97,7 @@ struct ipc_render_state
|
||||||
bool rendering;
|
bool rendering;
|
||||||
enum xrt_blend_mode env_blend_mode;
|
enum xrt_blend_mode env_blend_mode;
|
||||||
uint32_t num_layers;
|
uint32_t num_layers;
|
||||||
struct ipc_layer_render_state layers[IPC_MAX_LAYERS];
|
struct ipc_layer_entry layers[IPC_MAX_LAYERS];
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -103,27 +103,20 @@ ipc_handle_compositor_layer_sync(volatile struct ipc_client_state *cs,
|
||||||
struct ipc_layer_slot *slot = &ism->slots[slot_id];
|
struct ipc_layer_slot *slot = &ism->slots[slot_id];
|
||||||
|
|
||||||
for (uint32_t i = 0; i < slot->num_layers; i++) {
|
for (uint32_t i = 0; i < slot->num_layers; i++) {
|
||||||
cs->render_state.layers[i].type = slot->layers[i].data.type;
|
|
||||||
|
|
||||||
struct ipc_layer_entry *sl = &slot->layers[i];
|
struct ipc_layer_entry *sl = &slot->layers[i];
|
||||||
volatile struct ipc_layer_render_state *rl =
|
volatile struct ipc_layer_render_state *rl =
|
||||||
&cs->render_state.layers[i];
|
&cs->render_state.layers[i];
|
||||||
|
|
||||||
rl->flip_y = sl->data.flip_y;
|
rl->data = sl->data;
|
||||||
|
|
||||||
switch (slot->layers[i].data.type) {
|
switch (slot->layers[i].data.type) {
|
||||||
case XRT_LAYER_STEREO_PROJECTION:
|
case XRT_LAYER_STEREO_PROJECTION:
|
||||||
rl->stereo.l.swapchain_index = sl->swapchain_ids[0];
|
rl->swapchain_ids[0] = sl->swapchain_ids[0];
|
||||||
rl->stereo.l.sub = sl->data.stereo.l.sub;
|
|
||||||
|
|
||||||
rl->stereo.r.swapchain_index = sl->swapchain_ids[1];
|
rl->swapchain_ids[1] = sl->swapchain_ids[1];
|
||||||
rl->stereo.r.sub = sl->data.stereo.r.sub;
|
|
||||||
break;
|
break;
|
||||||
case XRT_LAYER_QUAD:
|
case XRT_LAYER_QUAD:
|
||||||
rl->quad.swapchain_index = sl->swapchain_ids[0];
|
rl->swapchain_ids[0] = sl->swapchain_ids[0];
|
||||||
rl->quad.sub = sl->data.quad.sub;
|
|
||||||
rl->quad.pose = sl->data.quad.pose;
|
|
||||||
rl->quad.size = sl->data.quad.size;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -456,15 +449,18 @@ client_loop(volatile struct ipc_client_state *cs)
|
||||||
volatile struct ipc_layer_render_state *rl =
|
volatile struct ipc_layer_render_state *rl =
|
||||||
&cs->render_state.layers[i];
|
&cs->render_state.layers[i];
|
||||||
|
|
||||||
rl->flip_y = false;
|
rl->swapchain_ids[0] = 0;
|
||||||
rl->stereo.l.swapchain_index = 0;
|
rl->swapchain_ids[1] = 0;
|
||||||
rl->stereo.l.sub.image_index = 0;
|
rl->data.flip_y = false;
|
||||||
rl->stereo.r.swapchain_index = 0;
|
/*!
|
||||||
rl->stereo.r.sub.image_index = 0;
|
* @todo this is redundant, we're setting both elements of a
|
||||||
rl->quad.swapchain_index = 0;
|
* union. Why?
|
||||||
rl->quad.sub.image_index = 0;
|
*/
|
||||||
|
rl->data.stereo.l.sub.image_index = 0;
|
||||||
|
rl->data.stereo.r.sub.image_index = 0;
|
||||||
|
rl->data.quad.sub.image_index = 0;
|
||||||
|
|
||||||
//! @todo set rects?
|
//! @todo set rects or array index?
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destroy all swapchains now.
|
// Destroy all swapchains now.
|
||||||
|
|
|
@ -520,8 +520,10 @@ _update_projection_layer(struct comp_compositor *c,
|
||||||
volatile struct ipc_layer_render_state *layer,
|
volatile struct ipc_layer_render_state *layer,
|
||||||
uint32_t i)
|
uint32_t i)
|
||||||
{
|
{
|
||||||
uint32_t lsi = layer->stereo.l.swapchain_index;
|
// left
|
||||||
uint32_t rsi = layer->stereo.r.swapchain_index;
|
uint32_t lsi = layer->swapchain_ids[0];
|
||||||
|
// right
|
||||||
|
uint32_t rsi = layer->swapchain_ids[1];
|
||||||
|
|
||||||
if (active_client->xscs[lsi] == NULL ||
|
if (active_client->xscs[lsi] == NULL ||
|
||||||
active_client->xscs[rsi] == NULL) {
|
active_client->xscs[rsi] == NULL) {
|
||||||
|
@ -535,13 +537,15 @@ _update_projection_layer(struct comp_compositor *c,
|
||||||
|
|
||||||
struct comp_swapchain_image *l = NULL;
|
struct comp_swapchain_image *l = NULL;
|
||||||
struct comp_swapchain_image *r = NULL;
|
struct comp_swapchain_image *r = NULL;
|
||||||
l = &cl->images[layer->stereo.l.sub.image_index];
|
l = &cl->images[layer->data.stereo.l.sub.image_index];
|
||||||
r = &cr->images[layer->stereo.r.sub.image_index];
|
r = &cr->images[layer->data.stereo.r.sub.image_index];
|
||||||
|
|
||||||
//! @todo we are ignoring subrect here!
|
//! @todo we are ignoring subrect here!
|
||||||
comp_renderer_set_projection_layer(c->r, l, r, layer->flip_y, i,
|
// (and perhaps can simplify by re-using some structs?)
|
||||||
layer->stereo.l.sub.array_index,
|
comp_renderer_set_projection_layer(
|
||||||
layer->stereo.r.sub.array_index);
|
c->r, l, r, layer->data.flip_y, i,
|
||||||
|
layer->data.stereo.l.sub.array_index,
|
||||||
|
layer->data.stereo.r.sub.array_index);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -552,7 +556,7 @@ _update_quad_layer(struct comp_compositor *c,
|
||||||
volatile struct ipc_layer_render_state *layer,
|
volatile struct ipc_layer_render_state *layer,
|
||||||
uint32_t i)
|
uint32_t i)
|
||||||
{
|
{
|
||||||
uint32_t sci = layer->quad.swapchain_index;
|
uint32_t sci = layer->swapchain_ids[0];
|
||||||
|
|
||||||
if (active_client->xscs[sci] == NULL) {
|
if (active_client->xscs[sci] == NULL) {
|
||||||
fprintf(stderr, "ERROR: Invalid swap chain for quad layer.\n");
|
fprintf(stderr, "ERROR: Invalid swap chain for quad layer.\n");
|
||||||
|
@ -561,14 +565,16 @@ _update_quad_layer(struct comp_compositor *c,
|
||||||
|
|
||||||
struct comp_swapchain *sc = comp_swapchain(active_client->xscs[sci]);
|
struct comp_swapchain *sc = comp_swapchain(active_client->xscs[sci]);
|
||||||
struct comp_swapchain_image *image = NULL;
|
struct comp_swapchain_image *image = NULL;
|
||||||
image = &sc->images[layer->quad.sub.image_index];
|
image = &sc->images[layer->data.quad.sub.image_index];
|
||||||
|
|
||||||
struct xrt_pose pose = layer->quad.pose;
|
struct xrt_pose pose = layer->data.quad.pose;
|
||||||
struct xrt_vec2 size = layer->quad.size;
|
struct xrt_vec2 size = layer->data.quad.size;
|
||||||
|
|
||||||
//! @todo we are ignoring subrect here!
|
//! @todo we are ignoring subrect here!
|
||||||
comp_renderer_set_quad_layer(c->r, image, &pose, &size, layer->flip_y,
|
// (and perhaps can simplify by re-using some structs?)
|
||||||
i, layer->quad.sub.array_index);
|
comp_renderer_set_quad_layer(c->r, image, &pose, &size,
|
||||||
|
layer->data.flip_y, i,
|
||||||
|
layer->data.quad.sub.array_index);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -591,7 +597,7 @@ _update_layers(struct comp_compositor *c,
|
||||||
for (uint32_t i = 0; i < render_state->num_layers; i++) {
|
for (uint32_t i = 0; i < render_state->num_layers; i++) {
|
||||||
volatile struct ipc_layer_render_state *layer =
|
volatile struct ipc_layer_render_state *layer =
|
||||||
&render_state->layers[i];
|
&render_state->layers[i];
|
||||||
switch (layer->type) {
|
switch (layer->data.type) {
|
||||||
case XRT_LAYER_STEREO_PROJECTION: {
|
case XRT_LAYER_STEREO_PROJECTION: {
|
||||||
if (!_update_projection_layer(c, active_client, layer,
|
if (!_update_projection_layer(c, active_client, layer,
|
||||||
i))
|
i))
|
||||||
|
|
Loading…
Reference in a new issue