xrt: Use new xrt_layer_data in layer functions

This commit is contained in:
Jakob Bornecrantz 2020-06-09 19:02:04 +01:00 committed by Jakob Bornecrantz
parent 320c9ab3cb
commit 55e026245a
6 changed files with 117 additions and 291 deletions

View file

@ -145,61 +145,40 @@ client_gl_compositor_layer_begin(struct xrt_compositor *xc,
}
static xrt_result_t
client_gl_compositor_layer_stereo_projection(
struct xrt_compositor *xc,
uint64_t timestamp,
struct xrt_device *xdev,
enum xrt_input_name name,
enum xrt_layer_composition_flags layer_flags,
struct xrt_swapchain *l_sc,
uint32_t l_image_index,
struct xrt_rect *l_rect,
uint32_t l_array_index,
struct xrt_fov *l_fov,
struct xrt_pose *l_pose,
struct xrt_swapchain *r_sc,
uint32_t r_image_index,
struct xrt_rect *r_rect,
uint32_t r_array_index,
struct xrt_fov *r_fov,
struct xrt_pose *r_pose,
bool flip_y)
client_gl_compositor_layer_stereo_projection(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *l_sc,
struct xrt_swapchain *r_sc,
struct xrt_layer_data *data)
{
struct client_gl_compositor *c = client_gl_compositor(xc);
struct xrt_swapchain *l_xscfd, *r_xscfd;
assert(data->type == XRT_LAYER_STEREO_PROJECTION);
l_xscfd = &client_gl_swapchain(l_sc)->xscfd->base;
r_xscfd = &client_gl_swapchain(r_sc)->xscfd->base;
data->flip_y = true;
return xrt_comp_layer_stereo_projection(
&c->xcfd->base, timestamp, xdev, name, layer_flags, l_xscfd,
l_image_index, l_rect, l_array_index, l_fov, l_pose, r_xscfd,
r_image_index, r_rect, r_array_index, r_fov, r_pose, true);
return xrt_comp_layer_stereo_projection(&c->xcfd->base, xdev, l_xscfd,
r_xscfd, data);
}
static xrt_result_t
client_gl_compositor_layer_quad(struct xrt_compositor *xc,
uint64_t timestamp,
struct xrt_device *xdev,
enum xrt_input_name name,
enum xrt_layer_composition_flags layer_flags,
enum xrt_layer_eye_visibility visibility,
struct xrt_swapchain *sc,
uint32_t image_index,
struct xrt_rect *rect,
uint32_t array_index,
struct xrt_pose *pose,
struct xrt_vec2 *size,
bool flip_y)
struct xrt_layer_data *data)
{
struct client_gl_compositor *c = client_gl_compositor(xc);
struct xrt_swapchain *xscfb;
xscfb = &client_gl_swapchain(sc)->xscfd->base;
assert(data->type == XRT_LAYER_QUAD);
return xrt_comp_layer_quad(&c->xcfd->base, timestamp, xdev, name,
layer_flags, visibility, xscfb, image_index,
rect, array_index, pose, size, true);
xscfb = &client_gl_swapchain(sc)->xscfd->base;
data->flip_y = true;
return xrt_comp_layer_quad(&c->xcfd->base, xdev, xscfb, data);
}
static xrt_result_t

View file

@ -8,13 +8,14 @@
* @ingroup comp_client
*/
#include <stdio.h>
#include <stdlib.h>
#include "util/u_misc.h"
#include "comp_vk_client.h"
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
/*!
* Down-cast helper.
*
@ -174,61 +175,40 @@ client_vk_compositor_layer_begin(struct xrt_compositor *xc,
}
static xrt_result_t
client_vk_compositor_layer_stereo_projection(
struct xrt_compositor *xc,
uint64_t timestamp,
struct xrt_device *xdev,
enum xrt_input_name name,
enum xrt_layer_composition_flags layer_flags,
struct xrt_swapchain *l_sc,
uint32_t l_image_index,
struct xrt_rect *l_rect,
uint32_t l_array_index,
struct xrt_fov *l_fov,
struct xrt_pose *l_pose,
struct xrt_swapchain *r_sc,
uint32_t r_image_index,
struct xrt_rect *r_rect,
uint32_t r_array_index,
struct xrt_fov *r_fov,
struct xrt_pose *r_pose,
bool flip_y)
client_vk_compositor_layer_stereo_projection(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *l_sc,
struct xrt_swapchain *r_sc,
struct xrt_layer_data *data)
{
struct client_vk_compositor *c = client_vk_compositor(xc);
struct xrt_swapchain *l_xscfd, *r_xscfd;
assert(data->type == XRT_LAYER_STEREO_PROJECTION);
l_xscfd = &client_vk_swapchain(l_sc)->xscfd->base;
r_xscfd = &client_vk_swapchain(r_sc)->xscfd->base;
data->flip_y = false;
return xrt_comp_layer_stereo_projection(
&c->xcfd->base, timestamp, xdev, name, layer_flags, l_xscfd,
l_image_index, l_rect, l_array_index, l_fov, l_pose, r_xscfd,
r_image_index, r_rect, r_array_index, r_fov, r_pose, false);
return xrt_comp_layer_stereo_projection(&c->xcfd->base, xdev, l_xscfd,
r_xscfd, data);
}
static xrt_result_t
client_vk_compositor_layer_quad(struct xrt_compositor *xc,
uint64_t timestamp,
struct xrt_device *xdev,
enum xrt_input_name name,
enum xrt_layer_composition_flags layer_flags,
enum xrt_layer_eye_visibility visibility,
struct xrt_swapchain *sc,
uint32_t image_index,
struct xrt_rect *rect,
uint32_t array_index,
struct xrt_pose *pose,
struct xrt_vec2 *size,
bool flip_y)
struct xrt_layer_data *data)
{
struct client_vk_compositor *c = client_vk_compositor(xc);
struct xrt_swapchain *xscfb;
xscfb = &client_vk_swapchain(sc)->xscfd->base;
assert(data->type == XRT_LAYER_QUAD);
return xrt_comp_layer_quad(&c->xcfd->base, timestamp, xdev, name,
layer_flags, visibility, xscfb, image_index,
rect, array_index, pose, size, false);
xscfb = &client_vk_swapchain(sc)->xscfd->base;
data->flip_y = false;
return xrt_comp_layer_quad(&c->xcfd->base, xdev, xscfb, data);
}
static xrt_result_t

View file

@ -294,23 +294,10 @@ compositor_layer_begin(struct xrt_compositor *xc,
static xrt_result_t
compositor_layer_stereo_projection(struct xrt_compositor *xc,
uint64_t timestamp,
struct xrt_device *xdev,
enum xrt_input_name name,
enum xrt_layer_composition_flags layer_flags,
struct xrt_swapchain *l_sc,
uint32_t l_image_index,
struct xrt_rect *l_rect,
uint32_t l_array_index,
struct xrt_fov *l_fov,
struct xrt_pose *l_pose,
struct xrt_swapchain *r_sc,
uint32_t r_image_index,
struct xrt_rect *r_rect,
uint32_t r_array_index,
struct xrt_fov *r_fov,
struct xrt_pose *r_pose,
bool flip_y)
struct xrt_layer_data *data)
{
struct comp_compositor *c = comp_compositor(xc);
@ -319,18 +306,9 @@ 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];
struct xrt_layer_data *data = &layer->data;
layer->scs[0] = comp_swapchain(l_sc);
layer->scs[1] = comp_swapchain(r_sc);
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;
layer->data = *data;
c->slots[slot_id].num_layers++;
return XRT_SUCCESS;
@ -338,18 +316,9 @@ compositor_layer_stereo_projection(struct xrt_compositor *xc,
static xrt_result_t
compositor_layer_quad(struct xrt_compositor *xc,
uint64_t timestamp,
struct xrt_device *xdev,
enum xrt_input_name name,
enum xrt_layer_composition_flags layer_flags,
enum xrt_layer_eye_visibility visibility,
struct xrt_swapchain *sc,
uint32_t image_index,
struct xrt_rect *rect,
uint32_t array_index,
struct xrt_pose *pose,
struct xrt_vec2 *size,
bool flip_y)
struct xrt_layer_data *data)
{
struct comp_compositor *c = comp_compositor(xc);
@ -358,20 +327,9 @@ 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];
struct xrt_layer_data *data = &layer->data;
layer->scs[0] = comp_swapchain(sc);
layer->scs[1] = NULL;
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;
layer->data = *data;
c->slots[slot_id].num_layers++;
return XRT_SUCCESS;

View file

@ -360,75 +360,30 @@ struct xrt_compositor
* Adds a stereo projection layer for submissions.
*
* @param xc Self pointer
* @param timestamp When should this layer be shown.
* @param xdev The device the layer is relative to.
* @param name Which pose this layer is relative to.
* @param layer_flags Flags for this layer, applied to both images.
* @param l_sc Left swapchain.
* @param l_image_index Left image index as return by acquire_image.
* @param l_rect Left subimage rect.
* @param l_array_index Left array index.
* @param l_fov Left fov the left projection rendered with.
* @param l_pose Left pose the left projection rendered with.
* @param r_sc Right swapchain.
* @param r_image_index Right image index as return by acquire_image.
* @param r_rect Right subimage rect.
* @param r_array_index Right array index.
* @param r_fov Right fov the left projection rendered with.
* @param r_pose Right pose the left projection rendered with.
* @param flip_y Flip Y texture coordinates.
* @param xdev The device the layer is relative to.
* @param l_sc Left swapchain.
* @param r_sc Right swapchain.
* @param data All of the pure data bits.
*/
xrt_result_t (*layer_stereo_projection)(
struct xrt_compositor *xc,
uint64_t timestamp,
struct xrt_device *xdev,
enum xrt_input_name name,
enum xrt_layer_composition_flags layer_flags,
struct xrt_swapchain *l_sc,
uint32_t l_image_index,
struct xrt_rect *l_rect,
uint32_t l_array_index,
struct xrt_fov *l_fov,
struct xrt_pose *l_pose,
struct xrt_swapchain *r_sc,
uint32_t r_image_index,
struct xrt_rect *r_rect,
uint32_t r_array_index,
struct xrt_fov *r_fov,
struct xrt_pose *r_pose,
bool flip_y);
xrt_result_t (*layer_stereo_projection)(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *l_sc,
struct xrt_swapchain *r_sc,
struct xrt_layer_data *data);
/*!
* Adds a quad layer for submission, the center of the quad is specified
* by the pose and extends outwards from it.
*
* @param xc Self pointer
* @param timestamp When should this layer be shown.
* @param xdev The device the layer is relative to.
* @param name Which pose this layer is relative to.
* @param layer_flags Flags for this layer.
* @param visibility Which views are is this layer visible in.
* @param sc Swapchain.
* @param image_index Image index as return by acquire_image.
* @param rect Subimage rect.
* @param array_index Array index.
* @param pose Pose the left projection rendered with.
* @param size Size of the quad in meters.
* @param flip_y Flip Y texture coordinates.
* @param data All of the pure data bits.
*/
xrt_result_t (*layer_quad)(struct xrt_compositor *xc,
uint64_t timestamp,
struct xrt_device *xdev,
enum xrt_input_name name,
enum xrt_layer_composition_flags layer_flags,
enum xrt_layer_eye_visibility visibility,
struct xrt_swapchain *sc,
uint32_t image_index,
struct xrt_rect *rect,
uint32_t array_index,
struct xrt_pose *pose,
struct xrt_vec2 *size,
bool flip_y);
struct xrt_layer_data *data);
/*!
* Commits all of the submitted layers, it's from this on that the
@ -586,28 +541,12 @@ xrt_comp_layer_begin(struct xrt_compositor *xc,
*/
static inline xrt_result_t
xrt_comp_layer_stereo_projection(struct xrt_compositor *xc,
uint64_t timestamp,
struct xrt_device *xdev,
enum xrt_input_name name,
enum xrt_layer_composition_flags layer_flags,
struct xrt_swapchain *l_sc,
uint32_t l_image_index,
struct xrt_rect *l_rect,
uint32_t l_array_index,
struct xrt_fov *l_fov,
struct xrt_pose *l_pose,
struct xrt_swapchain *r_sc,
uint32_t r_image_index,
struct xrt_rect *r_rect,
uint32_t r_array_index,
struct xrt_fov *r_fov,
struct xrt_pose *r_pose,
bool flip_y)
struct xrt_layer_data *data)
{
return xc->layer_stereo_projection(
xc, timestamp, xdev, name, layer_flags, l_sc, l_image_index, l_rect,
l_array_index, l_fov, l_pose, r_sc, r_image_index, r_rect,
r_array_index, r_fov, r_pose, flip_y);
return xc->layer_stereo_projection(xc, xdev, l_sc, r_sc, data);
}
/*!
@ -619,22 +558,11 @@ xrt_comp_layer_stereo_projection(struct xrt_compositor *xc,
*/
static inline xrt_result_t
xrt_comp_layer_quad(struct xrt_compositor *xc,
uint64_t timestamp,
struct xrt_device *xdev,
enum xrt_input_name name,
enum xrt_layer_composition_flags layer_flags,
enum xrt_layer_eye_visibility visibility,
struct xrt_swapchain *sc,
uint32_t image_index,
struct xrt_rect *rect,
uint32_t array_index,
struct xrt_pose *pose,
struct xrt_vec2 *size,
bool flip_y)
struct xrt_layer_data *data)
{
return xc->layer_quad(xc, timestamp, xdev, name, layer_flags,
visibility, sc, image_index, rect, array_index,
pose, size, flip_y);
return xc->layer_quad(xc, xdev, sc, data);
}
/*!

View file

@ -339,56 +339,24 @@ ipc_compositor_layer_begin(struct xrt_compositor *xc,
}
static xrt_result_t
ipc_compositor_layer_stereo_projection(
struct xrt_compositor *xc,
uint64_t timestamp,
struct xrt_device *xdev,
enum xrt_input_name name,
enum xrt_layer_composition_flags layer_flags,
struct xrt_swapchain *l_sc,
uint32_t l_image_index,
struct xrt_rect *l_rect,
uint32_t l_array_index,
struct xrt_fov *l_fov,
struct xrt_pose *l_pose,
struct xrt_swapchain *r_sc,
uint32_t r_image_index,
struct xrt_rect *r_rect,
uint32_t r_array_index,
struct xrt_fov *r_fov,
struct xrt_pose *r_pose,
bool flip_y)
ipc_compositor_layer_stereo_projection(struct xrt_compositor *xc,
struct xrt_device *xdev,
struct xrt_swapchain *l_sc,
struct xrt_swapchain *r_sc,
struct xrt_layer_data *data)
{
struct ipc_client_compositor *icc = ipc_client_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 xrt_layer_data *data = &layer->data;
struct xrt_layer_stereo_projection_data *stereo = &data->stereo;
struct ipc_client_swapchain *l = ipc_client_swapchain(l_sc);
struct ipc_client_swapchain *r = ipc_client_swapchain(r_sc);
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.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->data = *data;
// Increment the number of layers.
icc->layers.num_layers++;
@ -398,43 +366,23 @@ ipc_compositor_layer_stereo_projection(
static xrt_result_t
ipc_compositor_layer_quad(struct xrt_compositor *xc,
uint64_t timestamp,
struct xrt_device *xdev,
enum xrt_input_name name,
enum xrt_layer_composition_flags layer_flags,
enum xrt_layer_eye_visibility visibility,
struct xrt_swapchain *sc,
uint32_t image_index,
struct xrt_rect *rect,
uint32_t array_index,
struct xrt_pose *pose,
struct xrt_vec2 *size,
bool flip_y)
struct xrt_layer_data *data)
{
struct ipc_client_compositor *icc = ipc_client_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 xrt_layer_data *data = &layer->data;
struct xrt_layer_quad_data *quad = &data->quad;
struct ipc_client_swapchain *ics = ipc_client_swapchain(sc);
assert(data->type == XRT_LAYER_QUAD);
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->data = *data;
// Increment the number of layers.
icc->layers.num_layers++;

View file

@ -736,15 +736,30 @@ submit_quad_layer(struct xrt_compositor *xc,
struct oxr_swapchain *sc = XRT_CAST_OXR_HANDLE_TO_PTR(
struct oxr_swapchain *, quad->subImage.swapchain);
enum xrt_layer_composition_flags flags = quad->layerFlags;
struct xrt_pose pose;
math_pose_transform(inv_offset, (struct xrt_pose *)&quad->pose, &pose);
CALL_CHK(xrt_comp_layer_quad(
xc, timestamp, head, XRT_INPUT_GENERIC_HEAD_POSE, quad->layerFlags,
(enum xrt_layer_eye_visibility)quad->eyeVisibility, sc->swapchain,
sc->released.index, (struct xrt_rect *)&quad->subImage.imageRect,
quad->subImage.imageArrayIndex, &pose,
(struct xrt_vec2 *)&quad->size, false));
struct xrt_layer_data data;
U_ZERO(&data);
data.type = XRT_LAYER_QUAD;
data.name = XRT_INPUT_GENERIC_HEAD_POSE;
data.timestamp = timestamp;
data.flags = flags;
struct xrt_vec2 *size = (struct xrt_vec2 *)&quad->size;
struct xrt_rect *rect = (struct xrt_rect *)&quad->subImage.imageRect;
data.quad.visibility =
(enum xrt_layer_eye_visibility)quad->eyeVisibility;
data.quad.image_index = sc->released.index;
data.quad.array_index = quad->subImage.imageArrayIndex;
data.quad.rect = *rect;
data.quad.pose = pose;
data.quad.size = *size;
CALL_CHK(xrt_comp_layer_quad(xc, head, sc->swapchain, &data));
return XR_SUCCESS;
}
@ -757,7 +772,7 @@ submit_projection_layer(struct xrt_compositor *xc,
struct xrt_pose *inv_offset,
uint64_t timestamp)
{
enum xrt_layer_composition_flags flags = 0;
enum xrt_layer_composition_flags flags = proj->layerFlags;
struct oxr_swapchain *scs[2];
uint32_t num_chains = ARRAY_SIZE(scs);
@ -773,18 +788,36 @@ submit_projection_layer(struct xrt_compositor *xc,
math_pose_transform(inv_offset, (struct xrt_pose *)&proj->views[1].pose,
&pose[1]);
CALL_CHK(xrt_comp_layer_stereo_projection(
xc, timestamp, head, XRT_INPUT_GENERIC_HEAD_POSE, flags,
scs[0]->swapchain, // Left
scs[0]->released.index,
(struct xrt_rect *)&proj->views[0].subImage.imageRect,
proj->views[0].subImage.imageArrayIndex,
(struct xrt_fov *)&proj->views[0].fov, &pose[0],
scs[1]->swapchain, // Right
scs[1]->released.index,
(struct xrt_rect *)&proj->views[1].subImage.imageRect,
proj->views[1].subImage.imageArrayIndex,
(struct xrt_fov *)&proj->views[1].fov, &pose[1], false));
struct xrt_rect *l_rect =
(struct xrt_rect *)&proj->views[0].subImage.imageRect;
struct xrt_fov *l_fov = (struct xrt_fov *)&proj->views[0].fov;
struct xrt_rect *r_rect =
(struct xrt_rect *)&proj->views[1].subImage.imageRect;
struct xrt_fov *r_fov = (struct xrt_fov *)&proj->views[1].fov;
struct xrt_layer_data data;
U_ZERO(&data);
data.type = XRT_LAYER_STEREO_PROJECTION;
data.name = XRT_INPUT_GENERIC_HEAD_POSE;
data.timestamp = timestamp;
data.flags = flags;
data.stereo.l.image_index = scs[0]->released.index;
data.stereo.l.array_index = proj->views[0].subImage.imageArrayIndex;
data.stereo.l.rect = *l_rect;
data.stereo.l.fov = *l_fov;
data.stereo.l.pose = pose[0];
data.stereo.r.image_index = scs[1]->released.index;
data.stereo.r.array_index = proj->views[1].subImage.imageArrayIndex;
data.stereo.r.rect = *r_rect;
data.stereo.r.fov = *r_fov;
data.stereo.r.pose = pose[1];
CALL_CHK(xrt_comp_layer_stereo_projection(xc, head,
scs[0]->swapchain, // Left
scs[1]->swapchain, // Right
&data));
return XR_SUCCESS;
}