mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 12:46:12 +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;
|
||||
};
|
||||
|
||||
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.
|
||||
*
|
||||
* @todo De-dupe with @ref ipc_layer_slot? has everything but rendering
|
||||
*
|
||||
* @ingroup ipc_server
|
||||
*/
|
||||
struct ipc_render_state
|
||||
|
@ -127,7 +97,7 @@ struct ipc_render_state
|
|||
bool rendering;
|
||||
enum xrt_blend_mode env_blend_mode;
|
||||
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];
|
||||
|
||||
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];
|
||||
volatile struct ipc_layer_render_state *rl =
|
||||
&cs->render_state.layers[i];
|
||||
|
||||
rl->flip_y = sl->data.flip_y;
|
||||
rl->data = sl->data;
|
||||
|
||||
switch (slot->layers[i].data.type) {
|
||||
case XRT_LAYER_STEREO_PROJECTION:
|
||||
rl->stereo.l.swapchain_index = sl->swapchain_ids[0];
|
||||
rl->stereo.l.sub = sl->data.stereo.l.sub;
|
||||
rl->swapchain_ids[0] = sl->swapchain_ids[0];
|
||||
|
||||
rl->stereo.r.swapchain_index = sl->swapchain_ids[1];
|
||||
rl->stereo.r.sub = sl->data.stereo.r.sub;
|
||||
rl->swapchain_ids[1] = sl->swapchain_ids[1];
|
||||
break;
|
||||
case XRT_LAYER_QUAD:
|
||||
rl->quad.swapchain_index = 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;
|
||||
rl->swapchain_ids[0] = sl->swapchain_ids[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -456,15 +449,18 @@ client_loop(volatile struct ipc_client_state *cs)
|
|||
volatile struct ipc_layer_render_state *rl =
|
||||
&cs->render_state.layers[i];
|
||||
|
||||
rl->flip_y = false;
|
||||
rl->stereo.l.swapchain_index = 0;
|
||||
rl->stereo.l.sub.image_index = 0;
|
||||
rl->stereo.r.swapchain_index = 0;
|
||||
rl->stereo.r.sub.image_index = 0;
|
||||
rl->quad.swapchain_index = 0;
|
||||
rl->quad.sub.image_index = 0;
|
||||
rl->swapchain_ids[0] = 0;
|
||||
rl->swapchain_ids[1] = 0;
|
||||
rl->data.flip_y = false;
|
||||
/*!
|
||||
* @todo this is redundant, we're setting both elements of a
|
||||
* union. Why?
|
||||
*/
|
||||
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.
|
||||
|
|
|
@ -520,8 +520,10 @@ _update_projection_layer(struct comp_compositor *c,
|
|||
volatile struct ipc_layer_render_state *layer,
|
||||
uint32_t i)
|
||||
{
|
||||
uint32_t lsi = layer->stereo.l.swapchain_index;
|
||||
uint32_t rsi = layer->stereo.r.swapchain_index;
|
||||
// left
|
||||
uint32_t lsi = layer->swapchain_ids[0];
|
||||
// right
|
||||
uint32_t rsi = layer->swapchain_ids[1];
|
||||
|
||||
if (active_client->xscs[lsi] == 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 *r = NULL;
|
||||
l = &cl->images[layer->stereo.l.sub.image_index];
|
||||
r = &cr->images[layer->stereo.r.sub.image_index];
|
||||
l = &cl->images[layer->data.stereo.l.sub.image_index];
|
||||
r = &cr->images[layer->data.stereo.r.sub.image_index];
|
||||
|
||||
//! @todo we are ignoring subrect here!
|
||||
comp_renderer_set_projection_layer(c->r, l, r, layer->flip_y, i,
|
||||
layer->stereo.l.sub.array_index,
|
||||
layer->stereo.r.sub.array_index);
|
||||
// (and perhaps can simplify by re-using some structs?)
|
||||
comp_renderer_set_projection_layer(
|
||||
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;
|
||||
}
|
||||
|
@ -552,7 +556,7 @@ _update_quad_layer(struct comp_compositor *c,
|
|||
volatile struct ipc_layer_render_state *layer,
|
||||
uint32_t i)
|
||||
{
|
||||
uint32_t sci = layer->quad.swapchain_index;
|
||||
uint32_t sci = layer->swapchain_ids[0];
|
||||
|
||||
if (active_client->xscs[sci] == NULL) {
|
||||
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_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_vec2 size = layer->quad.size;
|
||||
struct xrt_pose pose = layer->data.quad.pose;
|
||||
struct xrt_vec2 size = layer->data.quad.size;
|
||||
|
||||
//! @todo we are ignoring subrect here!
|
||||
comp_renderer_set_quad_layer(c->r, image, &pose, &size, layer->flip_y,
|
||||
i, layer->quad.sub.array_index);
|
||||
// (and perhaps can simplify by re-using some structs?)
|
||||
comp_renderer_set_quad_layer(c->r, image, &pose, &size,
|
||||
layer->data.flip_y, i,
|
||||
layer->data.quad.sub.array_index);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -591,7 +597,7 @@ _update_layers(struct comp_compositor *c,
|
|||
for (uint32_t i = 0; i < render_state->num_layers; i++) {
|
||||
volatile struct ipc_layer_render_state *layer =
|
||||
&render_state->layers[i];
|
||||
switch (layer->type) {
|
||||
switch (layer->data.type) {
|
||||
case XRT_LAYER_STEREO_PROJECTION: {
|
||||
if (!_update_projection_layer(c, active_client, layer,
|
||||
i))
|
||||
|
|
Loading…
Reference in a new issue