The open source OpenXR runtime
0
fork

Configure Feed

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

c/main: Refactor arguments to comp_target::create_images

authored by

Jakob Bornecrantz and committed by
Simon Zeni
a6e9893f 206bdfe0

+72 -73
+13 -8
src/xrt/compositor/main/comp_renderer.c
··· 529 529 image_usage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT; 530 530 } 531 531 532 - comp_target_create_images( // 533 - r->c->target, // 534 - r->c->settings.preferred.width, // 535 - r->c->settings.preferred.height, // 536 - r->settings->color_format, // 537 - r->settings->color_space, // 538 - image_usage, // 539 - r->settings->present_mode); // 532 + struct comp_target_create_images_info info = { 533 + .extent = 534 + { 535 + .width = r->c->settings.preferred.width, 536 + .height = r->c->settings.preferred.height, 537 + }, 538 + .format = r->settings->color_format, 539 + .image_usage = image_usage, 540 + .color_space = r->settings->color_space, 541 + .present_mode = r->settings->present_mode, 542 + }; 543 + 544 + comp_target_create_images(r->c->target, &info); 540 545 541 546 bool pre_rotate = false; 542 547 if (r->c->target->surface_transform & VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR ||
+27 -22
src/xrt/compositor/main/comp_target.h
··· 65 65 }; 66 66 67 67 /*! 68 + * Information given in when creating the swapchain images, 69 + * argument to @ref comp_target_create_images. 70 + * 71 + * @ingroup comp_main 72 + */ 73 + struct comp_target_create_images_info 74 + { 75 + //! Image usage for the images, must be followed. 76 + VkImageUsageFlags image_usage; 77 + 78 + //! Preferred format for the images, can be ignored by the target. 79 + VkFormat format; 80 + 81 + //! Preferred extent, can be ignored by the target. 82 + VkExtent2D extent; 83 + 84 + //! Preferred color space, can be ignored by the target. 85 + VkColorSpaceKHR color_space; 86 + 87 + // Preferred present_mode, can be ignored by the target. 88 + VkPresentModeKHR present_mode; 89 + }; 90 + 91 + /*! 68 92 * Collection of semaphores needed for a target. 69 93 * 70 94 * @ingroup comp_main ··· 157 181 * 158 182 * @pre @ref check_ready returns true 159 183 */ 160 - void (*create_images)(struct comp_target *ct, 161 - uint32_t preferred_width, 162 - uint32_t preferred_height, 163 - VkFormat preferred_color_format, 164 - VkColorSpaceKHR preferred_color_space, 165 - VkImageUsageFlags image_usage, 166 - VkPresentModeKHR present_mode); 184 + void (*create_images)(struct comp_target *ct, const struct comp_target_create_images_info *create_info); 167 185 168 186 /*! 169 187 * Has this target successfully had images created? ··· 326 344 * @ingroup comp_main 327 345 */ 328 346 static inline void 329 - comp_target_create_images(struct comp_target *ct, 330 - uint32_t preferred_width, 331 - uint32_t preferred_height, 332 - VkFormat preferred_color_format, 333 - VkColorSpaceKHR preferred_color_space, 334 - VkImageUsageFlags image_usage, 335 - VkPresentModeKHR present_mode) 347 + comp_target_create_images(struct comp_target *ct, const struct comp_target_create_images_info *create_info) 336 348 { 337 349 COMP_TRACE_MARKER(); 338 350 339 - ct->create_images( // 340 - ct, // 341 - preferred_width, // 342 - preferred_height, // 343 - preferred_color_format, // 344 - preferred_color_space, // 345 - image_usage, // 346 - present_mode); // 351 + ct->create_images(ct, create_info); 347 352 } 348 353 349 354 /*!
+16 -25
src/xrt/compositor/main/comp_target_swapchain.c
··· 145 145 } 146 146 147 147 static VkExtent2D 148 - select_extent(struct comp_target_swapchain *cts, 149 - VkSurfaceCapabilitiesKHR caps, 150 - uint32_t preferred_width, 151 - uint32_t preferred_height) 148 + select_extent(struct comp_target_swapchain *cts, VkSurfaceCapabilitiesKHR caps, VkExtent2D preferred) 152 149 { 153 150 /* 154 151 * A sub-class wants us to use these extents over the ones the ··· 156 153 * upporting this size so we better respect those wishes. 157 154 */ 158 155 if (cts->override.compositor_extent) { 159 - preferred_width = cts->override.extent.width; 160 - preferred_height = cts->override.extent.height; 156 + preferred.width = cts->override.extent.width; 157 + preferred.height = cts->override.extent.height; 161 158 } 162 159 163 160 // If width (and height) equals the special value 0xFFFFFFFF, 164 161 // the size of the surface will be set by the swapchain 165 162 if (caps.currentExtent.width == (uint32_t)-1) { 166 - assert(preferred_width > 0 && preferred_height > 0); 163 + assert(preferred.width > 0 && preferred.height > 0); 167 164 168 165 VkExtent2D extent = { 169 - .width = preferred_width, 170 - .height = preferred_height, 166 + .width = preferred.width, 167 + .height = preferred.height, 171 168 }; 172 169 return extent; 173 170 } 174 171 175 - if (caps.currentExtent.width != preferred_width || // 176 - caps.currentExtent.height != preferred_height) { 172 + if (caps.currentExtent.width != preferred.width || // 173 + caps.currentExtent.height != preferred.height) { 177 174 COMP_DEBUG(cts->base.c, "Using swap chain extent dimensions %dx%d instead of requested %dx%d.", 178 175 caps.currentExtent.width, // 179 176 caps.currentExtent.height, // 180 - preferred_width, // 181 - preferred_height); // 177 + preferred.width, // 178 + preferred.height); // 182 179 } 183 180 184 181 return caps.currentExtent; ··· 641 638 */ 642 639 643 640 static void 644 - comp_target_swapchain_create_images(struct comp_target *ct, 645 - uint32_t preferred_width, 646 - uint32_t preferred_height, 647 - VkFormat color_format, 648 - VkColorSpaceKHR color_space, 649 - VkImageUsageFlags image_usage, 650 - VkPresentModeKHR present_mode) 641 + comp_target_swapchain_create_images(struct comp_target *ct, const struct comp_target_create_images_info *create_info) 651 642 { 652 643 struct comp_target_swapchain *cts = (struct comp_target_swapchain *)ct; 653 644 struct vk_bundle *vk = get_vk(cts); ··· 673 664 674 665 cts->base.image_count = 0; 675 666 cts->swapchain.handle = VK_NULL_HANDLE; 676 - cts->present_mode = present_mode; 677 - cts->preferred.color_format = color_format; 678 - cts->preferred.color_space = color_space; 667 + cts->present_mode = create_info->present_mode; 668 + cts->preferred.color_format = create_info->format; 669 + cts->preferred.color_space = create_info->color_space; 679 670 680 671 681 672 /* ··· 737 728 */ 738 729 739 730 // Get the extents of the swapchain. 740 - VkExtent2D extent = select_extent(cts, surface_caps, preferred_width, preferred_height); 731 + VkExtent2D extent = select_extent(cts, surface_caps, create_info->extent); 741 732 742 733 if (surface_caps.currentTransform & VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR || 743 734 surface_caps.currentTransform & VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR) { ··· 785 776 .height = extent.height, 786 777 }, 787 778 .imageArrayLayers = 1, 788 - .imageUsage = image_usage, 779 + .imageUsage = create_info->image_usage, 789 780 .imageSharingMode = VK_SHARING_MODE_EXCLUSIVE, 790 781 .queueFamilyIndexCount = 0, 791 782 .preTransform = surface_caps.currentTransform,
+16 -18
src/xrt/compositor/main/comp_window_peek.c
··· 50 50 return &w->c->base.vk; 51 51 } 52 52 53 + static inline void 54 + create_images(struct comp_window_peek *w) 55 + { 56 + struct comp_target_create_images_info info = { 57 + .extent = {w->width, w->height}, 58 + .format = w->c->settings.color_format, 59 + .color_space = w->c->settings.color_space, 60 + .image_usage = PEEK_IMAGE_USAGE, 61 + .present_mode = VK_PRESENT_MODE_MAILBOX_KHR, 62 + }; 63 + 64 + comp_target_create_images(&w->base.base, &info); 65 + } 66 + 53 67 static void * 54 68 window_peek_run_thread(void *ptr) 55 69 { ··· 204 218 * Images 205 219 */ 206 220 207 - /* TODO: present mode fallback to FIFO if MAILBOX is not available */ 208 - comp_target_create_images( // 209 - &w->base.base, // 210 - w->width, // 211 - w->height, // 212 - w->c->settings.color_format, // 213 - w->c->settings.color_space, // 214 - PEEK_IMAGE_USAGE, // 215 - VK_PRESENT_MODE_MAILBOX_KHR); // 216 - 221 + create_images(w); 217 222 218 223 /* 219 224 * Thread ··· 280 285 281 286 if (w->width != w->base.base.width || w->height != w->base.base.height) { 282 287 COMP_DEBUG(w->c, "Resizing swapchain"); 283 - comp_target_create_images( // 284 - &w->base.base, // 285 - w->width, // 286 - w->height, // 287 - w->c->settings.color_format, // 288 - w->c->settings.color_space, // 289 - PEEK_IMAGE_USAGE, // 290 - VK_PRESENT_MODE_MAILBOX_KHR); // 288 + create_images(w); 291 289 } 292 290 293 291 while (!comp_target_check_ready(&w->base.base))