The open source OpenXR runtime
0
fork

Configure Feed

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

c/main: Let sub-classed targets override compositor extents

authored by

Jakob Bornecrantz and committed by
Simon Zeni
cb1b2087 14104658

+75 -15
+29
src/xrt/compositor/main/comp_target_swapchain.c
··· 150 150 uint32_t preferred_width, 151 151 uint32_t preferred_height) 152 152 { 153 + /* 154 + * A sub-class wants us to use these extents over the ones the 155 + * compositor preferred, this is probably due to the target only 156 + * upporting this size so we better respect those wishes. 157 + */ 158 + if (cts->override.compositor_extent) { 159 + preferred_width = cts->override.extent.width; 160 + preferred_height = cts->override.extent.height; 161 + } 162 + 153 163 // If width (and height) equals the special value 0xFFFFFFFF, 154 164 // the size of the surface will be set by the swapchain 155 165 if (caps.currentExtent.width == (uint32_t)-1) { ··· 1031 1041 * 'Exported' functions. 1032 1042 * 1033 1043 */ 1044 + 1045 + void 1046 + comp_target_swapchain_override_extents(struct comp_target_swapchain *cts, VkExtent2D extent) 1047 + { 1048 + VkExtent2D old = cts->override.extent; 1049 + 1050 + COMP_INFO( // 1051 + cts->base.c, // 1052 + "Target '%s' overrides compositor extents with (%ux%u) was (%ux%u %s)", // 1053 + cts->base.name, // 1054 + extent.width, // 1055 + extent.height, // 1056 + old.width, // 1057 + old.height, // 1058 + cts->override.compositor_extent ? "true" : "false"); // 1059 + 1060 + cts->override.compositor_extent = true; 1061 + cts->override.extent = extent; 1062 + } 1034 1063 1035 1064 void 1036 1065 comp_target_swapchain_cleanup(struct comp_target_swapchain *cts)
+27
src/xrt/compositor/main/comp_target_swapchain.h
··· 49 49 50 50 struct 51 51 { 52 + /*! 53 + * Should we ignore the compositor's preferred extents. Some 54 + * targets, like the direct mode ones, requires a particular 55 + * set of dimensions. 56 + */ 57 + bool compositor_extent; 58 + 59 + /*! 60 + * The extents that a sub-class wants us to use, 61 + * see @p ignore_compositor_extent above. 62 + */ 63 + VkExtent2D extent; 64 + } override; 65 + 66 + struct 67 + { 52 68 VkSwapchainKHR handle; 53 69 } swapchain; 54 70 ··· 128 144 void 129 145 comp_target_swapchain_init_and_set_fnptrs(struct comp_target_swapchain *cts, 130 146 enum comp_target_display_timing_usage timing_usage); 147 + 148 + /*! 149 + * Set that any size from the compositor should be ignored and that given size 150 + * must be used for the @p VkSwapchain the helper code creates. 151 + * 152 + * @protected @memberof comp_target_swapchain 153 + * 154 + * @ingroup comp_main 155 + */ 156 + void 157 + comp_target_swapchain_override_extents(struct comp_target_swapchain *cts, VkExtent2D extent); 131 158 132 159 /*! 133 160 * Free all managed resources on the given @ref comp_target_swapchain,
+1 -2
src/xrt/compositor/main/comp_window_direct_nvidia.c
··· 160 160 */ 161 161 162 162 // Make the compositor use this size. 163 - w->base.base.c->settings.preferred.width = disp->physicalResolution.width; 164 - w->base.base.c->settings.preferred.height = disp->physicalResolution.height; 163 + comp_target_swapchain_override_extents(&w->base, disp->physicalResolution); 165 164 166 165 // Create the entry. 167 166 struct comp_window_direct_nvidia_display d = {
+2 -2
src/xrt/compositor/main/comp_window_direct_randr.c
··· 223 223 struct comp_window_direct_randr_display *d = comp_window_direct_randr_current_display(w_direct); 224 224 225 225 // Make the compositor use this size. 226 - ct->c->settings.preferred.width = d->primary_mode.width; 227 - ct->c->settings.preferred.height = d->primary_mode.height; 226 + VkExtent2D extent = {d->primary_mode.width, d->primary_mode.height}; 227 + comp_target_swapchain_override_extents(&w_direct->base, extent); 228 228 229 229 return true; 230 230 }
+1 -2
src/xrt/compositor/main/comp_window_vk_display.c
··· 128 128 append_vk_display_entry(struct comp_window_vk_display *w, struct VkDisplayPropertiesKHR *disp) 129 129 { 130 130 // Make the compositor use this size. 131 - w->base.base.c->settings.preferred.width = disp->physicalResolution.width; 132 - w->base.base.c->settings.preferred.height = disp->physicalResolution.height; 131 + comp_target_swapchain_override_extents(&w->base, disp->physicalResolution); 133 132 134 133 // Create the entry. 135 134 struct vk_display d = {
+15 -9
src/xrt/compositor/main/comp_window_xcb.c
··· 90 90 comp_window_xcb_connect(struct comp_window_xcb *w); 91 91 92 92 static void 93 - comp_window_xcb_create_window(struct comp_window_xcb *w, uint32_t width, uint32_t height); 93 + comp_window_xcb_create_window(struct comp_window_xcb *w, VkExtent2D extent); 94 94 95 95 static void 96 96 comp_window_xcb_get_randr_outputs(struct comp_window_xcb *w); ··· 237 237 } 238 238 239 239 if (d->size.width != 0 && d->size.height != 0) { 240 - ct->c->settings.preferred.width = d->size.width; 241 - ct->c->settings.preferred.height = d->size.height; 242 240 COMP_DEBUG(ct->c, "Setting window size %dx%d.", d->size.width, d->size.height); 243 241 244 - // TODO: size cb 245 - // set_size_cb(settings->width, settings->height); 242 + VkExtent2D extent = {d->size.width, d->size.height}; 243 + comp_target_swapchain_override_extents(&w_xcb->base, extent); 246 244 } 247 245 } 248 246 247 + // The extent of the window we are about to create. 248 + VkExtent2D extent = {ct->c->settings.preferred.width, ct->c->settings.preferred.height}; 249 + 250 + // If we require a particular size, use that. 251 + if (w_xcb->base.override.compositor_extent) { 252 + extent = w_xcb->base.override.extent; 253 + } 254 + 249 255 // We can now create the window. 250 - comp_window_xcb_create_window(w_xcb, ct->c->settings.preferred.width, ct->c->settings.preferred.height); 256 + comp_window_xcb_create_window(w_xcb, extent); 251 257 252 258 comp_window_xcb_connect_delete_event(w_xcb); 253 259 ··· 294 300 } 295 301 296 302 static void 297 - comp_window_xcb_create_window(struct comp_window_xcb *w, uint32_t width, uint32_t height) 303 + comp_window_xcb_create_window(struct comp_window_xcb *w, VkExtent2D extent) 298 304 { 299 305 w->window = xcb_generate_id(w->connection); 300 306 ··· 315 321 w->screen->root, // parent 316 322 x, // x 317 323 y, // y 318 - width, // width 319 - height, // height 324 + extent.width, // width 325 + extent.height, // height 320 326 0, // border_width 321 327 XCB_WINDOW_CLASS_INPUT_OUTPUT, // _class 322 328 w->screen->root_visual, // visual