From 9c8d0ae3cc180e831cc39830e5fd9c7d31320953 Mon Sep 17 00:00:00 2001 From: Lubosz Sarnecki Date: Fri, 22 May 2020 16:01:41 +0200 Subject: [PATCH] xrt: Pass the flip y on layer per layer basis. st/oxr: Adopt to flip y in layers change. c/client: Adapt to flip y in layers change. Set true for GL and false for Vulkan. --- src/xrt/compositor/client/comp_gl_client.c | 10 ++++++---- src/xrt/compositor/client/comp_vk_client.c | 10 ++++++---- src/xrt/include/xrt/xrt_compositor.h | 18 ++++++++++++------ src/xrt/state_trackers/oxr/oxr_session.c | 4 ++-- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/xrt/compositor/client/comp_gl_client.c b/src/xrt/compositor/client/comp_gl_client.c index f9b8ea3bf..892116543 100644 --- a/src/xrt/compositor/client/comp_gl_client.c +++ b/src/xrt/compositor/client/comp_gl_client.c @@ -152,7 +152,8 @@ client_gl_compositor_layer_stereo_projection( struct xrt_rect *r_rect, uint32_t r_array_index, struct xrt_fov *r_fov, - struct xrt_pose *r_pose) + struct xrt_pose *r_pose, + bool flip_y) { struct client_gl_compositor *c = client_gl_compositor(xc); struct xrt_swapchain *l_xscfd, *r_xscfd; @@ -163,7 +164,7 @@ client_gl_compositor_layer_stereo_projection( 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); + r_image_index, r_rect, r_array_index, r_fov, r_pose, true); } static void @@ -178,7 +179,8 @@ client_gl_compositor_layer_quad(struct xrt_compositor *xc, struct xrt_rect *rect, uint32_t array_index, struct xrt_pose *pose, - struct xrt_vec2 *size) + struct xrt_vec2 *size, + bool flip_y) { struct client_gl_compositor *c = client_gl_compositor(xc); struct xrt_swapchain *xscfb; @@ -187,7 +189,7 @@ client_gl_compositor_layer_quad(struct xrt_compositor *xc, xrt_comp_layer_quad(&c->xcfd->base, timestamp, xdev, name, layer_flags, visibility, xscfb, image_index, rect, array_index, - pose, size); + pose, size, true); } static void diff --git a/src/xrt/compositor/client/comp_vk_client.c b/src/xrt/compositor/client/comp_vk_client.c index d5303a0d9..e7f8ab2ac 100644 --- a/src/xrt/compositor/client/comp_vk_client.c +++ b/src/xrt/compositor/client/comp_vk_client.c @@ -170,7 +170,8 @@ client_vk_compositor_layer_stereo_projection( struct xrt_rect *r_rect, uint32_t r_array_index, struct xrt_fov *r_fov, - struct xrt_pose *r_pose) + struct xrt_pose *r_pose, + bool flip_y) { struct client_vk_compositor *c = client_vk_compositor(xc); struct xrt_swapchain *l_xscfd, *r_xscfd; @@ -181,7 +182,7 @@ client_vk_compositor_layer_stereo_projection( 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); + r_image_index, r_rect, r_array_index, r_fov, r_pose, false); } static void @@ -196,7 +197,8 @@ client_vk_compositor_layer_quad(struct xrt_compositor *xc, struct xrt_rect *rect, uint32_t array_index, struct xrt_pose *pose, - struct xrt_vec2 *size) + struct xrt_vec2 *size, + bool flip_y) { struct client_vk_compositor *c = client_vk_compositor(xc); struct xrt_swapchain *xscfb; @@ -205,7 +207,7 @@ client_vk_compositor_layer_quad(struct xrt_compositor *xc, xrt_comp_layer_quad(&c->xcfd->base, timestamp, xdev, name, layer_flags, visibility, xscfb, image_index, rect, array_index, - pose, size); + pose, size, false); } static void diff --git a/src/xrt/include/xrt/xrt_compositor.h b/src/xrt/include/xrt/xrt_compositor.h index 92d23ffe1..52a470240 100644 --- a/src/xrt/include/xrt/xrt_compositor.h +++ b/src/xrt/include/xrt/xrt_compositor.h @@ -273,6 +273,7 @@ struct xrt_compositor * @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. */ void (*layer_stereo_projection)( struct xrt_compositor *xc, @@ -291,7 +292,8 @@ struct xrt_compositor struct xrt_rect *r_rect, uint32_t r_array_index, struct xrt_fov *r_fov, - struct xrt_pose *r_pose); + struct xrt_pose *r_pose, + bool flip_y); /*! * Adds a quad layer for submission, the center of the quad is specified @@ -308,6 +310,7 @@ struct xrt_compositor * @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. */ void (*layer_quad)(struct xrt_compositor *xc, uint64_t timestamp, @@ -320,7 +323,8 @@ struct xrt_compositor struct xrt_rect *rect, uint32_t array_index, struct xrt_pose *pose, - struct xrt_vec2 *size); + struct xrt_vec2 *size, + bool flip_y); /*! * Commits all of the submitted layers, it's from this on that the @@ -472,12 +476,13 @@ xrt_comp_layer_stereo_projection(struct xrt_compositor *xc, struct xrt_rect *r_rect, uint32_t r_array_index, struct xrt_fov *r_fov, - struct xrt_pose *r_pose) + struct xrt_pose *r_pose, + bool flip_y) { 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); + r_array_index, r_fov, r_pose, flip_y); } /*! @@ -497,10 +502,11 @@ xrt_comp_layer_quad(struct xrt_compositor *xc, struct xrt_rect *rect, uint32_t array_index, struct xrt_pose *pose, - struct xrt_vec2 *size) + struct xrt_vec2 *size, + bool flip_y) { xc->layer_quad(xc, timestamp, xdev, name, layer_flags, visibility, sc, - image_index, rect, array_index, pose, size); + image_index, rect, array_index, pose, size, flip_y); } /*! diff --git a/src/xrt/state_trackers/oxr/oxr_session.c b/src/xrt/state_trackers/oxr/oxr_session.c index d105ddc64..9eeda19df 100644 --- a/src/xrt/state_trackers/oxr/oxr_session.c +++ b/src/xrt/state_trackers/oxr/oxr_session.c @@ -553,7 +553,7 @@ submit_quad_layer(struct xrt_compositor *xc, (enum xrt_layer_eye_visibility)quad->eyeVisibility, sc->swapchain, sc->released_index, (struct xrt_rect *)&quad->subImage.imageRect, quad->subImage.imageArrayIndex, (struct xrt_pose *)&quad->pose, - (struct xrt_vec2 *)&quad->size); + (struct xrt_vec2 *)&quad->size, false); } static void @@ -586,7 +586,7 @@ submit_projection_layer(struct xrt_compositor *xc, (struct xrt_rect *)&proj->views[1].subImage.imageRect, proj->views[1].subImage.imageArrayIndex, (struct xrt_fov *)&proj->views[1].fov, - (struct xrt_pose *)&proj->views[1].pose); + (struct xrt_pose *)&proj->views[1].pose, false); } XrResult