From 026cc646816bf58d697f8273a9142b2a061dea98 Mon Sep 17 00:00:00 2001 From: Christoph Haag Date: Tue, 11 Aug 2020 00:38:07 +0200 Subject: [PATCH] comp: make nvidia display selectable with XRT_COMPOSITOR_FORCE_NVIDIA_DISPLAY Allows temporarily adding a nvidia display name string to the whitelist without recompiling. --- src/xrt/compositor/main/comp_compositor.c | 6 ++++++ src/xrt/compositor/main/comp_settings.c | 4 ++++ src/xrt/compositor/main/comp_settings.h | 3 +++ src/xrt/compositor/main/comp_window_direct_nvidia.c | 6 ++++++ 4 files changed, 19 insertions(+) diff --git a/src/xrt/compositor/main/comp_compositor.c b/src/xrt/compositor/main/comp_compositor.c index fef8732aa..fa3a26e7b 100644 --- a/src/xrt/compositor/main/comp_compositor.c +++ b/src/xrt/compositor/main/comp_compositor.c @@ -775,6 +775,12 @@ _test_for_nvidia(struct comp_compositor *c, struct vk_bundle *vk) return true; } } + + if (c->settings.nvidia_display && + _match_wl_entry(c->settings.nvidia_display, disp)) { + free(display_props); + return true; + } } COMP_ERROR(c, "NVIDIA: No whitelisted displays found!"); diff --git a/src/xrt/compositor/main/comp_settings.c b/src/xrt/compositor/main/comp_settings.c index 77ab58363..1449ab95a 100644 --- a/src/xrt/compositor/main/comp_settings.c +++ b/src/xrt/compositor/main/comp_settings.c @@ -16,6 +16,7 @@ DEBUG_GET_ONCE_BOOL_OPTION(print_debug, "XRT_COMPOSITOR_PRINT_DEBUG", false) DEBUG_GET_ONCE_BOOL_OPTION(print_modes, "XRT_COMPOSITOR_PRINT_MODES", false) DEBUG_GET_ONCE_BOOL_OPTION(force_randr, "XRT_COMPOSITOR_FORCE_RANDR", false) DEBUG_GET_ONCE_BOOL_OPTION(force_nvidia, "XRT_COMPOSITOR_FORCE_NVIDIA", false) +DEBUG_GET_ONCE_OPTION(nvidia_display, "XRT_COMPOSITOR_FORCE_NVIDIA_DISPLAY", NULL) DEBUG_GET_ONCE_BOOL_OPTION(force_xcb, "XRT_COMPOSITOR_FORCE_XCB", false) DEBUG_GET_ONCE_BOOL_OPTION(force_wayland, "XRT_COMPOSITOR_FORCE_WAYLAND", false) DEBUG_GET_ONCE_BOOL_OPTION(wireframe, "XRT_COMPOSITOR_WIREFRAME", false) @@ -56,6 +57,9 @@ comp_settings_init(struct comp_settings *s, struct xrt_device *xdev) if (debug_get_bool_option_force_nvidia()) { s->window_type = WINDOW_DIRECT_NVIDIA; } + + s->nvidia_display = debug_get_option_nvidia_display(); + if (debug_get_bool_option_force_randr()) { s->window_type = WINDOW_DIRECT_RANDR; } diff --git a/src/xrt/compositor/main/comp_settings.h b/src/xrt/compositor/main/comp_settings.h index a069abe42..7b18d8c38 100644 --- a/src/xrt/compositor/main/comp_settings.h +++ b/src/xrt/compositor/main/comp_settings.h @@ -64,6 +64,9 @@ struct comp_settings //! Window type to use. enum window_type window_type; + //! display string forced by user or NULL + const char *nvidia_display; + //! Distortion type to use. enum xrt_distortion_model distortion_model; diff --git a/src/xrt/compositor/main/comp_window_direct_nvidia.c b/src/xrt/compositor/main/comp_window_direct_nvidia.c index 4e730cbde..43d270e8a 100644 --- a/src/xrt/compositor/main/comp_window_direct_nvidia.c +++ b/src/xrt/compositor/main/comp_window_direct_nvidia.c @@ -202,6 +202,12 @@ comp_window_direct_nvidia_init(struct comp_window *w) // TODO: what if we have multiple whitelisted HMD displays connected? for (uint32_t i = 0; i < display_count; i++) { struct VkDisplayPropertiesKHR disp = *(display_props + i); + + if (w->c->settings.nvidia_display) { + append_nvidia_entry_on_match( + w_direct, w->c->settings.nvidia_display, &disp); + } + // check this display against our whitelist for (uint32_t j = 0; j < ARRAY_SIZE(NV_DIRECT_WHITELIST); j++) if (append_nvidia_entry_on_match(