The open source OpenXR runtime

c/main: allow custom pacing app factory

Part-of: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2434>

authored by

Patrick Nicolas and committed by
Marge Bot
c4417629 eaff7a09

+26 -9
+21 -8
src/xrt/compositor/main/comp_compositor.c
··· 1005 1005 xrt_result_t 1006 1006 comp_main_create_system_compositor(struct xrt_device *xdev, 1007 1007 const struct comp_target_factory *ctf, 1008 + struct u_pacing_app_factory *upaf, 1008 1009 struct xrt_system_compositor **out_xsysc) 1009 1010 { 1010 1011 COMP_TRACE_MARKER(); ··· 1025 1026 c->frame.waited.id = -1; 1026 1027 c->frame.rendering.id = -1; 1027 1028 c->xdev = xdev; 1029 + 1030 + xrt_result_t xret = XRT_SUCCESS; 1028 1031 1029 1032 COMP_DEBUG(c, "Doing init %p", (void *)c); 1030 1033 ··· 1073 1076 !compositor_init_vulkan(c) || 1074 1077 !compositor_init_render_resources(c)) { 1075 1078 COMP_ERROR(c, "Failed to init compositor %p", (void *)c); 1076 - c->base.base.base.destroy(&c->base.base.base); 1077 1079 1078 - return XRT_ERROR_VULKAN; 1080 + xret = XRT_ERROR_VULKAN; 1081 + goto error; 1079 1082 } 1080 1083 1081 1084 if (!c->deferred_surface) { ··· 1083 1086 !compositor_init_swapchain(c) || 1084 1087 !compositor_init_renderer(c)) { 1085 1088 COMP_ERROR(c, "Failed to init compositor %p", (void*)c); 1086 - c->base.base.base.destroy(&c->base.base.base); 1087 1089 1088 - return XRT_ERROR_VULKAN; 1090 + xret = XRT_ERROR_VULKAN; 1091 + goto error; 1089 1092 } 1090 1093 comp_target_set_title(c->target, WINDOW_TITLE); 1091 1094 } ··· 1205 1208 } 1206 1209 1207 1210 // Standard app pacer. 1208 - struct u_pacing_app_factory *upaf = NULL; 1209 - xrt_result_t xret = u_pa_factory_create(&upaf); 1210 - assert(xret == XRT_SUCCESS && upaf != NULL); 1211 - (void)xret; 1211 + if (upaf == NULL) { 1212 + xret = u_pa_factory_create(&upaf); 1213 + if (xret != XRT_SUCCESS || upaf == NULL) { 1214 + COMP_ERROR(c, "Failed to create app pacing factory"); 1215 + goto error; 1216 + } 1217 + } 1212 1218 1213 1219 return comp_multi_create_system_compositor(&c->base.base, upaf, sys_info, !c->deferred_surface, out_xsysc); 1220 + 1221 + error: 1222 + if (c != NULL) { 1223 + c->base.base.base.destroy(&c->base.base.base); 1224 + } 1225 + u_paf_destroy(&upaf); 1226 + return xret; 1214 1227 }
+4
src/xrt/compositor/main/comp_main_interface.h
··· 15 15 #include "xrt/xrt_compositor.h" 16 16 17 17 struct comp_target_factory; 18 + struct u_pacing_app_factory; 18 19 19 20 #ifdef __cplusplus 20 21 extern "C" { ··· 31 32 * @param xdev The head device 32 33 * @param ctf A compositor target factory to force the output device, must remain valid for the lifetime of the 33 34 * compositor. If NULL, factory is automatically selected 35 + * @param upaf A pacing app factory to customize the application pacer, compositor takes ownership. 36 + * If NULL, a default factory is used 34 37 * @param out_xsysc The output compositor 35 38 */ 36 39 xrt_result_t 37 40 comp_main_create_system_compositor(struct xrt_device *xdev, 38 41 const struct comp_target_factory *ctf, 42 + struct u_pacing_app_factory *upaf, 39 43 struct xrt_system_compositor **out_xsysc); 40 44 41 45
+1 -1
src/xrt/targets/common/target_instance.c
··· 109 109 110 110 #ifdef XRT_MODULE_COMPOSITOR_MAIN 111 111 if (xret == XRT_SUCCESS && xsysc == NULL) { 112 - xret = comp_main_create_system_compositor(head, NULL, &xsysc); 112 + xret = comp_main_create_system_compositor(head, NULL, NULL, &xsysc); 113 113 } 114 114 #else 115 115 if (!use_null) {