diff --git a/src/xrt/compositor/main/comp_compositor.c b/src/xrt/compositor/main/comp_compositor.c index 2cfe19387..bf5e48e2e 100644 --- a/src/xrt/compositor/main/comp_compositor.c +++ b/src/xrt/compositor/main/comp_compositor.c @@ -1005,6 +1005,7 @@ compositor_init_renderer(struct comp_compositor *c) xrt_result_t comp_main_create_system_compositor(struct xrt_device *xdev, const struct comp_target_factory *ctf, + struct u_pacing_app_factory *upaf, struct xrt_system_compositor **out_xsysc) { COMP_TRACE_MARKER(); @@ -1026,6 +1027,8 @@ comp_main_create_system_compositor(struct xrt_device *xdev, c->frame.rendering.id = -1; c->xdev = xdev; + xrt_result_t xret = XRT_SUCCESS; + COMP_DEBUG(c, "Doing init %p", (void *)c); if (xdev->hmd->view_count == 0) { @@ -1073,9 +1076,9 @@ comp_main_create_system_compositor(struct xrt_device *xdev, !compositor_init_vulkan(c) || !compositor_init_render_resources(c)) { COMP_ERROR(c, "Failed to init compositor %p", (void *)c); - c->base.base.base.destroy(&c->base.base.base); - return XRT_ERROR_VULKAN; + xret = XRT_ERROR_VULKAN; + goto error; } if (!c->deferred_surface) { @@ -1083,9 +1086,9 @@ comp_main_create_system_compositor(struct xrt_device *xdev, !compositor_init_swapchain(c) || !compositor_init_renderer(c)) { COMP_ERROR(c, "Failed to init compositor %p", (void*)c); - c->base.base.base.destroy(&c->base.base.base); - return XRT_ERROR_VULKAN; + xret = XRT_ERROR_VULKAN; + goto error; } comp_target_set_title(c->target, WINDOW_TITLE); } @@ -1205,10 +1208,20 @@ comp_main_create_system_compositor(struct xrt_device *xdev, } // Standard app pacer. - struct u_pacing_app_factory *upaf = NULL; - xrt_result_t xret = u_pa_factory_create(&upaf); - assert(xret == XRT_SUCCESS && upaf != NULL); - (void)xret; + if (upaf == NULL) { + xret = u_pa_factory_create(&upaf); + if (xret != XRT_SUCCESS || upaf == NULL) { + COMP_ERROR(c, "Failed to create app pacing factory"); + goto error; + } + } return comp_multi_create_system_compositor(&c->base.base, upaf, sys_info, !c->deferred_surface, out_xsysc); + +error: + if (c != NULL) { + c->base.base.base.destroy(&c->base.base.base); + } + u_paf_destroy(&upaf); + return xret; } diff --git a/src/xrt/compositor/main/comp_main_interface.h b/src/xrt/compositor/main/comp_main_interface.h index 0f0678358..f60568b43 100644 --- a/src/xrt/compositor/main/comp_main_interface.h +++ b/src/xrt/compositor/main/comp_main_interface.h @@ -15,6 +15,7 @@ #include "xrt/xrt_compositor.h" struct comp_target_factory; +struct u_pacing_app_factory; #ifdef __cplusplus extern "C" { @@ -31,11 +32,14 @@ extern "C" { * @param xdev The head device * @param ctf A compositor target factory to force the output device, must remain valid for the lifetime of the * compositor. If NULL, factory is automatically selected + * @param upaf A pacing app factory to customize the application pacer, compositor takes ownership. + * If NULL, a default factory is used * @param out_xsysc The output compositor */ xrt_result_t comp_main_create_system_compositor(struct xrt_device *xdev, const struct comp_target_factory *ctf, + struct u_pacing_app_factory *upaf, struct xrt_system_compositor **out_xsysc); diff --git a/src/xrt/targets/common/target_instance.c b/src/xrt/targets/common/target_instance.c index 617561c37..e10ba8358 100644 --- a/src/xrt/targets/common/target_instance.c +++ b/src/xrt/targets/common/target_instance.c @@ -109,7 +109,7 @@ t_instance_create_system(struct xrt_instance *xinst, #ifdef XRT_MODULE_COMPOSITOR_MAIN if (xret == XRT_SUCCESS && xsysc == NULL) { - xret = comp_main_create_system_compositor(head, NULL, &xsysc); + xret = comp_main_create_system_compositor(head, NULL, NULL, &xsysc); } #else if (!use_null) {