diff --git a/src/xrt/compositor/main/comp_compositor.h b/src/xrt/compositor/main/comp_compositor.h index 7ffea4a87..88681088a 100644 --- a/src/xrt/compositor/main/comp_compositor.h +++ b/src/xrt/compositor/main/comp_compositor.h @@ -221,6 +221,18 @@ comp_compositor_print(struct comp_compositor *c, } \ } while (false) +/*! + * Mode printing. + * + * @ingroup comp + */ +#define COMP_PRINT_MODE(c, ...) \ + do { \ + if (c->settings.print_modes) { \ + comp_compositor_print(c, __func__, __VA_ARGS__); \ + } \ + } while (false) + /*! * Error level logging. * diff --git a/src/xrt/compositor/main/comp_settings.c b/src/xrt/compositor/main/comp_settings.c index bceffab92..1c62c5f18 100644 --- a/src/xrt/compositor/main/comp_settings.c +++ b/src/xrt/compositor/main/comp_settings.c @@ -13,6 +13,7 @@ // clang-format off DEBUG_GET_ONCE_BOOL_OPTION(print_spew, "XRT_COMPOSITOR_PRINT_SPEW", false) 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_BOOL_OPTION(force_xcb, "XRT_COMPOSITOR_FORCE_XCB", false) @@ -44,6 +45,7 @@ comp_settings_init(struct comp_settings *s, struct xrt_device *xdev) s->nominal_frame_interval_ns = interval_ns; s->print_spew = debug_get_bool_option_print_spew(); s->print_debug = debug_get_bool_option_print_debug(); + s->print_modes = debug_get_bool_option_print_modes(); s->validate_vulkan = debug_get_bool_option_validate_vulkan(); s->gpu_index = debug_get_num_option_force_gpu_index(); s->debug.wireframe = debug_get_bool_option_wireframe(); diff --git a/src/xrt/compositor/main/comp_settings.h b/src/xrt/compositor/main/comp_settings.h index dbd03f57a..a697b3c92 100644 --- a/src/xrt/compositor/main/comp_settings.h +++ b/src/xrt/compositor/main/comp_settings.h @@ -82,6 +82,9 @@ struct comp_settings //! Should we debug print. bool print_debug; + //! Print information about available modes for direct mode. + bool print_modes; + //! Should we flip y axis for compositor buffers (for GL) bool flip_y; diff --git a/src/xrt/compositor/main/comp_window_direct_mode.cpp b/src/xrt/compositor/main/comp_window_direct_mode.cpp index 7f2c646f2..a4b044d7e 100644 --- a/src/xrt/compositor/main/comp_window_direct_mode.cpp +++ b/src/xrt/compositor/main/comp_window_direct_mode.cpp @@ -428,6 +428,24 @@ choose_best_vk_mode_auto(struct comp_window_direct *w, return best_mode.index; } +static void +print_modes(struct comp_window_direct *w, + VkDisplayModePropertiesKHR *mode_properties, + int mode_count) +{ + COMP_PRINT_MODE(w->base.c, "Available Vk modes for direct mode"); + for (int i = 0; i < mode_count; i++) { + VkDisplayModePropertiesKHR props = mode_properties[i]; + uint16_t width = props.parameters.visibleRegion.width; + uint16_t height = props.parameters.visibleRegion.height; + float refresh = (float)props.parameters.refreshRate / 1000.; + + COMP_PRINT_MODE(w->base.c, "| %2d | %dx%d@%.2f", i, width, + height, refresh); + } + COMP_PRINT_MODE(w->base.c, "Listed %d modes", mode_count); +} + static VkDisplayModeKHR comp_window_direct_get_primary_display_mode(struct comp_window_direct *w, VkDisplayKHR display) @@ -459,6 +477,8 @@ comp_window_direct_get_primary_display_mode(struct comp_window_direct *w, return nullptr; } + print_modes(w, mode_properties, mode_count); + int chosen_mode = choose_best_vk_mode_auto(w, mode_properties, mode_count); VkDisplayModePropertiesKHR props = mode_properties[chosen_mode];