The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

u/debug_gui: Add options to create call

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

authored by

Jakob Bornecrantz and committed by
Simon Zeni
0f7c0399 b6522fdf

+92 -11
+2
doc/changes/auxiliary/mr.2400.md
··· 1 + u/debug_gui: Add an interface to control the window title and if the window 2 + opens or not.
+18 -7
src/xrt/auxiliary/util/u_debug_gui.c
··· 1 1 // Copyright 2019-2024, Collabora, Ltd. 2 + // Copyright 2024-2025, NVIDIA CORPORATION. 2 3 // SPDX-License-Identifier: BSL-1.0 3 4 /*! 4 5 * @file ··· 16 17 struct u_debug_gui; 17 18 18 19 int 19 - u_debug_gui_create(struct u_debug_gui **out_debug_ui) 20 + u_debug_gui_create(const struct u_debug_gui_create_info *udgci, struct u_debug_gui **out_debug_ui) 20 21 { 21 22 return 0; 22 23 } ··· 72 73 { 73 74 struct gui_program base; 74 75 76 + //! Information passed in at create. 77 + struct u_debug_gui_create_info udgci; 78 + 75 79 SDL_GLContext ctx; 76 80 SDL_Window *win; 77 81 ··· 97 101 { 98 102 XRT_TRACE_MARKER(); 99 103 100 - const char *title = "Monado! ✨⚡🔥"; 101 104 int x = SDL_WINDOWPOS_UNDEFINED; 102 105 int y = SDL_WINDOWPOS_UNDEFINED; 103 106 int w = 1920; ··· 121 124 window_flags |= SDL_WINDOW_MAXIMIZED; 122 125 #endif 123 126 124 - p->win = SDL_CreateWindow(title, x, y, w, h, window_flags); 127 + p->win = SDL_CreateWindow(p->udgci.window_title, x, y, w, h, window_flags); 125 128 if (p->win == NULL) { 126 129 U_LOG_E("Failed to create window!"); 127 130 return; ··· 340 343 } 341 344 342 345 int 343 - u_debug_gui_create(struct u_debug_gui **out_debug_gui) 346 + u_debug_gui_create(const struct u_debug_gui_create_info *udgci, struct u_debug_gui **out_debug_gui) 344 347 { 345 348 XRT_TRACE_MARKER(); 346 349 347 - // Enabled? 348 - if (!debug_get_bool_option_gui()) { 349 - return 0; 350 + switch (udgci->open) { 351 + case U_DEBUG_GUI_OPEN_AUTO: 352 + if (!debug_get_bool_option_gui()) { 353 + return 0; 354 + } 355 + break; 356 + case U_DEBUG_GUI_OPEN_ALWAYS: break; 357 + case U_DEBUG_GUI_OPEN_NEVER: return 0; // No-op 350 358 } 351 359 352 360 // Need to do this as early as possible. ··· 356 364 if (p == NULL) { 357 365 return -1; 358 366 } 367 + 368 + // Copy the data. 369 + p->udgci = *udgci; 359 370 360 371 os_thread_helper_init(&p->oth); 361 372
+56 -1
src/xrt/auxiliary/util/u_debug_gui.h
··· 1 1 // Copyright 2019-2023, Collabora, Ltd. 2 + // Copyright 2024-2025, NVIDIA CORPORATION. 2 3 // SPDX-License-Identifier: BSL-1.0 3 4 /*! 4 5 * @file ··· 16 17 extern "C" { 17 18 #endif 18 19 20 + #define U_DEBUG_GUI_WINDOW_TITLE_MAX (256) 21 + 19 22 struct xrt_instance; 20 23 struct xrt_system_devices; 21 24 22 25 struct u_debug_gui; 23 26 27 + /*! 28 + * Controls if the debug gui window is opened, allowing code to always call 29 + * create and progmatically or external control if the window is opened. 30 + * 31 + * @ingroup aux_util 32 + */ 33 + enum u_debug_gui_open 34 + { 35 + //! Opens the window if the environmental variable XRT_DEBUG_GUI is true. 36 + U_DEBUG_GUI_OPEN_AUTO, 37 + //! Always (if supported) opens the window. 38 + U_DEBUG_GUI_OPEN_ALWAYS, 39 + //! Never opens the window. 40 + U_DEBUG_GUI_OPEN_NEVER, 41 + }; 42 + 43 + /*! 44 + * Argument to the function @ref u_debug_gui_create. 45 + * 46 + * @ingroup aux_util 47 + */ 48 + struct u_debug_gui_create_info 49 + { 50 + char window_title[U_DEBUG_GUI_WINDOW_TITLE_MAX]; 51 + 52 + enum u_debug_gui_open open; 53 + }; 54 + 55 + /*! 56 + * Creates the debug gui, may not create it. 57 + * 58 + * If the debug gui is disabled through the means listed below this function 59 + * will return 0, but not create any struct and set @p out_debug_gui to NULL. 60 + * It is safe to call the other functions with a NULL @p debug_gui argument. 61 + * 62 + * The window will be disabled and 0 returned if: 63 + * * Monado was compiled without the needed dependencies, like SDL. 64 + * * The @p open field on the info struct set to NEVER. 65 + * * The XRT_DEBUG_GUI env variable is false (or unset). 66 + * 67 + * @ingroup aux_util 68 + */ 24 69 int 25 - u_debug_gui_create(struct u_debug_gui **out_debug_gui); 70 + u_debug_gui_create(const struct u_debug_gui_create_info *info, struct u_debug_gui **out_debug_gui); 26 71 72 + /*! 73 + * Starts the debug gui, also passes in some structs that might be needed. 74 + * 75 + * @ingroup aux_util 76 + */ 27 77 void 28 78 u_debug_gui_start(struct u_debug_gui *debug_gui, struct xrt_instance *xinst, struct xrt_system_devices *xsysd); 29 79 80 + /*! 81 + * Stops the debug gui, closing the window and freeing resources. 82 + * 83 + * @ingroup aux_util 84 + */ 30 85 void 31 86 u_debug_gui_stop(struct u_debug_gui **debug_gui); 32 87
+8 -1
src/xrt/ipc/server/ipc_server_process.c
··· 1 1 // Copyright 2020-2024, Collabora, Ltd. 2 + // Copyright 2024-2025, NVIDIA CORPORATION. 2 3 // SPDX-License-Identifier: BSL-1.0 3 4 /*! 4 5 * @file ··· 1018 1019 timeBeginPeriod(1); 1019 1020 #endif 1020 1021 1022 + struct u_debug_gui_info udgci = { 1023 + .window_title = "Monado! ✨⚡🔥", 1024 + .open = U_DEBUG_GUI_OPEN_AUTO, 1025 + }; 1026 + 1021 1027 /* 1022 1028 * Need to create early before any vars are added. Not created in 1023 1029 * init_all since that function is shared with Android and the debug 1024 1030 * GUI isn't supported on Android. 1025 1031 */ 1026 - u_debug_gui_create(&s->debug_gui); 1032 + u_debug_gui_create(&udgci, &s->debug_gui); 1033 + 1027 1034 1028 1035 int ret = init_all(s, log_level); 1029 1036 if (ret < 0) {
+7 -1
src/xrt/state_trackers/oxr/oxr_instance.c
··· 1 1 // Copyright 2018-2024, Collabora, Ltd. 2 + // Copyright 2024-2025, NVIDIA CORPORATION. 2 3 // SPDX-License-Identifier: BSL-1.0 3 4 /*! 4 5 * @file ··· 250 251 } 251 252 252 253 #ifdef XRT_FEATURE_CLIENT_DEBUG_GUI 253 - u_debug_gui_create(&inst->debug_ui); 254 + struct u_debug_gui_create_info udgci = { 255 + .window_title = "Monado! ✨⚡🔥", 256 + .open = U_DEBUG_GUI_OPEN_AUTO, 257 + }; 258 + 259 + u_debug_gui_create(&udgci, &inst->debug_ui); 254 260 #endif 255 261 256 262 ret = oxr_path_init(log, inst);
+1 -1
src/xrt/targets/sdl_test/sdl_hack_stubs.c
··· 13 13 14 14 15 15 int 16 - u_debug_gui_create(void **out_hack) 16 + u_debug_gui_create(void *hack, void **out_hack) 17 17 { 18 18 return 0; 19 19 }