The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

c/main: Always use the mode's extents when creating the surface

This fixes a bug on NVIDIA Jetson. Note this isn't so much the NVIDIA Jetson
fault, while the code was working on desktop, Monado did something wrong.
What happned was that Monado would select a mode with one size, while then
creating a VkSurface/VkSwapchain of a different size. This would work on
hardware with scalers/panning modes. The NVIDIA Jetson apparently doesn't have
support for that so failed when presenting. This patch makes sure that the
VkSurface/VkSwapchain extents match the mode for all direct mode targets.

+48 -7
+47 -5
src/xrt/compositor/main/comp_window_direct.c
··· 74 74 COMP_PRINT_MODE(ct->c, "Listed %d modes", mode_count); 75 75 } 76 76 77 - VkDisplayModeKHR 78 - comp_window_direct_get_primary_display_mode(struct comp_target_swapchain *cts, VkDisplayKHR display) 77 + static VkDisplayModeKHR 78 + get_primary_display_mode(struct comp_target_swapchain *cts, 79 + VkDisplayKHR display, 80 + uint32_t *out_width, 81 + uint32_t *out_height) 79 82 { 80 83 struct vk_bundle *vk = get_vk(cts); 81 84 struct comp_target *ct = &cts->base; ··· 142 145 143 146 free(mode_properties); 144 147 148 + *out_width = props.parameters.visibleRegion.width; 149 + *out_height = props.parameters.visibleRegion.height; 150 + 145 151 return props.displayMode; 146 152 } 147 153 ··· 157 163 return VK_DISPLAY_PLANE_ALPHA_GLOBAL_BIT_KHR; 158 164 } 159 165 166 + 167 + /* 168 + * 169 + * 'Exported' functions. 170 + * 171 + */ 172 + 160 173 VkResult 161 174 comp_window_direct_create_surface(struct comp_target_swapchain *cts, 162 175 VkDisplayKHR display, ··· 188 201 plane_properties = NULL; 189 202 190 203 // Select the mode. 191 - VkDisplayModeKHR display_mode = comp_window_direct_get_primary_display_mode(cts, display); 204 + uint32_t mode_width = 0, mode_height = 0; 205 + VkDisplayModeKHR display_mode = get_primary_display_mode( // 206 + cts, // 207 + display, // 208 + &mode_width, // 209 + &mode_height); // 210 + 211 + if (display_mode == VK_NULL_HANDLE) { 212 + COMP_ERROR(cts->base.c, "Failed to find display mode!"); 213 + return VK_ERROR_INITIALIZATION_FAILED; 214 + } 215 + 216 + /* 217 + * This fixes a bug on NVIDIA Jetson. Note this isn't so much the NVIDIA 218 + * Jetson fault, while the code was working on desktop, Monado did 219 + * something wrong. What happned was that Monado would select a mode 220 + * with one size, while then creating a VkSurface/VkSwapchain of a 221 + * different size. This would work on hardware with scalers/panning 222 + * modes. The NVIDIA Jetson apparently doesn't have support for that so 223 + * failed when presenting. This patch makes sure that the VkSurface & 224 + * VkSwapchain extents match the mode for all direct mode targets. 225 + */ 226 + if (mode_width != width || mode_height != height) { 227 + COMP_INFO(cts->base.c, 228 + "Ignoring given extent %dx%d and using %dx%d from mode, bugs could happen otherwise.", 229 + width, // 230 + height, // 231 + mode_width, // 232 + mode_height); // 233 + } 192 234 193 235 // We need the capabilities of the selected plane. 194 236 VkDisplayPlaneCapabilitiesKHR plane_caps; ··· 206 248 .alphaMode = choose_alpha_mode(plane_caps.supportedAlpha), 207 249 .imageExtent = 208 250 { 209 - .width = width, 210 - .height = height, 251 + .width = mode_width, 252 + .height = mode_height, 211 253 }, 212 254 }; 213 255
+1 -2
src/xrt/compositor/main/comp_window_direct.h
··· 16 16 extern "C" { 17 17 #endif 18 18 19 - VkDisplayModeKHR 20 - comp_window_direct_get_primary_display_mode(struct comp_target_swapchain *cts, VkDisplayKHR display); 21 19 22 20 VkResult 23 21 comp_window_direct_create_surface(struct comp_target_swapchain *cts, ··· 38 36 struct comp_target_swapchain *cts, Display *dpy, VkDisplayKHR display, uint32_t width, uint32_t height); 39 37 40 38 #endif 39 + 41 40 42 41 #ifdef __cplusplus 43 42 }