From 7e45fc7dd9aade419938f0e64b879171728baaf4 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 20 May 2022 11:13:58 +0100 Subject: [PATCH] t/common: Integrate null compositor --- CMakeLists.txt | 2 +- src/xrt/targets/common/CMakeLists.txt | 11 +++++-- src/xrt/targets/common/target_instance.c | 41 ++++++++++++++++++++++-- 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e1a87c3a..38b9f7277 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -237,7 +237,7 @@ option(XRT_FEATURE_COLOR_LOG "Enable logging in color on supported platforms" ON option_with_deps(XRT_FEATURE_COMPOSITOR_MAIN "Build main compositor host functionality" DEPENDS XRT_HAVE_VULKAN "XRT_HAVE_WAYLAND OR XRT_HAVE_XCB OR ANDROID OR WIN32") option_with_deps(XRT_FEATURE_COMPOSITOR_NULL "Build testing null compositor" DEPENDS XRT_HAVE_VULKAN) option_with_deps(XRT_FEATURE_IPC "Enable the build of the IPC layer" DEPENDS "NOT WIN32") -option_with_deps(XRT_FEATURE_OPENXR "Build OpenXR runtime target" DEPENDS XRT_FEATURE_COMPOSITOR_MAIN) +option_with_deps(XRT_FEATURE_OPENXR "Build OpenXR runtime target" DEPENDS "XRT_FEATURE_COMPOSITOR_MAIN OR XRT_FEATURE_COMPOSITOR_NULL") option_with_deps(XRT_FEATURE_RENDERDOC "Enable RenderDoc API" DEPENDS "RT_LIBRARY OR WIN32") option_with_deps(XRT_FEATURE_SERVICE "Enable separate service module for OpenXR runtime" DEPENDS XRT_FEATURE_IPC XRT_FEATURE_OPENXR) option_with_deps(XRT_FEATURE_SERVICE_SYSTEMD "Enable systemd socket activation of the service" DEPENDS XRT_HAVE_SYSTEMD XRT_FEATURE_SERVICE) diff --git a/src/xrt/targets/common/CMakeLists.txt b/src/xrt/targets/common/CMakeLists.txt index d21ee6655..0341523dc 100644 --- a/src/xrt/targets/common/CMakeLists.txt +++ b/src/xrt/targets/common/CMakeLists.txt @@ -123,7 +123,7 @@ endif() #### # Instance # -if(XRT_FEATURE_COMPOSITOR_MAIN) +if(XRT_FEATURE_COMPOSITOR_MAIN OR XRT_FEATURE_COMPOSITOR_NULL) add_library(target_instance STATIC target_instance.c) target_link_libraries( target_instance @@ -132,10 +132,17 @@ if(XRT_FEATURE_COMPOSITOR_MAIN) aux_util st_prober target_lists - comp_main drv_includes ) target_include_directories(target_instance PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + + if(XRT_FEATURE_COMPOSITOR_MAIN) + target_link_libraries(target_instance PRIVATE comp_main) + endif() + + if(XRT_FEATURE_COMPOSITOR_NULL) + target_link_libraries(target_instance PRIVATE comp_null) + endif() endif() #### diff --git a/src/xrt/targets/common/target_instance.c b/src/xrt/targets/common/target_instance.c index d062d28c1..8fd013e94 100644 --- a/src/xrt/targets/common/target_instance.c +++ b/src/xrt/targets/common/target_instance.c @@ -1,4 +1,4 @@ -// Copyright 2020, Collabora, Ltd. +// Copyright 2020-2022, Collabora, Ltd. // SPDX-License-Identifier: BSL-1.0 /*! * @file @@ -9,6 +9,7 @@ #include "xrt/xrt_gfx_native.h" #include "xrt/xrt_system.h" +#include "util/u_debug.h" #include "util/u_trace_marker.h" #include "util/u_system_helpers.h" @@ -17,6 +18,19 @@ #include +#ifdef XRT_FEATURE_COMPOSITOR_MAIN +#define USE_NULL_DEFAULT (false) +#else +#define USE_NULL_DEFAULT (true) +#endif + +DEBUG_GET_ONCE_BOOL_OPTION(use_null, "XRT_COMPOSITOR_NULL", USE_NULL_DEFAULT) + +xrt_result_t +null_compositor_create_system(struct xrt_device *xdev, struct xrt_system_compositor **out_xsysc); + + + /* * * Internal functions. @@ -49,7 +63,30 @@ t_instance_create_system(struct xrt_instance *xinst, struct xrt_device *head = xsysd->roles.head; - xret = xrt_gfx_provider_create_system(head, &xsysc); + bool use_null = debug_get_bool_option_use_null(); + +#ifdef XRT_FEATURE_COMPOSITOR_NULL + if (use_null) { + xret = null_compositor_create_system(head, &xsysc); + } +#else + if (use_null) { + U_LOG_E("The null compositor is not compiled in!"); + xret = XRT_ERROR_VULKAN; + } +#endif + +#ifdef XRT_FEATURE_COMPOSITOR_MAIN + if (xret == XRT_SUCCESS && xsysc == NULL) { + xret = xrt_gfx_provider_create_system(head, &xsysc); + } +#else + if (!use_null) { + U_LOG_E("Explicitly didn't request the null compositor, but the main compositor hasn't been built!"); + xret = XRT_ERROR_VULKAN; + } +#endif + if (xret != XRT_SUCCESS) { xrt_system_devices_destroy(&xsysd); return xret;