The open source OpenXR runtime
0
fork

Configure Feed

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

c/base: Add support for xrt_swapchain_create_properties

+46 -8
+17 -1
src/xrt/compositor/util/comp_base.c
··· 48 48 */ 49 49 50 50 static xrt_result_t 51 + base_get_swapchain_create_properties(struct xrt_compositor *xc, 52 + const struct xrt_swapchain_create_info *info, 53 + struct xrt_swapchain_create_properties *xsccp) 54 + { 55 + return comp_swapchain_get_create_properties(info, xsccp); 56 + } 57 + 58 + static xrt_result_t 51 59 base_create_swapchain(struct xrt_compositor *xc, 52 60 const struct xrt_swapchain_create_info *info, 53 61 struct xrt_swapchain **out_xsc) 54 62 { 55 63 struct comp_base *cb = comp_base(xc); 56 64 57 - return comp_swapchain_create(&cb->vk, &cb->cscgc, info, out_xsc); 65 + /* 66 + * In case the default get properties function have been overridden 67 + * make sure to correctly dispatch the call to get the properties. 68 + */ 69 + struct xrt_swapchain_create_properties xsccp = {0}; 70 + xrt_comp_get_swapchain_create_properties(xc, info, &xsccp); 71 + 72 + return comp_swapchain_create(&cb->vk, &cb->cscgc, info, &xsccp, out_xsc); 58 73 } 59 74 60 75 static xrt_result_t ··· 243 258 void 244 259 comp_base_init(struct comp_base *cb) 245 260 { 261 + cb->base.base.get_swapchain_create_properties = base_get_swapchain_create_properties; 246 262 cb->base.base.create_swapchain = base_create_swapchain; 247 263 cb->base.base.import_swapchain = base_import_swapchain; 248 264 cb->base.base.create_semaphore = base_create_semaphore;
+19 -7
src/xrt/compositor/util/comp_swapchain.c
··· 256 256 */ 257 257 258 258 xrt_result_t 259 + comp_swapchain_get_create_properties(const struct xrt_swapchain_create_info *info, 260 + struct xrt_swapchain_create_properties *xsccp) 261 + { 262 + uint32_t image_count = 3; 263 + 264 + if ((info->create & XRT_SWAPCHAIN_CREATE_STATIC_IMAGE) != 0) { 265 + image_count = 1; 266 + } 267 + 268 + U_ZERO(xsccp); 269 + xsccp->image_count = image_count; 270 + 271 + return XRT_SUCCESS; 272 + } 273 + 274 + xrt_result_t 259 275 comp_swapchain_create(struct vk_bundle *vk, 260 276 struct comp_swapchain_gc *cscgc, 261 277 const struct xrt_swapchain_create_info *info, 278 + const struct xrt_swapchain_create_properties *xsccp, 262 279 struct xrt_swapchain **out_xsc) 263 280 { 264 - uint32_t image_count = 3; 265 281 VkResult ret; 266 282 267 283 if ((info->create & XRT_SWAPCHAIN_CREATE_PROTECTED_CONTENT) != 0) { ··· 271 287 return XRT_ERROR_SWAPCHAIN_FLAG_VALID_BUT_UNSUPPORTED; 272 288 } 273 289 274 - if ((info->create & XRT_SWAPCHAIN_CREATE_STATIC_IMAGE) != 0) { 275 - image_count = 1; 276 - } 277 - 278 - struct comp_swapchain *sc = alloc_and_set_funcs(vk, cscgc, image_count); 290 + struct comp_swapchain *sc = alloc_and_set_funcs(vk, cscgc, xsccp->image_count); 279 291 280 292 VK_DEBUG(vk, "CREATE %p %dx%d %s (%ld)", (void *)sc, // 281 293 info->width, info->height, // 282 294 vk_format_string(info->format), info->format); 283 295 284 296 // Use the image helper to allocate the images. 285 - ret = vk_ic_allocate(vk, info, image_count, &sc->vkic); 297 + ret = vk_ic_allocate(vk, info, xsccp->image_count, &sc->vkic); 286 298 if (ret == VK_ERROR_FEATURE_NOT_PRESENT) { 287 299 free(sc); 288 300 return XRT_ERROR_SWAPCHAIN_FLAG_VALID_BUT_UNSUPPORTED;
+10
src/xrt/compositor/util/comp_swapchain.h
··· 124 124 * @ingroup comp_util 125 125 */ 126 126 xrt_result_t 127 + comp_swapchain_get_create_properties(const struct xrt_swapchain_create_info *info, 128 + struct xrt_swapchain_create_properties *xsccp); 129 + 130 + /*! 131 + * A compositor function that is implemented in the swapchain code. 132 + * 133 + * @ingroup comp_util 134 + */ 135 + xrt_result_t 127 136 comp_swapchain_create(struct vk_bundle *vk, 128 137 struct comp_swapchain_gc *cscgc, 129 138 const struct xrt_swapchain_create_info *info, 139 + const struct xrt_swapchain_create_properties *xsccp, 130 140 struct xrt_swapchain **out_xsc); 131 141 132 142 /*!