mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-02-03 12:28:07 +00:00
ipc: Further de-duplication of structures
This commit is contained in:
parent
b6b5052d48
commit
1881bb6357
|
@ -85,21 +85,6 @@ struct ipc_swapchain_data
|
|||
bool active;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Render state for a client.
|
||||
*
|
||||
* @todo De-dupe with @ref ipc_layer_slot? has everything but rendering
|
||||
*
|
||||
* @ingroup ipc_server
|
||||
*/
|
||||
struct ipc_render_state
|
||||
{
|
||||
bool rendering;
|
||||
enum xrt_blend_mode env_blend_mode;
|
||||
uint32_t num_layers;
|
||||
struct ipc_layer_entry layers[IPC_MAX_LAYERS];
|
||||
};
|
||||
|
||||
/*!
|
||||
* Holds the state for a single client.
|
||||
*
|
||||
|
@ -126,7 +111,10 @@ struct ipc_client_state
|
|||
int ipc_socket_fd;
|
||||
|
||||
//! State for rendering.
|
||||
struct ipc_render_state render_state;
|
||||
struct ipc_layer_slot render_state;
|
||||
|
||||
//! Whether we are currently rendering @ref render_state
|
||||
bool rendering_state;
|
||||
|
||||
bool active;
|
||||
};
|
||||
|
|
|
@ -102,27 +102,17 @@ ipc_handle_compositor_layer_sync(volatile struct ipc_client_state *cs,
|
|||
struct ipc_shared_memory *ism = cs->server->ism;
|
||||
struct ipc_layer_slot *slot = &ism->slots[slot_id];
|
||||
|
||||
//! @todo big copy instead of this sparse copy?
|
||||
for (uint32_t i = 0; i < slot->num_layers; i++) {
|
||||
struct ipc_layer_entry *sl = &slot->layers[i];
|
||||
volatile struct ipc_layer_render_state *rl =
|
||||
volatile struct ipc_layer_entry *rl =
|
||||
&cs->render_state.layers[i];
|
||||
|
||||
rl->data = sl->data;
|
||||
|
||||
switch (slot->layers[i].data.type) {
|
||||
case XRT_LAYER_STEREO_PROJECTION:
|
||||
rl->swapchain_ids[0] = sl->swapchain_ids[0];
|
||||
|
||||
rl->swapchain_ids[1] = sl->swapchain_ids[1];
|
||||
break;
|
||||
case XRT_LAYER_QUAD:
|
||||
rl->swapchain_ids[0] = sl->swapchain_ids[0];
|
||||
break;
|
||||
}
|
||||
*rl = *sl;
|
||||
}
|
||||
|
||||
cs->render_state.num_layers = slot->num_layers;
|
||||
cs->render_state.rendering = true;
|
||||
cs->rendering_state = true;
|
||||
|
||||
*out_free_slot_id = (slot_id + 1) % IPC_MAX_SLOTS;
|
||||
|
||||
|
@ -443,10 +433,10 @@ client_loop(volatile struct ipc_client_state *cs)
|
|||
cs->num_swapchains = 0;
|
||||
|
||||
// Make sure to reset the renderstate fully.
|
||||
cs->rendering_state = false;
|
||||
cs->render_state.num_layers = 0;
|
||||
cs->render_state.rendering = false;
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(cs->render_state.layers); ++i) {
|
||||
volatile struct ipc_layer_render_state *rl =
|
||||
volatile struct ipc_layer_entry *rl =
|
||||
&cs->render_state.layers[i];
|
||||
|
||||
rl->swapchain_ids[0] = 0;
|
||||
|
@ -454,7 +444,7 @@ client_loop(volatile struct ipc_client_state *cs)
|
|||
rl->data.flip_y = false;
|
||||
/*!
|
||||
* @todo this is redundant, we're setting both elements of a
|
||||
* union. Why?
|
||||
* union. Why? Can we just zero the whole render_state?
|
||||
*/
|
||||
rl->data.stereo.l.sub.image_index = 0;
|
||||
rl->data.stereo.r.sub.image_index = 0;
|
||||
|
|
|
@ -517,7 +517,7 @@ check_epoll(struct ipc_server *vs)
|
|||
static bool
|
||||
_update_projection_layer(struct comp_compositor *c,
|
||||
volatile struct ipc_client_state *active_client,
|
||||
volatile struct ipc_layer_render_state *layer,
|
||||
volatile struct ipc_layer_entry *layer,
|
||||
uint32_t i)
|
||||
{
|
||||
// left
|
||||
|
@ -553,7 +553,7 @@ _update_projection_layer(struct comp_compositor *c,
|
|||
static bool
|
||||
_update_quad_layer(struct comp_compositor *c,
|
||||
volatile struct ipc_client_state *active_client,
|
||||
volatile struct ipc_layer_render_state *layer,
|
||||
volatile struct ipc_layer_entry *layer,
|
||||
uint32_t i)
|
||||
{
|
||||
uint32_t sci = layer->swapchain_ids[0];
|
||||
|
@ -584,7 +584,7 @@ _update_layers(struct comp_compositor *c,
|
|||
volatile struct ipc_client_state *active_client,
|
||||
uint32_t *num_layers)
|
||||
{
|
||||
volatile struct ipc_render_state *render_state =
|
||||
volatile struct ipc_layer_slot *render_state =
|
||||
&active_client->render_state;
|
||||
|
||||
if (*num_layers != render_state->num_layers) {
|
||||
|
@ -595,7 +595,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 =
|
||||
volatile struct ipc_layer_entry *layer =
|
||||
&render_state->layers[i];
|
||||
switch (layer->data.type) {
|
||||
case XRT_LAYER_STEREO_PROJECTION: {
|
||||
|
@ -659,16 +659,13 @@ main_loop(struct ipc_server *vs)
|
|||
// swapchain indices and toggle wait to false
|
||||
// when the client calls end_frame, signalling
|
||||
// us to render.
|
||||
volatile struct ipc_render_state *render_state =
|
||||
&active_client->render_state;
|
||||
|
||||
if (render_state->rendering) {
|
||||
if (active_client->rendering_state) {
|
||||
if (!_update_layers(c, active_client,
|
||||
&num_layers))
|
||||
continue;
|
||||
|
||||
// set our client state back to waiting.
|
||||
render_state->rendering = false;
|
||||
active_client->rendering_state = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue