From 9422aca625049b186e41da1aab386a97083604a1 Mon Sep 17 00:00:00 2001 From: James Hogan Date: Thu, 13 Jun 2024 17:03:05 +0100 Subject: [PATCH] comp: Fix OpenGL flipping of subimage coordinates In the process of flipping OpenGL subimage coordinates (in accordance with the specification of the XR_KHR_opengl_enable extension), Monado was incorrectly assuming a subimage height of 1.0. When the height of the subimage was reduced below 1.0 this was making Monado clip the bottom instead of the top of the swapchain (as if the origin was the top-left), and when the subimage Y offset was increased Monado would show a black bar at the top where the coordinates went out of range of the swapchain. Fix this in both the compute and graphics compositor, effectively replacing the assumed height of 1 with the original subimage height before negation. Part-of: --- src/xrt/compositor/util/comp_render_cs.c | 2 +- src/xrt/compositor/util/comp_render_gfx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/xrt/compositor/util/comp_render_cs.c b/src/xrt/compositor/util/comp_render_cs.c index d3cfbac22..8201407ae 100644 --- a/src/xrt/compositor/util/comp_render_cs.c +++ b/src/xrt/compositor/util/comp_render_cs.c @@ -425,8 +425,8 @@ do_cs_distortion_for_layer(struct render_compute *crc, src_image_view = get_image_view(image, data->flags, array_index); if (data->flip_y) { + src_norm_rect.y += src_norm_rect.h; src_norm_rect.h = -src_norm_rect.h; - src_norm_rect.y = 1 + src_norm_rect.y; } // Fill in data. diff --git a/src/xrt/compositor/util/comp_render_gfx.c b/src/xrt/compositor/util/comp_render_gfx.c index abf7c9359..6d1acaa62 100644 --- a/src/xrt/compositor/util/comp_render_gfx.c +++ b/src/xrt/compositor/util/comp_render_gfx.c @@ -774,8 +774,8 @@ do_mesh_from_proj(struct render_gfx *rr, const VkImageView src_image_view = get_image_view(image, data->flags, array_index); if (data->flip_y) { + src_norm_rect.y += src_norm_rect.h; src_norm_rect.h = -src_norm_rect.h; - src_norm_rect.y = 1 + src_norm_rect.y; } gfx_mesh_add_view( //