c/main: Allow providing comp_target_factory in constructor

This commit is contained in:
Patrick Nicolas 2022-12-09 19:24:32 +01:00 committed by Jakob Bornecrantz
parent 76dff0b42f
commit 7a0d87db25
3 changed files with 16 additions and 7 deletions

View file

@ -858,12 +858,10 @@ select_target_factory_by_detecting(struct comp_compositor *c, struct comp_target
}
static bool
compositor_init_window_pre_vulkan(struct comp_compositor *c)
compositor_init_window_pre_vulkan(struct comp_compositor *c, struct comp_target_factory *selected_ctf)
{
COMP_TRACE_MARKER();
struct comp_target_factory *selected_ctf = NULL;
if (selected_ctf == NULL && !select_target_factory_from_settings(c, &selected_ctf)) {
return false; // Error!
}
@ -985,7 +983,9 @@ compositor_init_renderer(struct comp_compositor *c)
}
xrt_result_t
comp_main_create_system_compositor(struct xrt_device *xdev, struct xrt_system_compositor **out_xsysc)
comp_main_create_system_compositor(struct xrt_device *xdev,
struct comp_target_factory *ctf,
struct xrt_system_compositor **out_xsysc)
{
COMP_TRACE_MARKER();
@ -1041,7 +1041,7 @@ comp_main_create_system_compositor(struct xrt_device *xdev, struct xrt_system_co
// clang-format off
if (!compositor_check_and_prepare_xdev(c, xdev) ||
!compositor_init_window_pre_vulkan(c) ||
!compositor_init_window_pre_vulkan(c, ctf) ||
!compositor_init_vulkan(c) ||
!compositor_init_render_resources(c)) {
COMP_ERROR(c, "Failed to init compositor %p", (void *)c);

View file

@ -14,6 +14,8 @@
#include "xrt/xrt_device.h"
#include "xrt/xrt_compositor.h"
struct comp_target_factory;
#ifdef __cplusplus
extern "C" {
#endif
@ -25,9 +27,16 @@ extern "C" {
*
* @ingroup comp_main
* @relates xrt_system_compositor
*
* @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 out_xsysc The output compositor
*/
xrt_result_t
comp_main_create_system_compositor(struct xrt_device *xdev, struct xrt_system_compositor **out_xsysc);
comp_main_create_system_compositor(struct xrt_device *xdev,
struct comp_target_factory *ctf,
struct xrt_system_compositor **out_xsysc);
#ifdef __cplusplus

View file

@ -86,7 +86,7 @@ t_instance_create_system(struct xrt_instance *xinst,
#ifdef XRT_FEATURE_COMPOSITOR_MAIN
if (xret == XRT_SUCCESS && xsysc == NULL) {
xret = comp_main_create_system_compositor(head, &xsysc);
xret = comp_main_create_system_compositor(head, NULL, &xsysc);
}
#else
if (!use_null) {