From e9293d8b6e4357f75a0a48d935814e59f8577e89 Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Sun, 14 Apr 2024 15:02:14 +0200 Subject: [PATCH] Handle reodered tracking packets better --- ...-Install-libopenxr-in-a-subdirectory.patch | 76 +++++++++++++++++++ server/CMakeLists.txt | 4 +- server/driver/history.h | 7 ++ 3 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 patches/monado/0004-t-oxr-Install-libopenxr-in-a-subdirectory.patch diff --git a/patches/monado/0004-t-oxr-Install-libopenxr-in-a-subdirectory.patch b/patches/monado/0004-t-oxr-Install-libopenxr-in-a-subdirectory.patch new file mode 100644 index 00000000..4f1e5466 --- /dev/null +++ b/patches/monado/0004-t-oxr-Install-libopenxr-in-a-subdirectory.patch @@ -0,0 +1,76 @@ +From 3dbcae473ee48cf4128c0f752a5b1bbc3a80e1ed Mon Sep 17 00:00:00 2001 +From: Patrick Nicolas +Date: Sun, 14 Apr 2024 09:56:50 +0200 +Subject: [PATCH] t/oxr Install libopenxr in a subdirectory + +--- + CMakeLists.txt | 6 +++--- + src/xrt/targets/openxr/CMakeLists.txt | 15 +++++++-------- + 2 files changed, 10 insertions(+), 11 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 4bc420755..98c317181 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -332,9 +332,9 @@ option_with_deps(XRT_BUILD_DRIVER_SIMULAVR "Enable simula driver" DEPENDS XRT_HA + option(XRT_BUILD_DRIVER_SIMULATED "Enable simulated driver" ON) + + option(XRT_BUILD_SAMPLES "Enable compiling sample code implementations that will not be linked into any final targets" ON) +-set(XRT_IPC_MSG_SOCK_FILENAME monado_comp_ipc CACHE STRING "Service socket filename") +-set(XRT_IPC_SERVICE_PID_FILENAME monado.pid CACHE STRING "Service pidfile filename") +-set(XRT_OXR_RUNTIME_SUFFIX monado CACHE STRING "OpenXR client library suffix") ++set(XRT_OXR_RUNTIME_NAME monado CACHE STRING "Runtime name used to derive other filenames") ++set(XRT_IPC_MSG_SOCK_FILENAME ${XRT_OXR_RUNTIME_NAME}_comp_ipc CACHE STRING "Service socket filename") ++set(XRT_IPC_SERVICE_PID_FILENAME ${XRT_OXR_RUNTIME_NAME}.pid CACHE STRING "Service pidfile filename") + + # cmake-format: on + +diff --git a/src/xrt/targets/openxr/CMakeLists.txt b/src/xrt/targets/openxr/CMakeLists.txt +index 15a6963aa..410364550 100644 +--- a/src/xrt/targets/openxr/CMakeLists.txt ++++ b/src/xrt/targets/openxr/CMakeLists.txt +@@ -4,11 +4,9 @@ + ###### + # Create a loadable OpenXR driver. + +-set(RUNTIME_SUFFIX _${XRT_OXR_RUNTIME_SUFFIX}) +- + set(RUNTIME_TARGET +- ${RUNTIME_PREFIX}openxr${RUNTIME_SUFFIX} +- CACHE INTERNAL "" FORCE ++ ${RUNTIME_PREFIX}openxr_${XRT_OXR_RUNTIME_NAME} ++ CACHE INTERNAL "" FORCE + ) + + # OpenXR 1.0 +@@ -111,22 +109,23 @@ elseif(NOT ANDROID) + install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/active_runtime.cmake) + endif() + ++ set(INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR}/${XRT_OXR_RUNTIME_NAME}) + set(_extra_args) + if(XRT_OPENXR_INSTALL_ABSOLUTE_RUNTIME_PATH) + set(_extra_args ABSOLUTE_RUNTIME_PATH) + elseif(XRT_OPENXR_INSTALL_MANIFEST_RELATIVE_RUNTIME_PATH) +- set(_extra_args RUNTIME_DIR_RELATIVE_TO_MANIFEST ../../../${CMAKE_INSTALL_LIBDIR}) ++ set(_extra_args RUNTIME_DIR_RELATIVE_TO_MANIFEST ../../../${INSTALL_LIBDIR}) + endif() + generate_openxr_runtime_manifest_at_install( + ${_extra_args} + RUNTIME_TARGET ${RUNTIME_TARGET} + DESTINATION share/openxr/${XR_API_MAJOR} +- RELATIVE_RUNTIME_DIR ${CMAKE_INSTALL_LIBDIR} ++ RELATIVE_RUNTIME_DIR ${INSTALL_LIBDIR} + ) + install( + TARGETS ${RUNTIME_TARGET} # +- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Runtime +- RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Runtime ++ LIBRARY DESTINATION ${INSTALL_LIBDIR} COMPONENT Runtime ++ RUNTIME DESTINATION ${INSTALL_LIBDIR} COMPONENT Runtime + ) + endif() + +-- +2.44.0 + diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index b1c2522f..ca051af3 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -42,9 +42,7 @@ set(BUILD_TESTING OFF) set(XRT_HAVE_SYSTEM_CJSON OFF) -set(XRT_IPC_MSG_SOCK_FILENAME "wivrn_comp_ipc" CACHE STRING "Service socket filename") -set(XRT_IPC_SERVICE_PID_FILENAME "wivrn.pid" CACHE STRING "Service pidfile filename") -set(XRT_OXR_RUNTIME_SUFFIX "wivrn" CACHE STRING "OpenXR client library suffix") +set(XRT_OXR_RUNTIME_NAME wivrn CACHE STRING "Runtime name used to derive other filenames") FetchContent_GetProperties(monado) if(NOT monado_POPULATED) diff --git a/server/driver/history.h b/server/driver/history.h index c7d5fb6f..5c64b902 100644 --- a/server/driver/history.h +++ b/server/driver/history.h @@ -44,6 +44,13 @@ protected: XrTime t = offset.from_headset(timestamp); std::lock_guard lock(mutex); + // Discard outdated data, packets could be reordered + if (not data.empty()) + { + if (data.back().produced_timestamp > produced) + return; + } + // Only keep one predicted value // It should be the last one if (not data.empty() and t != produced and data.back().at_timestamp_ns != data.back().produced_timestamp)