xrt: Constify compositor interface

This commit is contained in:
Jakob Bornecrantz 2020-08-26 12:43:33 +01:00
parent 777add8f9e
commit 1496262564
7 changed files with 79 additions and 71 deletions

View file

@ -82,8 +82,8 @@ client_gl_swapchain_release_image(struct xrt_swapchain *xsc, uint32_t index)
*/
static xrt_result_t
client_gl_compositor_prepare_session(struct xrt_compositor *xc,
struct xrt_session_prepare_info *xspi)
client_gl_compositor_prepare_session(
struct xrt_compositor *xc, const struct xrt_session_prepare_info *xspi)
{
struct client_gl_compositor *c = client_gl_compositor(xc);
@ -158,7 +158,7 @@ client_gl_compositor_layer_stereo_projection(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *l_xsc,
struct xrt_swapchain *r_xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
struct client_gl_compositor *c = client_gl_compositor(xc);
struct xrt_swapchain *l_xscn, *r_xscn;
@ -167,10 +167,12 @@ client_gl_compositor_layer_stereo_projection(struct xrt_compositor *xc,
l_xscn = &client_gl_swapchain(l_xsc)->xscn->base;
r_xscn = &client_gl_swapchain(r_xsc)->xscn->base;
data->flip_y = true;
struct xrt_layer_data d = *data;
d.flip_y = !d.flip_y;
return xrt_comp_layer_stereo_projection(&c->xcn->base, xdev, l_xscn,
r_xscn, data);
r_xscn, &d);
}
static xrt_result_t
@ -181,7 +183,7 @@ client_gl_compositor_layer_stereo_projection_depth(
struct xrt_swapchain *r_xsc,
struct xrt_swapchain *l_d_xsc,
struct xrt_swapchain *r_d_xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
struct client_gl_compositor *c = client_gl_compositor(xc);
struct xrt_swapchain *l_xscn, *r_xscn, *l_d_xscn, *r_d_xscn;
@ -192,17 +194,19 @@ client_gl_compositor_layer_stereo_projection_depth(
r_xscn = &client_gl_swapchain(r_xsc)->xscn->base;
l_d_xscn = &client_gl_swapchain(l_d_xsc)->xscn->base;
r_d_xscn = &client_gl_swapchain(r_d_xsc)->xscn->base;
data->flip_y = true;
struct xrt_layer_data d = *data;
d.flip_y = !d.flip_y;
return xrt_comp_layer_stereo_projection_depth(
&c->xcn->base, xdev, l_xscn, r_xscn, l_d_xscn, r_d_xscn, data);
&c->xcn->base, xdev, l_xscn, r_xscn, l_d_xscn, r_d_xscn, &d);
}
static xrt_result_t
client_gl_compositor_layer_quad(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
struct client_gl_compositor *c = client_gl_compositor(xc);
struct xrt_swapchain *xscfb;
@ -210,16 +214,18 @@ client_gl_compositor_layer_quad(struct xrt_compositor *xc,
assert(data->type == XRT_LAYER_QUAD);
xscfb = &client_gl_swapchain(xsc)->xscn->base;
data->flip_y = true;
return xrt_comp_layer_quad(&c->xcn->base, xdev, xscfb, data);
struct xrt_layer_data d = *data;
d.flip_y = !d.flip_y;
return xrt_comp_layer_quad(&c->xcn->base, xdev, xscfb, &d);
}
static xrt_result_t
client_gl_compositor_layer_cube(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
struct client_gl_compositor *c = client_gl_compositor(xc);
struct xrt_swapchain *xscfb;
@ -227,16 +233,18 @@ client_gl_compositor_layer_cube(struct xrt_compositor *xc,
assert(data->type == XRT_LAYER_CUBE);
xscfb = &client_gl_swapchain(xsc)->xscn->base;
data->flip_y = true;
return xrt_comp_layer_cube(&c->xcn->base, xdev, xscfb, data);
struct xrt_layer_data d = *data;
d.flip_y = !d.flip_y;
return xrt_comp_layer_cube(&c->xcn->base, xdev, xscfb, &d);
}
static xrt_result_t
client_gl_compositor_layer_cylinder(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
struct client_gl_compositor *c = client_gl_compositor(xc);
struct xrt_swapchain *xscfb;
@ -244,16 +252,18 @@ client_gl_compositor_layer_cylinder(struct xrt_compositor *xc,
assert(data->type == XRT_LAYER_CYLINDER);
xscfb = &client_gl_swapchain(xsc)->xscn->base;
data->flip_y = true;
return xrt_comp_layer_cylinder(&c->xcn->base, xdev, xscfb, data);
struct xrt_layer_data d = *data;
d.flip_y = !d.flip_y;
return xrt_comp_layer_cylinder(&c->xcn->base, xdev, xscfb, &d);
}
static xrt_result_t
client_gl_compositor_layer_equirect(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
struct client_gl_compositor *c = client_gl_compositor(xc);
struct xrt_swapchain *xscfb;
@ -261,9 +271,11 @@ client_gl_compositor_layer_equirect(struct xrt_compositor *xc,
assert(data->type == XRT_LAYER_EQUIRECT);
xscfb = &client_gl_swapchain(xsc)->xscn->base;
data->flip_y = true;
return xrt_comp_layer_equirect(&c->xcn->base, xdev, xscfb, data);
struct xrt_layer_data d = *data;
d.flip_y = !d.flip_y;
return xrt_comp_layer_equirect(&c->xcn->base, xdev, xscfb, &d);
}
static xrt_result_t

View file

@ -169,8 +169,8 @@ client_vk_compositor_destroy(struct xrt_compositor *xc)
}
static xrt_result_t
client_vk_compositor_prepare_session(struct xrt_compositor *xc,
struct xrt_session_prepare_info *xspi)
client_vk_compositor_prepare_session(
struct xrt_compositor *xc, const struct xrt_session_prepare_info *xspi)
{
struct client_vk_compositor *c = client_vk_compositor(xc);
@ -244,7 +244,7 @@ client_vk_compositor_layer_stereo_projection(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *l_xsc,
struct xrt_swapchain *r_xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
struct client_vk_compositor *c = client_vk_compositor(xc);
struct xrt_swapchain *l_xscn, *r_xscn;
@ -253,7 +253,6 @@ client_vk_compositor_layer_stereo_projection(struct xrt_compositor *xc,
l_xscn = &client_vk_swapchain(l_xsc)->xscn->base;
r_xscn = &client_vk_swapchain(r_xsc)->xscn->base;
data->flip_y = false;
return xrt_comp_layer_stereo_projection(&c->xcn->base, xdev, l_xscn,
r_xscn, data);
@ -268,7 +267,7 @@ client_vk_compositor_layer_stereo_projection_depth(
struct xrt_swapchain *r_xsc,
struct xrt_swapchain *l_d_xsc,
struct xrt_swapchain *r_d_xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
struct client_vk_compositor *c = client_vk_compositor(xc);
struct xrt_swapchain *l_xscn, *r_xscn, *l_d_xscn, *r_d_xscn;
@ -279,7 +278,6 @@ client_vk_compositor_layer_stereo_projection_depth(
r_xscn = &client_vk_swapchain(r_xsc)->xscn->base;
l_d_xscn = &client_vk_swapchain(l_d_xsc)->xscn->base;
r_d_xscn = &client_vk_swapchain(r_d_xsc)->xscn->base;
data->flip_y = false;
return xrt_comp_layer_stereo_projection_depth(
&c->xcn->base, xdev, l_xscn, r_xscn, l_d_xscn, r_d_xscn, data);
@ -289,7 +287,7 @@ static xrt_result_t
client_vk_compositor_layer_quad(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
struct client_vk_compositor *c = client_vk_compositor(xc);
struct xrt_swapchain *xscfb;
@ -297,7 +295,6 @@ client_vk_compositor_layer_quad(struct xrt_compositor *xc,
assert(data->type == XRT_LAYER_QUAD);
xscfb = &client_vk_swapchain(xsc)->xscn->base;
data->flip_y = false;
return xrt_comp_layer_quad(&c->xcn->base, xdev, xscfb, data);
}
@ -306,7 +303,7 @@ static xrt_result_t
client_vk_compositor_layer_cube(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
struct client_vk_compositor *c = client_vk_compositor(xc);
struct xrt_swapchain *xscfb;
@ -314,7 +311,6 @@ client_vk_compositor_layer_cube(struct xrt_compositor *xc,
assert(data->type == XRT_LAYER_CUBE);
xscfb = &client_vk_swapchain(xsc)->xscn->base;
data->flip_y = false;
return xrt_comp_layer_cube(&c->xcn->base, xdev, xscfb, data);
}
@ -323,7 +319,7 @@ static xrt_result_t
client_vk_compositor_layer_cylinder(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
struct client_vk_compositor *c = client_vk_compositor(xc);
struct xrt_swapchain *xscfb;
@ -331,7 +327,6 @@ client_vk_compositor_layer_cylinder(struct xrt_compositor *xc,
assert(data->type == XRT_LAYER_CYLINDER);
xscfb = &client_vk_swapchain(xsc)->xscn->base;
data->flip_y = false;
return xrt_comp_layer_cylinder(&c->xcn->base, xdev, xscfb, data);
}
@ -340,7 +335,7 @@ static xrt_result_t
client_vk_compositor_layer_equirect(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
struct client_vk_compositor *c = client_vk_compositor(xc);
struct xrt_swapchain *xscfb;
@ -348,7 +343,6 @@ client_vk_compositor_layer_equirect(struct xrt_compositor *xc,
assert(data->type == XRT_LAYER_EQUIRECT);
xscfb = &client_vk_swapchain(xsc)->xscn->base;
data->flip_y = false;
return xrt_comp_layer_equirect(&c->xcn->base, xdev, xscfb, data);
}

View file

@ -112,7 +112,7 @@ compositor_destroy(struct xrt_compositor *xc)
static xrt_result_t
compositor_prepare_session(struct xrt_compositor *xc,
struct xrt_session_prepare_info *xspi)
const struct xrt_session_prepare_info *xspi)
{
struct comp_compositor *c = comp_compositor(xc);
COMP_DEBUG(c, "PREPARE_SESSION");
@ -322,7 +322,7 @@ compositor_layer_stereo_projection(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *l_xsc,
struct xrt_swapchain *r_xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
struct comp_compositor *c = comp_compositor(xc);
@ -346,7 +346,7 @@ compositor_layer_stereo_projection_depth(struct xrt_compositor *xc,
struct xrt_swapchain *r_xsc,
struct xrt_swapchain *l_d_xsc,
struct xrt_swapchain *r_d_xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
struct comp_compositor *c = comp_compositor(xc);
@ -367,7 +367,7 @@ static xrt_result_t
do_single(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
struct comp_compositor *c = comp_compositor(xc);
@ -388,7 +388,7 @@ static xrt_result_t
compositor_layer_quad(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
return do_single(xc, xdev, xsc, data);
}
@ -397,7 +397,7 @@ static xrt_result_t
compositor_layer_cube(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
#if 0
return do_single(xc, xdev, xsc, data);
@ -410,7 +410,7 @@ static xrt_result_t
compositor_layer_cylinder(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
return do_single(xc, xdev, xsc, data);
}
@ -419,7 +419,7 @@ static xrt_result_t
compositor_layer_equirect(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
#if 0
return do_single(xc, xdev, xsc, data);

View file

@ -582,8 +582,9 @@ struct xrt_compositor
/*!
* This function is implicit in the OpenXR spec but made explicit here.
*/
xrt_result_t (*prepare_session)(struct xrt_compositor *xc,
struct xrt_session_prepare_info *xspi);
xrt_result_t (*prepare_session)(
struct xrt_compositor *xc,
const struct xrt_session_prepare_info *xspi);
/*!
* See xrBeginSession.
@ -648,11 +649,12 @@ struct xrt_compositor
* @param r_xsc Right swapchain.
* @param data All of the pure data bits.
*/
xrt_result_t (*layer_stereo_projection)(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *l_xsc,
struct xrt_swapchain *r_xsc,
struct xrt_layer_data *data);
xrt_result_t (*layer_stereo_projection)(
struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *l_xsc,
struct xrt_swapchain *r_xsc,
const struct xrt_layer_data *data);
/*!
* Adds a stereo projection layer for submission, has depth information.
@ -672,7 +674,7 @@ struct xrt_compositor
struct xrt_swapchain *r_xsc,
struct xrt_swapchain *l_d_xsc,
struct xrt_swapchain *r_d_xsc,
struct xrt_layer_data *data);
const struct xrt_layer_data *data);
/*!
* Adds a quad layer for submission, the center of the quad is specified
@ -686,7 +688,7 @@ struct xrt_compositor
xrt_result_t (*layer_quad)(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data);
const struct xrt_layer_data *data);
/*!
* Adds a cube layer for submission.
@ -699,7 +701,7 @@ struct xrt_compositor
xrt_result_t (*layer_cube)(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data);
const struct xrt_layer_data *data);
/*!
* Adds a cylinder layer for submission.
@ -712,7 +714,7 @@ struct xrt_compositor
xrt_result_t (*layer_cylinder)(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data);
const struct xrt_layer_data *data);
/*!
* Adds a equirect layer for submission.
@ -725,7 +727,7 @@ struct xrt_compositor
xrt_result_t (*layer_equirect)(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data);
const struct xrt_layer_data *data);
/*!
* Commits all of the submitted layers, it's from this on that the
@ -799,7 +801,7 @@ xrt_comp_poll_events(struct xrt_compositor *xc,
*/
static inline xrt_result_t
xrt_comp_prepare_session(struct xrt_compositor *xc,
struct xrt_session_prepare_info *xspi)
const struct xrt_session_prepare_info *xspi)
{
return xc->prepare_session(xc, xspi);
}
@ -900,7 +902,7 @@ xrt_comp_layer_stereo_projection(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *l_xsc,
struct xrt_swapchain *r_xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
return xc->layer_stereo_projection(xc, xdev, l_xsc, r_xsc, data);
}
@ -919,7 +921,7 @@ xrt_comp_layer_stereo_projection_depth(struct xrt_compositor *xc,
struct xrt_swapchain *r_xsc,
struct xrt_swapchain *l_d_xsc,
struct xrt_swapchain *r_d_xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
return xc->layer_stereo_projection_depth(xc, xdev, l_xsc, r_xsc,
l_d_xsc, r_d_xsc, data);
@ -936,7 +938,7 @@ static inline xrt_result_t
xrt_comp_layer_quad(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
return xc->layer_quad(xc, xdev, xsc, data);
}
@ -952,7 +954,7 @@ static inline xrt_result_t
xrt_comp_layer_cube(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
return xc->layer_cube(xc, xdev, xsc, data);
}
@ -968,7 +970,7 @@ static inline xrt_result_t
xrt_comp_layer_cylinder(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
return xc->layer_cylinder(xc, xdev, xsc, data);
}
@ -984,7 +986,7 @@ static inline xrt_result_t
xrt_comp_layer_equirect(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
return xc->layer_equirect(xc, xdev, xsc, data);
}

View file

@ -341,7 +341,7 @@ ipc_compositor_swapchain_import(struct xrt_compositor *xc,
static xrt_result_t
ipc_compositor_prepare_session(struct xrt_compositor *xc,
struct xrt_session_prepare_info *xspi)
const struct xrt_session_prepare_info *xspi)
{
struct ipc_client_compositor *icc = ipc_client_compositor(xc);
@ -476,7 +476,7 @@ ipc_compositor_layer_stereo_projection(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *l_xsc,
struct xrt_swapchain *r_xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
struct ipc_client_compositor *icc = ipc_client_compositor(xc);
@ -508,7 +508,7 @@ ipc_compositor_layer_stereo_projection_depth(struct xrt_compositor *xc,
struct xrt_swapchain *r_xsc,
struct xrt_swapchain *l_d_xsc,
struct xrt_swapchain *r_d_xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
struct ipc_client_compositor *icc = ipc_client_compositor(xc);
@ -539,7 +539,7 @@ static xrt_result_t
handle_layer(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data,
const struct xrt_layer_data *data,
enum xrt_layer_type type)
{
struct ipc_client_compositor *icc = ipc_client_compositor(xc);
@ -568,7 +568,7 @@ static xrt_result_t
ipc_compositor_layer_quad(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
return handle_layer(xc, xdev, xsc, data, XRT_LAYER_QUAD);
}
@ -577,7 +577,7 @@ static xrt_result_t
ipc_compositor_layer_cube(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
return handle_layer(xc, xdev, xsc, data, XRT_LAYER_CUBE);
}
@ -586,7 +586,7 @@ static xrt_result_t
ipc_compositor_layer_cylinder(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
return handle_layer(xc, xdev, xsc, data, XRT_LAYER_CYLINDER);
}
@ -595,7 +595,7 @@ static xrt_result_t
ipc_compositor_layer_equirect(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *xsc,
struct xrt_layer_data *data)
const struct xrt_layer_data *data)
{
return handle_layer(xc, xdev, xsc, data, XRT_LAYER_EQUIRECT);
}

View file

@ -92,7 +92,7 @@ ipc_handle_instance_get_shm_fd(volatile struct ipc_client_state *ics,
}
xrt_result_t
ipc_handle_session_create(volatile struct ipc_client_state *ics,
struct xrt_session_prepare_info *xspi)
const struct xrt_session_prepare_info *xspi)
{
ics->client_state.session_active = false;
ics->client_state.session_overlay = false;

View file

@ -40,7 +40,7 @@
"session_create": {
"in": [
{"name": "overlay_info", "type": "struct xrt_session_prepare_info"}
{"name": "overlay_info", "type": "const struct xrt_session_prepare_info"}
]
},