The open source OpenXR runtime

xrt: Refactor oxr_sdl2_hack to u_debug_gui

And OXR_DEBUG_GUI to XRT_DEBUG_GUI

Co-authored-by: Jakob Bornecrantz <jakob@collabora.com>

+145 -120
+4 -2
CMakeLists.txt
··· 269 option_with_deps(XRT_FEATURE_STEAMVR_PLUGIN "Build SteamVR plugin" DEPENDS "NOT ANDROID") 270 option_with_deps(XRT_FEATURE_TRACING "Enable debug tracing on supported platforms" DEFAULT OFF DEPENDS "XRT_HAVE_PERCETTO OR XRT_HAVE_TRACY") 271 option_with_deps(XRT_FEATURE_WINDOW_PEEK "Enable a window that displays the content of the HMD on screen" DEPENDS XRT_HAVE_SDL2) 272 option(XRT_FEATURE_SSE2 "Build using SSE2 instructions, if building for 32-bit x86" ON) 273 274 if (XRT_FEATURE_SERVICE) 275 # Disable the client debug gui by default for out-of-proc - 276 # too many clients have problems with depending on SDL/GStreamer/etc and we rarely use it in this configuration 277 - option(XRT_FEATURE_CLIENT_DEBUG_GUI "Allow clients to have their own instances of the debug gui" OFF) 278 else() 279 # Enable the client debug gui by default for in-proc - 280 # In in-proc, the client debug gui is the same as the server debug gui, and we use it a lot in this configuration 281 - option(XRT_FEATURE_CLIENT_DEBUG_GUI "Allow clients to have their own instances of the debug gui" ON) 282 endif() 283 284 # systemd detailed config ··· 526 message(STATUS "#") 527 message(STATUS "# FEATURE_CLIENT_DEBUG_GUI: ${XRT_FEATURE_CLIENT_DEBUG_GUI}") 528 message(STATUS "# FEATURE_COLOR_LOG: ${XRT_FEATURE_COLOR_LOG}") 529 message(STATUS "# FEATURE_MERCURY_HANDTRACKING: ${XRT_MODULE_MERCURY_HANDTRACKING}") 530 message(STATUS "# FEATURE_OPENXR: ${XRT_FEATURE_OPENXR}") 531 message(STATUS "# FEATURE_OPENXR_LAYER_CUBE: ${XRT_FEATURE_OPENXR_LAYER_CUBE}")
··· 269 option_with_deps(XRT_FEATURE_STEAMVR_PLUGIN "Build SteamVR plugin" DEPENDS "NOT ANDROID") 270 option_with_deps(XRT_FEATURE_TRACING "Enable debug tracing on supported platforms" DEFAULT OFF DEPENDS "XRT_HAVE_PERCETTO OR XRT_HAVE_TRACY") 271 option_with_deps(XRT_FEATURE_WINDOW_PEEK "Enable a window that displays the content of the HMD on screen" DEPENDS XRT_HAVE_SDL2) 272 + option_with_deps(XRT_FEATURE_DEBUG_GUI "Enable debug window to be used" DEPENDS XRT_HAVE_SDL2) 273 option(XRT_FEATURE_SSE2 "Build using SSE2 instructions, if building for 32-bit x86" ON) 274 275 if (XRT_FEATURE_SERVICE) 276 # Disable the client debug gui by default for out-of-proc - 277 # too many clients have problems with depending on SDL/GStreamer/etc and we rarely use it in this configuration 278 + option_with_deps(XRT_FEATURE_CLIENT_DEBUG_GUI "Allow clients to have their own instances of the debug gui" DEFAULT OFF DEPENDS XRT_FEATURE_DEBUG_GUI) 279 else() 280 # Enable the client debug gui by default for in-proc - 281 # In in-proc, the client debug gui is the same as the server debug gui, and we use it a lot in this configuration 282 + option_with_deps(XRT_FEATURE_CLIENT_DEBUG_GUI "Allow clients to have their own instances of the debug gui" DEFAULT ON DEPENDS XRT_FEATURE_DEBUG_GUI) 283 endif() 284 285 # systemd detailed config ··· 527 message(STATUS "#") 528 message(STATUS "# FEATURE_CLIENT_DEBUG_GUI: ${XRT_FEATURE_CLIENT_DEBUG_GUI}") 529 message(STATUS "# FEATURE_COLOR_LOG: ${XRT_FEATURE_COLOR_LOG}") 530 + message(STATUS "# FEATURE_DEBUG_GUI: ${XRT_FEATURE_DEBUG_GUI}") 531 message(STATUS "# FEATURE_MERCURY_HANDTRACKING: ${XRT_MODULE_MERCURY_HANDTRACKING}") 532 message(STATUS "# FEATURE_OPENXR: ${XRT_FEATURE_OPENXR}") 533 message(STATUS "# FEATURE_OPENXR_LAYER_CUBE: ${XRT_FEATURE_OPENXR_LAYER_CUBE}")
+31
src/xrt/auxiliary/util/CMakeLists.txt
··· 142 target_include_directories(aux_util PRIVATE ${EIGEN3_INCLUDE_DIR}) 143 144 #### 145 # Sink library 146 # 147
··· 142 target_include_directories(aux_util PRIVATE ${EIGEN3_INCLUDE_DIR}) 143 144 #### 145 + # Debug UI library 146 + # 147 + 148 + add_library(aux_util_debug_gui STATIC u_debug_gui.c u_debug_gui.h) # Always built, for stubs. 149 + target_link_libraries( 150 + aux_util_debug_gui 151 + INTERFACE xrt-interfaces 152 + PRIVATE aux-includes 153 + ) 154 + 155 + if(XRT_FEATURE_DEBUG_GUI) 156 + target_link_libraries(aux_util_debug_gui PRIVATE aux_util) 157 + 158 + if(XRT_HAVE_OPENGL) 159 + target_link_libraries(aux_util_debug_gui PUBLIC aux_ogl) 160 + endif() 161 + 162 + if(XRT_HAVE_SDL2) 163 + target_link_libraries( 164 + aux_util_debug_gui PRIVATE st_gui xrt-external-imgui-sdl2 ${SDL2_LIBRARIES} 165 + ) 166 + 167 + if(XRT_BUILD_DRIVER_QWERTY) 168 + target_link_libraries( 169 + aux_util_debug_gui PRIVATE drv_qwerty drv_qwerty_includes 170 + ) 171 + endif() 172 + endif() 173 + endif() 174 + 175 + #### 176 # Sink library 177 # 178
+36
src/xrt/auxiliary/util/u_debug_gui.h
···
··· 1 + // Copyright 2019-2023, Collabora, Ltd. 2 + // SPDX-License-Identifier: BSL-1.0 3 + /*! 4 + * @file 5 + * @brief SDL2 Debug UI implementation 6 + * @author Jakob Bornecrantz <jakob@collabora.com> 7 + * @author Moses Turner <moses@collabora.com> 8 + */ 9 + 10 + #pragma once 11 + 12 + #include "xrt/xrt_compiler.h" 13 + 14 + 15 + #ifdef __cplusplus 16 + extern "C" { 17 + #endif 18 + 19 + struct xrt_instance; 20 + struct xrt_system_devices; 21 + 22 + struct u_debug_gui; 23 + 24 + int 25 + u_debug_gui_create(struct u_debug_gui **out_debug_gui); 26 + 27 + void 28 + u_debug_gui_start(struct u_debug_gui *debug_gui, struct xrt_instance *xinst, struct xrt_system_devices *xsysd); 29 + 30 + void 31 + u_debug_gui_stop(struct u_debug_gui **debug_gui); 32 + 33 + 34 + #ifdef __cplusplus 35 + } 36 + #endif
+1
src/xrt/include/xrt/xrt_config_build.h.cmake_in
··· 21 /* keep sorted */ 22 23 #cmakedefine XRT_FEATURE_COLOR_LOG 24 #cmakedefine XRT_FEATURE_OPENXR 25 #cmakedefine XRT_FEATURE_OPENXR_DEBUG_UTILS 26 #cmakedefine XRT_FEATURE_OPENXR_LAYER_CUBE
··· 21 /* keep sorted */ 22 23 #cmakedefine XRT_FEATURE_COLOR_LOG 24 + #cmakedefine XRT_FEATURE_DEBUG_GUI 25 #cmakedefine XRT_FEATURE_OPENXR 26 #cmakedefine XRT_FEATURE_OPENXR_DEBUG_UTILS 27 #cmakedefine XRT_FEATURE_OPENXR_LAYER_CUBE
+1 -1
src/xrt/ipc/CMakeLists.txt
··· 92 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} 93 PRIVATE ${CMAKE_CURRENT_BINARY_DIR} 94 ) 95 - target_link_libraries(ipc_server PRIVATE aux_util aux_util_process ipc_shared) 96 97 if(XRT_HAVE_SYSTEMD) 98 target_include_directories(ipc_server PRIVATE ${SYSTEMD_INCLUDE_DIRS})
··· 92 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} 93 PRIVATE ${CMAKE_CURRENT_BINARY_DIR} 94 ) 95 + target_link_libraries(ipc_server PRIVATE aux_util aux_util_process aux_util_debug_gui ipc_shared) 96 97 if(XRT_HAVE_SYSTEMD) 98 target_include_directories(ipc_server PRIVATE ${SYSTEMD_INCLUDE_DIRS})
+1 -3
src/xrt/ipc/server/ipc_server.h
··· 295 //! Handle for the current process, e.g. pidfile on linux 296 struct u_process *process; 297 298 - /* ---- HACK ---- */ 299 - void *hack; 300 - /* ---- HACK ---- */ 301 302 //! System devices. 303 struct xrt_system_devices *xsysd;
··· 295 //! Handle for the current process, e.g. pidfile on linux 296 struct u_process *process; 297 298 + struct u_debug_gui *debug_gui; 299 300 //! System devices. 301 struct xrt_system_devices *xsysd;
+5 -22
src/xrt/ipc/server/ipc_server_process.c
··· 23 #include "util/u_trace_marker.h" 24 #include "util/u_verify.h" 25 #include "util/u_process.h" 26 27 #include "util/u_git_tag.h" 28 ··· 39 #include <stdio.h> 40 #include <string.h> 41 #include <assert.h> 42 - 43 - /* ---- HACK ---- */ 44 - extern int 45 - oxr_sdl2_hack_create(void **out_hack); 46 - 47 - extern void 48 - oxr_sdl2_hack_start(void *hack, struct xrt_instance *xinst, struct xrt_system_devices *xsysd); 49 - 50 - extern void 51 - oxr_sdl2_hack_stop(void **hack_ptr); 52 - /* ---- HACK ---- */ 53 - 54 55 /* 56 * ··· 789 790 U_LOG_I("Monado Service %s starting up...", u_git_tag); 791 792 - /* ---- HACK ---- */ 793 // need to create early before any vars are added 794 - oxr_sdl2_hack_create(&s->hack); 795 - /* ---- HACK ---- */ 796 797 int ret = init_all(s); 798 if (ret < 0) { 799 - free(s->hack); 800 free(s); 801 return ret; 802 } 803 804 init_server_state(s); 805 806 - /* ---- HACK ---- */ 807 - oxr_sdl2_hack_start(s->hack, s->xinst, s->xsysd); 808 - /* ---- HACK ---- */ 809 810 ret = main_loop(s); 811 812 - /* ---- HACK ---- */ 813 - oxr_sdl2_hack_stop(&s->hack); 814 - /* ---- HACK ---- */ 815 816 teardown_all(s); 817 free(s);
··· 23 #include "util/u_trace_marker.h" 24 #include "util/u_verify.h" 25 #include "util/u_process.h" 26 + #include "util/u_debug_gui.h" 27 28 #include "util/u_git_tag.h" 29 ··· 40 #include <stdio.h> 41 #include <string.h> 42 #include <assert.h> 43 44 /* 45 * ··· 778 779 U_LOG_I("Monado Service %s starting up...", u_git_tag); 780 781 // need to create early before any vars are added 782 + u_debug_gui_create(&s->debug_gui); 783 784 int ret = init_all(s); 785 if (ret < 0) { 786 + free(s->debug_gui); 787 free(s); 788 return ret; 789 } 790 791 init_server_state(s); 792 793 + u_debug_gui_start(s->debug_gui, s->xinst, s->xsysd); 794 795 ret = main_loop(s); 796 797 + u_debug_gui_stop(&s->debug_gui); 798 799 teardown_all(s); 800 free(s);
+7 -22
src/xrt/state_trackers/oxr/oxr_instance.c
··· 19 #include "util/u_git_tag.h" 20 #include "util/u_builders.h" 21 22 #ifdef XRT_OS_ANDROID 23 #include "android/android_globals.h" 24 #include "android/android_looper.h" ··· 49 DEBUG_GET_ONCE_FLOAT_OPTION(tracking_origin_offset_y, "OXR_TRACKING_ORIGIN_OFFSET_Y", 0.0f) 50 DEBUG_GET_ONCE_FLOAT_OPTION(tracking_origin_offset_z, "OXR_TRACKING_ORIGIN_OFFSET_Z", 0.0f) 51 52 - #ifdef XRT_FEATURE_CLIENT_DEBUG_GUI 53 - /* ---- HACK ---- */ 54 - extern int 55 - oxr_sdl2_hack_create(void **out_hack); 56 - 57 - extern void 58 - oxr_sdl2_hack_start(void *hack, struct xrt_instance *xinst, struct xrt_system_devices *xsysd); 59 - 60 - extern void 61 - oxr_sdl2_hack_stop(void **hack_ptr); 62 - /* ---- HACK ---- */ 63 - #endif 64 - 65 static XrResult 66 oxr_instance_destroy(struct oxr_logger *log, struct oxr_handle_base *hb) 67 { ··· 82 xrt_system_devices_destroy(&inst->system.xsysd); 83 84 #ifdef XRT_FEATURE_CLIENT_DEBUG_GUI 85 - /* ---- HACK ---- */ 86 - oxr_sdl2_hack_stop(&inst->hack); 87 - /* ---- HACK ---- */ 88 #endif 89 90 xrt_instance_destroy(&inst->xinst); ··· 204 } 205 206 #ifdef XRT_FEATURE_CLIENT_DEBUG_GUI 207 - /* ---- HACK ---- */ 208 - oxr_sdl2_hack_create(&inst->hack); 209 - /* ---- HACK ---- */ 210 #endif 211 212 ret = oxr_path_init(log, inst); ··· 343 u_var_add_root((void *)inst, "XrInstance", true); 344 345 #ifdef XRT_FEATURE_CLIENT_DEBUG_GUI 346 - /* ---- HACK ---- */ 347 - oxr_sdl2_hack_start(inst->hack, inst->xinst, sys->xsysd); 348 - /* ---- HACK ---- */ 349 #endif 350 351 oxr_log(log,
··· 19 #include "util/u_git_tag.h" 20 #include "util/u_builders.h" 21 22 + #ifdef XRT_FEATURE_CLIENT_DEBUG_GUI 23 + #include "util/u_debug_gui.h" 24 + #endif 25 + 26 #ifdef XRT_OS_ANDROID 27 #include "android/android_globals.h" 28 #include "android/android_looper.h" ··· 53 DEBUG_GET_ONCE_FLOAT_OPTION(tracking_origin_offset_y, "OXR_TRACKING_ORIGIN_OFFSET_Y", 0.0f) 54 DEBUG_GET_ONCE_FLOAT_OPTION(tracking_origin_offset_z, "OXR_TRACKING_ORIGIN_OFFSET_Z", 0.0f) 55 56 static XrResult 57 oxr_instance_destroy(struct oxr_logger *log, struct oxr_handle_base *hb) 58 { ··· 73 xrt_system_devices_destroy(&inst->system.xsysd); 74 75 #ifdef XRT_FEATURE_CLIENT_DEBUG_GUI 76 + u_debug_gui_stop(&inst->debug_ui); 77 #endif 78 79 xrt_instance_destroy(&inst->xinst); ··· 193 } 194 195 #ifdef XRT_FEATURE_CLIENT_DEBUG_GUI 196 + u_debug_gui_create(&inst->debug_ui); 197 #endif 198 199 ret = oxr_path_init(log, inst); ··· 330 u_var_add_root((void *)inst, "XrInstance", true); 331 332 #ifdef XRT_FEATURE_CLIENT_DEBUG_GUI 333 + u_debug_gui_start(inst->debug_ui, inst->xinst, sys->xsysd); 334 #endif 335 336 oxr_log(log,
+1 -3
src/xrt/state_trackers/oxr/oxr_objects.h
··· 1360 //! Common structure for things referred to by OpenXR handles. 1361 struct oxr_handle_base handle; 1362 1363 - /* ---- HACK ---- */ 1364 - void *hack; 1365 - /* ---- HACK ---- */ 1366 1367 struct xrt_instance *xinst; 1368
··· 1360 //! Common structure for things referred to by OpenXR handles. 1361 struct oxr_handle_base handle; 1362 1363 + struct u_debug_gui *debug_ui; 1364 1365 struct xrt_instance *xinst; 1366
+2 -16
src/xrt/targets/openxr/CMakeLists.txt
··· 130 ) 131 endif() 132 133 - ### 134 - # Inelegant but effective SDL2-based debug GUI 135 - add_library(oxr_sdl2 STATIC oxr_sdl2_hack.c) 136 - target_link_libraries(oxr_sdl2 PRIVATE aux_util) 137 - if(XRT_HAVE_OPENGL) 138 - target_link_libraries(oxr_sdl2 PUBLIC aux_ogl) 139 - endif() 140 - if(XRT_HAVE_SDL2) 141 - target_link_libraries(oxr_sdl2 PRIVATE st_gui xrt-external-imgui-sdl2 ${SDL2_LIBRARIES}) 142 - 143 - if(XRT_BUILD_DRIVER_QWERTY) 144 - target_link_libraries(oxr_sdl2 PRIVATE drv_qwerty drv_qwerty_includes) 145 - endif() 146 - endif() 147 - 148 if(XRT_FEATURE_CLIENT_DEBUG_GUI) 149 - target_link_libraries(${RUNTIME_TARGET} PRIVATE oxr_sdl2) 150 endif()
··· 130 ) 131 endif() 132 133 + # Optional debug ui 134 if(XRT_FEATURE_CLIENT_DEBUG_GUI) 135 + target_link_libraries(${RUNTIME_TARGET} PRIVATE aux_util_debug_gui) 136 endif()
+52 -47
src/xrt/targets/openxr/oxr_sdl2_hack.c src/xrt/auxiliary/util/u_debug_gui.c
··· 1 - // Copyright 2019, Collabora, Ltd. 2 // SPDX-License-Identifier: BSL-1.0 3 /*! 4 * @file 5 - * @brief Hacky SDL integration 6 * @author Jakob Bornecrantz <jakob@collabora.com> 7 */ 8 9 - #include "util/u_file.h" 10 - #include "xrt/xrt_compiler.h" 11 - #include "xrt/xrt_instance.h" 12 - #include "xrt/xrt_config_have.h" 13 - #include "xrt/xrt_config_drivers.h" 14 15 - #include "util/u_var.h" 16 - #include "util/u_misc.h" 17 - #include "util/u_debug.h" 18 19 - #include "os/os_threading.h" 20 - 21 - 22 - struct xrt_instance; 23 - 24 - #ifndef XRT_HAVE_SDL2 25 26 int 27 - oxr_sdl2_hack_create(void **out_hack) 28 { 29 return 0; 30 } 31 32 void 33 - oxr_sdl2_hack_start(void *hack, struct xrt_instance *xinst, struct xrt_system_devices *xsysd) 34 - {} 35 36 void 37 - oxr_sdl2_hack_stop(void **hack) 38 - {} 39 40 - #else 41 #include "xrt/xrt_system.h" 42 #include "ogl/ogl_api.h" 43 44 #include "gui/gui_common.h" ··· 50 51 #include <SDL2/SDL.h> 52 53 - DEBUG_GET_ONCE_BOOL_OPTION(gui, "OXR_DEBUG_GUI", false) 54 #ifdef XRT_BUILD_DRIVER_QWERTY 55 DEBUG_GET_ONCE_BOOL_OPTION(qwerty_enable, "QWERTY_ENABLE", false) 56 #endif ··· 60 * Common struct holding state for the GUI interface. 61 * @extends gui_program 62 */ 63 - struct sdl2_program 64 { 65 struct gui_program base; 66 ··· 81 }; 82 83 static void 84 - sdl2_window_init(struct sdl2_program *p) 85 { 86 const char *title = "Monado! ✨⚡🔥"; 87 int x = SDL_WINDOWPOS_UNDEFINED; ··· 137 } 138 139 static void 140 - sdl2_loop(struct sdl2_program *p) 141 { 142 // Need to call this before any other Imgui call. 143 igCreateContext(NULL); ··· 251 } 252 253 static void 254 - sdl2_close(struct sdl2_program *p) 255 { 256 // All scenes should be destroyed by now. 257 gui_scene_manager_destroy(&p->base); ··· 276 } 277 278 static void * 279 - oxr_sdl2_hack_run_thread(void *ptr) 280 { 281 - struct sdl2_program *p = (struct sdl2_program *)ptr; 282 - 283 - sdl2_window_init(p); 284 285 - sdl2_loop(p); 286 287 - sdl2_close(p); 288 289 return NULL; 290 } 291 292 int 293 - oxr_sdl2_hack_create(void **out_hack) 294 { 295 // Enabled? 296 if (!debug_get_bool_option_gui()) { ··· 300 // Need to do this as early as possible. 301 u_var_force_on(); 302 303 - struct sdl2_program *p = U_TYPED_CALLOC(struct sdl2_program); 304 if (p == NULL) { 305 return -1; 306 } 307 308 os_thread_helper_init(&p->oth); 309 310 - *out_hack = p; 311 312 return 0; 313 } 314 315 void 316 - oxr_sdl2_hack_start(void *hack, struct xrt_instance *xinst, struct xrt_system_devices *xsysd) 317 { 318 - struct sdl2_program *p = (struct sdl2_program *)hack; 319 - if (p == NULL) { 320 return; 321 } 322 323 // Share the system devices. 324 - p->base.xsysd = xsysd; 325 326 if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { 327 U_LOG_E("Failed to init SDL2!"); 328 return; 329 } 330 - p->sdl_initialized = true; 331 332 - (void)os_thread_helper_start(&p->oth, oxr_sdl2_hack_run_thread, p); 333 } 334 335 void 336 - oxr_sdl2_hack_stop(void **hack_ptr) 337 { 338 - struct sdl2_program *p = *(struct sdl2_program **)hack_ptr; 339 if (p == NULL) { 340 return; 341 } 342 343 - // HACK! 344 p->base.stopped = true; 345 346 // Destroy the thread object. 347 os_thread_helper_destroy(&p->oth); 348 349 free(p); 350 - *hack_ptr = NULL; 351 } 352 - #endif
··· 1 + // Copyright 2019-2023, Collabora, Ltd. 2 // SPDX-License-Identifier: BSL-1.0 3 /*! 4 * @file 5 + * @brief SDL2 Debug UI implementation 6 * @author Jakob Bornecrantz <jakob@collabora.com> 7 + * @author Moses Turner <moses@collabora.com> 8 */ 9 10 + #include "xrt/xrt_config_build.h" 11 12 + #ifndef XRT_FEATURE_DEBUG_GUI 13 14 + #include "util/u_debug_gui.h" 15 16 int 17 + u_debug_gui_create(struct u_debug_gui **out_debug_ui) 18 { 19 return 0; 20 } 21 22 void 23 + u_debug_gui_start(struct u_debug_gui *debug_ui, struct xrt_instance *xinst, struct xrt_system_devices *xsysd) 24 + { 25 + // No-op 26 + } 27 28 void 29 + u_debug_gui_stop(struct u_debug_gui **debug_ui) 30 + { 31 + // No-op 32 + } 33 + 34 + #else /* XRT_FEATURE_DEBUG_GUI */ 35 36 #include "xrt/xrt_system.h" 37 + #include "xrt/xrt_instance.h" 38 + #include "xrt/xrt_config_have.h" 39 + #include "xrt/xrt_config_drivers.h" 40 + 41 + #include "os/os_threading.h" 42 + 43 + #include "util/u_var.h" 44 + #include "util/u_misc.h" 45 + #include "util/u_file.h" 46 + #include "util/u_debug.h" 47 + #include "util/u_debug_gui.h" 48 + 49 #include "ogl/ogl_api.h" 50 51 #include "gui/gui_common.h" ··· 57 58 #include <SDL2/SDL.h> 59 60 + DEBUG_GET_ONCE_BOOL_OPTION(gui, "XRT_DEBUG_GUI", false) 61 #ifdef XRT_BUILD_DRIVER_QWERTY 62 DEBUG_GET_ONCE_BOOL_OPTION(qwerty_enable, "QWERTY_ENABLE", false) 63 #endif ··· 67 * Common struct holding state for the GUI interface. 68 * @extends gui_program 69 */ 70 + struct u_debug_gui 71 { 72 struct gui_program base; 73 ··· 88 }; 89 90 static void 91 + sdl2_window_init(struct u_debug_gui *p) 92 { 93 const char *title = "Monado! ✨⚡🔥"; 94 int x = SDL_WINDOWPOS_UNDEFINED; ··· 144 } 145 146 static void 147 + sdl2_loop(struct u_debug_gui *p) 148 { 149 // Need to call this before any other Imgui call. 150 igCreateContext(NULL); ··· 258 } 259 260 static void 261 + sdl2_close(struct u_debug_gui *p) 262 { 263 // All scenes should be destroyed by now. 264 gui_scene_manager_destroy(&p->base); ··· 283 } 284 285 static void * 286 + u_debug_gui_run_thread(void *ptr) 287 { 288 + struct u_debug_gui *debug_gui = (struct u_debug_gui *)ptr; 289 + sdl2_window_init(debug_gui); 290 291 + sdl2_loop(debug_gui); 292 293 + sdl2_close(debug_gui); 294 295 return NULL; 296 } 297 298 int 299 + u_debug_gui_create(struct u_debug_gui **out_debug_gui) 300 { 301 // Enabled? 302 if (!debug_get_bool_option_gui()) { ··· 306 // Need to do this as early as possible. 307 u_var_force_on(); 308 309 + struct u_debug_gui *p = U_TYPED_CALLOC(struct u_debug_gui); 310 if (p == NULL) { 311 return -1; 312 } 313 314 os_thread_helper_init(&p->oth); 315 316 + *out_debug_gui = p; 317 318 return 0; 319 } 320 321 void 322 + u_debug_gui_start(struct u_debug_gui *debug_gui, struct xrt_instance *xinst, struct xrt_system_devices *xsysd) 323 { 324 + if (debug_gui == NULL) { 325 return; 326 } 327 328 // Share the system devices. 329 + debug_gui->base.xsysd = xsysd; 330 331 if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { 332 U_LOG_E("Failed to init SDL2!"); 333 return; 334 } 335 + debug_gui->sdl_initialized = true; 336 337 + (void)os_thread_helper_start(&debug_gui->oth, u_debug_gui_run_thread, (void *)debug_gui); 338 } 339 340 void 341 + u_debug_gui_stop(struct u_debug_gui **debug_gui) 342 { 343 + struct u_debug_gui *p = *(struct u_debug_gui **)debug_gui; 344 if (p == NULL) { 345 return; 346 } 347 348 p->base.stopped = true; 349 350 // Destroy the thread object. 351 os_thread_helper_destroy(&p->oth); 352 353 free(p); 354 + *debug_gui = NULL; 355 } 356 + 357 + #endif /* XRT_FEATURE_DEBUG_GUI */
+3 -3
src/xrt/targets/sdl_test/sdl_hack_stubs.c
··· 13 14 15 int 16 - oxr_sdl2_hack_create(void **out_hack) 17 { 18 return 0; 19 } 20 21 void 22 - oxr_sdl2_hack_start(void *hack, struct xrt_instance *xinst, struct xrt_system_devices *xsysd) 23 { 24 // Noop 25 } 26 27 void 28 - oxr_sdl2_hack_stop(void **hack) 29 { 30 // Noop 31 }
··· 13 14 15 int 16 + u_debug_gui_create(void **out_hack) 17 { 18 return 0; 19 } 20 21 void 22 + u_debug_gui_start(void *hack, struct xrt_instance *xinst, struct xrt_system_devices *xsysd) 23 { 24 // Noop 25 } 26 27 void 28 + u_debug_gui_stop(void **hack) 29 { 30 // Noop 31 }
+1 -1
src/xrt/targets/service/CMakeLists.txt
··· 8 monado-service 9 PRIVATE 10 aux_util 11 st_prober 12 ipc_server 13 target_lists 14 target_instance 15 - oxr_sdl2 16 ) 17 18 install(TARGETS monado-service RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
··· 8 monado-service 9 PRIVATE 10 aux_util 11 + aux_util_debug_gui 12 st_prober 13 ipc_server 14 target_lists 15 target_instance 16 ) 17 18 install(TARGETS monado-service RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})