This commit is contained in:
Just some guy
2025-09-25 04:02:29 +00:00
committed by GitHub
8 changed files with 377 additions and 233 deletions
+85 -29
View File
@@ -18,12 +18,13 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
include(FetchContent)
include(ExternalProject)
include(GNUInstallDirs)
include("cmake/AutoOption.cmake")
option(WIVRN_USE_SYSTEM_FREETYPE "Use system FreeType" ON)
option(WIVRN_USE_SYSTEM_BOOST "Use system Boost headers" ON)
option(WIVRN_USE_SYSTEM_OPENXR "Use system OpenXR headers" ON)
option(WIVRN_USE_SYSTEMD "Use libsystemd" ON)
option(WIVRN_USE_LIBKTX "Use libktx" ${ANDROID})
auto_option(WIVRN_USE_SYSTEM_BOOST "Use system Boost headers" AUTO)
auto_option(WIVRN_USE_SYSTEM_OPENXR "Use system OpenXR headers" AUTO)
auto_option(WIVRN_USE_SYSTEMD "Use libsystemd" AUTO)
auto_option(WIVRN_USE_LIBKTX "Use libktx" AUTO)
option(WIVRN_USE_ANDROID_VALIDATION_LAYER "Download the android version of the Vulkan validation layer" OFF)
option(WIVRN_BUILD_CLIENT "Build WiVRn client" OFF)
option(WIVRN_BUILD_SERVER "Build WiVRn server" ON)
@@ -36,12 +37,12 @@ option(WIVRN_WERROR "Treat warnings as errors" OFF)
option(WIVRN_OPTIMIZE_SHADERS "Run siprv-opt on compiled shaders" ON)
option(WIVRN_USE_NVENC "Enable nvenc (Nvidia) hardware encoder" ON)
option(WIVRN_USE_VAAPI "Enable vaapi (AMD/Intel) hardware encoder" ON)
option(WIVRN_USE_VULKAN_ENCODE "Enable vulkan video encoder" ON)
option(WIVRN_USE_X264 "Enable x264 software encoder" ON)
auto_option(WIVRN_USE_VAAPI "Enable vaapi (AMD/Intel) hardware encoder" AUTO)
auto_option(WIVRN_USE_VULKAN_ENCODE "Enable vulkan video encoder" AUTO)
auto_option(WIVRN_USE_X264 "Enable x264 software encoder" AUTO)
option(WIVRN_USE_PIPEWIRE "Enable pipewire backend" ON)
option(WIVRN_USE_PULSEAUDIO "Enable pulseaudio backend" OFF)
auto_option(WIVRN_USE_PIPEWIRE "Enable pipewire backend" AUTO)
auto_option(WIVRN_USE_PULSEAUDIO "Enable pulseaudio backend" AUTO)
set(OVR_COMPAT_SEARCH_PATH "/usr/local/lib/OpenComposite:/usr/lib/OpenComposite:/opt/OpenComposite:/opt/opencomposite:/opt/xrizer"
CACHE STRING "List of places to search for the OpenVR compatibility layer, separated by :")
@@ -65,12 +66,6 @@ endif()
option(ENABLE_COLOURED_OUTPUT "Always produce ANSI-coloured output (GNU/Clang only)." ON)
if (WIVRN_BUILD_CLIENT OR WIVRN_BUILD_SERVER OR WIVRN_BUILD_DASHBOARD OR WIVRN_BUILD_DISSECTOR)
set(NEED_COMMON TRUE)
else()
set(NEED_COMMON FALSE)
endif()
if(ENABLE_COLOURED_OUTPUT)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(-fdiagnostics-color=always)
@@ -82,13 +77,19 @@ endif()
find_package(PkgConfig REQUIRED)
find_package(Vulkan REQUIRED)
find_package(Git)
if (NEED_COMMON AND NOT ANDROID)
if (NOT ANDROID)
find_package(OpenSSL REQUIRED)
endif()
include(VulkanVersion)
if (WIVRN_USE_SYSTEM_BOOST AND NEED_COMMON)
if (WIVRN_BUILD_DISSECTOR)
if (WIVRN_USE_SYSTEM_BOOST STREQUAL "AUTO")
if(WIVRN_BUILD_DISSECTOR)
find_package(Boost 1.84.0 COMPONENTS locale url)
else()
find_package(Boost 1.75.0 COMPONENTS locale url)
endif()
elseif(WIVRN_USE_SYSTEM_BOOST STREQUAL "ON")
if(WIVRN_BUILD_DISSECTOR)
find_package(Boost 1.84.0 REQUIRED COMPONENTS locale url)
else()
find_package(Boost 1.75.0 REQUIRED COMPONENTS locale url)
@@ -105,30 +106,72 @@ if (WIVRN_BUILD_SERVER)
message(FATAL_ERROR "No encoder selected, use at least one of WIVRN_USE_NVENC, WIVRN_USE_VAAPI, WIVRN_USE_VULKAN_ENCODE or WIVRN_USE_X264")
endif()
if (WIVRN_USE_VAAPI)
if (WIVRN_USE_VAAPI STREQUAL "AUTO")
pkg_check_modules(LIBAV IMPORTED_TARGET libavcodec libavutil libswscale libavfilter)
pkg_check_modules(LIBDRM IMPORTED_TARGET libdrm)
if (LIBAV_FOUND AND LIBDRM_FOUND)
set(WIVRN_USE_VAAPI ON)
else()
set(WIVRN_USE_VAAPI OFF)
endif()
elseif (WIVRN_USE_VAAPI)
pkg_check_modules(LIBAV REQUIRED IMPORTED_TARGET libavcodec libavutil libswscale libavfilter)
pkg_check_modules(LIBDRM REQUIRED IMPORTED_TARGET libdrm)
endif()
if (WIVRN_USE_VULKAN_ENCODE)
if (WIVRN_USE_VULKAN_ENCODE STREQUAL "AUTO")
if (Vulkan_VERSION VERSION_GREATER_EQUAL 1.3.283)
set(WIVRN_USE_VULKAN_ENCODE ON)
else()
set(WIVRN_USE_VULKAN_ENCODE OFF)
endif()
elseif(WIVRN_USE_VULKAN_ENCODE)
if (Vulkan_VERSION VERSION_LESS 1.3.283)
message(FATAL_ERROR "Vulkan video encode requires 1.3.283, found ${Vulkan_VERSION}")
endif()
endif()
if (WIVRN_USE_X264)
if (WIVRN_USE_X264 STREQUAL "AUTO")
pkg_check_modules(X264 IMPORTED_TARGET x264)
if (X264_FOUND)
set(WIVRN_USE_X264 ON)
else()
set(WIVRN_USE_X264 OFF)
endif()
elseif (WIVRN_USE_X264)
pkg_check_modules(X264 REQUIRED IMPORTED_TARGET x264)
endif()
if (WIVRN_USE_SYSTEMD)
if (WIVRN_USE_SYSTEMD STREQUAL "AUTO")
pkg_check_modules(SYSTEMD IMPORTED_TARGET libsystemd)
if (SYSTEMD_FOUND)
set(WIVRN_USE_SYSTEMD ON)
else()
set(WIVRN_USE_SYSTEMD OFF)
endif()
elseif (WIVRN_USE_SYSTEMD)
pkg_check_modules(SYSTEMD REQUIRED IMPORTED_TARGET libsystemd)
endif()
if (WIVRN_USE_PIPEWIRE)
if (WIVRN_USE_PIPEWIRE STREQUAL "AUTO")
pkg_check_modules(libpipewire IMPORTED_TARGET libpipewire-0.3)
if (libpipewire_FOUND)
set(WIVRN_USE_PIPEWIRE ON)
else()
set(WIVRN_USE_PIPEWIRE OFF)
endif()
elseif (WIVRN_USE_PIPEWIRE)
pkg_check_modules(libpipewire REQUIRED IMPORTED_TARGET libpipewire-0.3)
endif()
if (WIVRN_USE_PULSEAUDIO)
if (WIVRN_USE_PULSEAUDIO STREQUAL "AUTO")
pkg_check_modules(libpulse IMPORTED_TARGET libpulse)
if (libpulse_FOUND)
set(WIVRN_USE_PULSEAUDIO ON)
else()
set(WIVRN_USE_PULSEAUDIO OFF)
endif()
elseif (WIVRN_USE_PULSEAUDIO)
pkg_check_modules(libpulse REQUIRED IMPORTED_TARGET libpulse)
endif()
@@ -144,8 +187,7 @@ endif()
if (WIVRN_BUILD_DASHBOARD OR WIVRN_BUILD_SERVER)
pkg_check_modules(librsvg-2.0 REQUIRED IMPORTED_TARGET librsvg-2.0)
find_package(LibArchive REQUIRED)
find_package(PNG REQUIRED)
find_package(PNG)
endif()
if (WIVRN_BUILD_DASHBOARD)
@@ -174,11 +216,23 @@ if (WIVRN_BUILD_CLIENT OR WIVRN_BUILD_DASHBOARD)
find_package(Gettext REQUIRED)
endif()
if (WIVRN_BUILD_CLIENT)
if (WIVRN_USE_LIBKTX STREQUAL "AUTO")
if (ANDROID)
set(WIVRN_USE_LIBKTX ON)
else()
set(WIVRN_USE_LIBKTX OFF)
endif()
endif()
endif()
if (WIVRN_BUILD_CLIENT AND NOT ANDROID)
pkg_check_modules(LIBAV REQUIRED IMPORTED_TARGET libavcodec libavutil libswscale libavfilter)
find_package(Fontconfig REQUIRED)
if (WIVRN_USE_SYSTEM_OPENXR)
if (WIVRN_USE_SYSTEM_OPENXR STREQUAL "AUTO")
find_package(OpenXR 1.1.48)
elseif(WIVRN_USE_SYSTEM_OPENXR STREQUAL "ON")
find_package(OpenXR 1.1.48 REQUIRED)
endif()
@@ -192,7 +246,9 @@ if(ANDROID)
endif()
if (WIVRN_BUILD_DISSECTOR)
if (WIVRN_USE_SYSTEM_OPENXR)
if (WIVRN_USE_SYSTEM_OPENXR STREQUAL "AUTO")
find_package(OpenXR 1.1.48)
elseif(WIVRN_USE_SYSTEM_OPENXR STREQUAL "ON")
find_package(OpenXR 1.1.48 REQUIRED)
endif()
find_package(Wireshark REQUIRED)
@@ -249,7 +305,7 @@ FetchContent_Declare(monado
)
add_subdirectory(external)
if (NEED_COMMON)
if (WIVRN_BUILD_CLIENT OR WIVRN_BUILD_SERVER OR WIVRN_BUILD_DASHBOARD OR WIVRN_BUILD_DISSECTOR)
add_subdirectory(common)
endif()
-1
View File
@@ -124,7 +124,6 @@ android {
'-DCMAKE_ANDROID_NDK_VERSION=' + ndkVersion,
'-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON',
'-DCMAKE_EXPORT_COMPILE_COMMANDS=ON',
'-DWIVRN_USE_SYSTEM_BOOST=OFF',
'-DWIVRN_USE_SYSTEM_FREETYPE=OFF',
'-DWIVRN_BUILD_CLIENT=ON',
'-DWIVRN_BUILD_SERVER=OFF',
+126 -98
View File
@@ -29,20 +29,16 @@
#include "utils/i18n.h"
#include "vk/check.h"
#include "wifi_lock.h"
#include "wivrn_packets.h"
#include "xr/actionset.h"
#include "xr/check.h"
#include "xr/htc_exts.h"
#include "xr/htc_face_tracker.h"
#include "xr/meta_body_tracking_fidelity.h"
#include "xr/to_string.h"
#include "xr/xr.h"
#include <algorithm>
#include <boost/locale.hpp>
#include <boost/url/parse.hpp>
#include <chrono>
#include <ctype.h>
#include <exception>
#include <magic_enum.hpp>
#include <string>
#include <thread>
#include <vector>
@@ -350,7 +346,7 @@ static std::vector<interaction_profile> interaction_profiles{
},
interaction_profile{
.profile_name = "/interaction_profiles/bytedance/pico_neo3_controller",
.required_extensions = {XR_BD_CONTROLLER_INTERACTION_EXTENSION_NAME},
.required_extensions = {"XR_BD_controller_interaction"},
.input_sources = {
"/user/hand/left/output/haptic",
"/user/hand/right/output/haptic",
@@ -393,7 +389,7 @@ static std::vector<interaction_profile> interaction_profiles{
},
interaction_profile{
.profile_name = "/interaction_profiles/bytedance/pico4_controller",
.required_extensions = {XR_BD_CONTROLLER_INTERACTION_EXTENSION_NAME},
.required_extensions = {"XR_BD_controller_interaction"},
.input_sources = {
"/user/hand/left/output/haptic",
"/user/hand/right/output/haptic",
@@ -436,7 +432,7 @@ static std::vector<interaction_profile> interaction_profiles{
},
interaction_profile{
.profile_name = "/interaction_profiles/bytedance/pico4s_controller",
.required_extensions = {XR_BD_CONTROLLER_INTERACTION_EXTENSION_NAME},
.required_extensions = {"XR_BD_controller_interaction"},
.input_sources = {
"/user/hand/left/output/haptic",
"/user/hand/right/output/haptic",
@@ -479,7 +475,7 @@ static std::vector<interaction_profile> interaction_profiles{
},
interaction_profile{
.profile_name = "/interaction_profiles/htc/vive_focus3_controller",
.required_extensions = {XR_HTC_VIVE_FOCUS3_CONTROLLER_INTERACTION_EXTENSION_NAME},
.required_extensions = {"XR_HTC_vive_focus3_controller_interaction"},
.input_sources = {
"/user/hand/left/output/haptic",
"/user/hand/right/output/haptic",
@@ -521,7 +517,7 @@ static std::vector<interaction_profile> interaction_profiles{
},
interaction_profile{
.profile_name = "/interaction_profiles/ext/hand_interaction_ext",
.required_extensions = {XR_EXT_HAND_INTERACTION_EXTENSION_NAME},
.required_extensions = {"XR_EXT_hand_interaction"},
.input_sources = {
"/user/hand/left/input/aim/pose",
"/user/hand/left/input/grip/pose",
@@ -550,14 +546,11 @@ static std::vector<interaction_profile> interaction_profiles{
},
interaction_profile{
.profile_name = "/interaction_profiles/htc/vive_xr_tracker",
.required_extensions = {
XR_HTC_VIVE_XR_TRACKER_INTERACTION_EXTENSION_NAME,
XR_HTC_PATH_ENUMERATION_EXTENSION_NAME,
},
.required_extensions = {"XR_HTC_vive_xr_tracker_interaction", "XR_HTC_path_enumeration"},
},
interaction_profile{
.profile_name = "/interaction_profiles/ext/eye_gaze_interaction",
.required_extensions = {XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME},
.required_extensions = {"XR_EXT_eye_gaze_interaction"},
.input_sources = {
"/user/eyes_ext/input/gaze_ext/pose",
},
@@ -726,13 +719,15 @@ void application::initialize_vulkan()
spdlog::info("Using Vulkan validation layer");
layers.push_back("VK_LAYER_KHRONOS_validation");
}
bool debug_report_found = false;
bool debug_utils_found = false;
#endif
std::vector<const char *> instance_extensions{};
std::unordered_set<std::string_view> optional_device_extensions{};
#ifndef NDEBUG
bool debug_report_found = false;
bool debug_utils_found = false;
#endif
spdlog::info("Available Vulkan instance extensions:");
std::vector<std::pair<std::string, int>> extensions;
for (vk::ExtensionProperties & i: vk_context.enumerateInstanceExtensionProperties(nullptr))
@@ -741,27 +736,28 @@ void application::initialize_vulkan()
#ifndef NDEBUG
if (!strcmp(i.extensionName, VK_EXT_DEBUG_REPORT_EXTENSION_NAME))
{
debug_report_found = true;
instance_extensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
}
if (!strcmp(i.extensionName, VK_EXT_DEBUG_UTILS_EXTENSION_NAME) and
guess_model() != model::oculus_quest) // Quest 1 lies, the extension won't load
{
if (!strcmp(i.extensionName, VK_EXT_DEBUG_UTILS_EXTENSION_NAME))
debug_utils_found = true;
instance_extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
}
#endif
}
std::ranges::sort(extensions);
for (const auto & [extension_name, spec_version]: extensions)
spdlog::info(" {} (version {})", extension_name, spec_version);
#ifndef NDEBUG
if (debug_utils_found && debug_report_found)
{
// debug_extensions_found = true;
// spdlog::info("Using debug extensions");
instance_extensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
// instance_extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
}
#endif
vk_device_extensions.push_back(VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
optional_device_extensions.emplace(VK_IMG_FILTER_CUBIC_EXTENSION_NAME);
optional_device_extensions.emplace(VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME);
optional_device_extensions.emplace(VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME);
#ifdef __ANDROID__
vk_device_extensions.push_back(VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME);
@@ -880,7 +876,6 @@ void application::initialize_vulkan()
.ppEnabledExtensionNames = vk_device_extensions.data(),
.pEnabledFeatures = &device_features,
},
vk::PhysicalDeviceFragmentShadingRateFeaturesKHR{},
#ifdef __ANDROID__
vk::PhysicalDeviceSamplerYcbcrConversionFeaturesKHR{
.samplerYcbcrConversion = VK_TRUE,
@@ -888,22 +883,6 @@ void application::initialize_vulkan()
#endif
};
if (utils::contains(vk_device_extensions, VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME) and
utils::contains(vk_device_extensions, VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME))
{
auto [feat, fragment_feat] = vk_physical_device.getFeatures2<vk::PhysicalDeviceFeatures2, vk::PhysicalDeviceFragmentShadingRateFeaturesKHR>();
auto & create_feat = device_create_info.get<vk::PhysicalDeviceFragmentShadingRateFeaturesKHR>();
create_feat.primitiveFragmentShadingRate = fragment_feat.primitiveFragmentShadingRate;
create_feat.attachmentFragmentShadingRate = fragment_feat.attachmentFragmentShadingRate;
spdlog::info("Fragment shading rate features: primitive={} attachment={}",
create_feat.primitiveFragmentShadingRate,
create_feat.attachmentFragmentShadingRate);
}
else
{
device_create_info.unlink<vk::PhysicalDeviceFragmentShadingRateFeaturesKHR>();
}
vk_device = xr_system_id.create_device(vk_physical_device, device_create_info.get());
*vk_queue.lock() = vk_device.getQueue(vk_queue_family_index, 0);
@@ -925,16 +904,10 @@ void application::initialize_vulkan()
pipeline_cache = vk::raii::PipelineCache(vk_device, pipeline_cache_info);
allocator.emplace(VmaAllocatorCreateInfo{
.physicalDevice = *vk_physical_device,
.device = *vk_device,
.instance = *vk_instance,
},
#ifndef NDEBUG
debug_utils_found
#else
false
#endif
);
.physicalDevice = *vk_physical_device,
.device = *vk_device,
.instance = *vk_instance,
});
}
void application::log_views()
@@ -981,6 +954,8 @@ void application::initialize_actions()
{
spdlog::debug("Initializing actions");
auto * htc_body = std::get_if<xr::htc_body_tracker>(&body_tracker);
// Build an action set with all possible input sources
std::vector<XrActionSet> action_sets;
xr_actionset = xr::actionset(xr_instance, "all_actions", "All actions");
@@ -1036,15 +1011,15 @@ void application::initialize_actions()
}
if (add_palms)
{
if ((api_version >= XR_MAKE_VERSION(1, 1, 0) or xr_instance.has_extension(XR_KHR_MAINTENANCE1_EXTENSION_NAME)) //
and utils::contains(profile.input_sources, "/user/hand/left/input/grip/pose") //
if ((api_version >= XR_MAKE_VERSION(1, 1, 0) or utils::contains(xr_extensions, XR_KHR_MAINTENANCE1_EXTENSION_NAME)) //
and utils::contains(profile.input_sources, "/user/hand/left/input/grip/pose") //
and not utils::contains(profile.input_sources, "/user/hand/left/input/grip_surface/pose"))
{
spdlog::info("Adding grip_surface/pose for interaction profile {}", profile.profile_name);
profile.input_sources.push_back("/user/hand/left/input/grip_surface/pose");
profile.input_sources.push_back("/user/hand/right/input/grip_surface/pose");
}
else if (xr_instance.has_extension(XR_EXT_PALM_POSE_EXTENSION_NAME) //
else if (utils::contains(xr_extensions, XR_EXT_PALM_POSE_EXTENSION_NAME) //
and utils::contains(profile.input_sources, "/user/hand/left/input/grip/pose") //
and not utils::contains(profile.input_sources, "/user/hand/left/input/palm_ext/pose"))
{
@@ -1055,15 +1030,14 @@ void application::initialize_actions()
}
// Dynamically add VIVE XR Trackers to the profile if available
if (utils::contains(profile.required_extensions, XR_HTC_VIVE_XR_TRACKER_INTERACTION_EXTENSION_NAME) and
xr_instance.has_extension(XR_HTC_PATH_ENUMERATION_EXTENSION_NAME))
if (htc_body && utils::contains(profile.required_extensions, XR_HTC_VIVE_XR_TRACKER_INTERACTION_EXTENSION_NAME))
{
XrPath tracker_profile = xr_instance.string_to_path("/interaction_profiles/htc/vive_xr_tracker");
for (const auto & user_path: xr_instance.enumerate_paths_for_interaction_profile(tracker_profile))
for (const auto & user_path: htc_body->get_paths())
{
generic_trackers.emplace_back(user_path, nullptr);
for (const auto & input_path: xr_instance.enumerate_paths_for_interaction_profile(tracker_profile, user_path))
profile.input_sources.push_back(xr_instance.path_to_string(user_path) + xr_instance.path_to_string(input_path));
for (const auto & input_path: htc_body->get_paths(user_path))
{
profile.input_sources.push_back(path_to_string(user_path) + path_to_string(input_path));
}
}
}
@@ -1111,14 +1085,8 @@ void application::initialize_actions()
spaces[size_t(xr::spaces::poke_right)] = xr_session.create_action_space(a);
else if (name == "/user/eyes_ext/input/gaze_ext/pose")
spaces[size_t(xr::spaces::eye_gaze)] = xr_session.create_action_space(a);
else if (name.contains("/input/entity_htc/pose"))
{
for (auto & [path, action]: generic_trackers)
{
if (name.starts_with(xr_instance.path_to_string(path)))
action = xr_session.create_action_space(a);
}
}
else if (name.contains("/input/entity_htc/pose") && htc_body)
htc_body->add(xr_session.create_action_space(a));
}
// Build an action set for each scene
@@ -1155,7 +1123,7 @@ void application::initialize_actions()
xr_bindings.push_back(XrActionSuggestedBinding{
.action = a,
.binding = xr_instance.string_to_path(k.input_source)});
.binding = string_to_path(k.input_source)});
}
}
}
@@ -1172,7 +1140,7 @@ void application::initialize_actions()
for (const auto & name: profile.input_sources)
{
xr_bindings.push_back({actions_by_name[name], xr_instance.string_to_path(name)});
xr_bindings.push_back({actions_by_name[name], string_to_path(name)});
}
try
@@ -1192,7 +1160,7 @@ void application::initialize()
{
// LogLayersAndExtensions
assert(!xr_instance);
std::vector<std::string> xr_extensions;
xr_extensions.clear();
// Required extensions
xr_extensions.push_back(XR_KHR_CONVERT_TIMESPEC_TIME_EXTENSION_NAME);
@@ -1265,16 +1233,21 @@ void application::initialize()
spdlog::info(" Orientation tracking: {}", (bool)properties.trackingProperties.orientationTracking);
spdlog::info(" Position tracking: {}", (bool)properties.trackingProperties.positionTracking);
spdlog::info(" Hand tracking support: {}", xr_system_id.hand_tracking_supported());
if (utils::contains(xr_extensions, XR_EXT_HAND_TRACKING_EXTENSION_NAME))
{
XrSystemHandTrackingPropertiesEXT hand_tracking_properties = xr_system_id.hand_tracking_properties();
spdlog::info(" Hand tracking support: {}", (bool)hand_tracking_properties.supportsHandTracking);
hand_tracking_supported = hand_tracking_properties.supportsHandTracking;
}
if (xr_instance.has_extension(XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME))
if (utils::contains(xr_extensions, XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME))
{
XrSystemEyeGazeInteractionPropertiesEXT eye_gaze_properties = xr_system_id.eye_gaze_interaction_properties();
spdlog::info(" Eye gaze support: {}", (bool)eye_gaze_properties.supportsEyeGazeInteraction);
eye_gaze_supported = eye_gaze_properties.supportsEyeGazeInteraction;
}
if (xr_instance.has_extension(XR_FB_COMPOSITION_LAYER_SETTINGS_EXTENSION_NAME))
if (utils::contains(xr_extensions, XR_FB_COMPOSITION_LAYER_SETTINGS_EXTENSION_NAME))
{
spdlog::info(" OpenXR post-processing extension support: true");
openxr_post_processing_supported = true;
@@ -1282,39 +1255,23 @@ void application::initialize()
switch (xr_system_id.passthrough_supported())
{
case xr::passthrough_type::none:
case xr::system::passthrough_type::no_passthrough:
spdlog::info(" Passthrough: not supported");
break;
case xr::passthrough_type::bw:
case xr::system::passthrough_type::bw:
spdlog::info(" Passthrough: black and white");
break;
case xr::passthrough_type::color:
case xr::system::passthrough_type::color:
spdlog::info(" Passthrough: color");
break;
}
spdlog::info(" Face tracker: {}", magic_enum::enum_name(xr_system_id.face_tracker_supported()));
spdlog::info(" Body tracker: {}", magic_enum::enum_name(xr_system_id.body_tracker_supported()));
// Log view configurations and blend modes
log_views();
initialize_vulkan();
xr_session = xr::session(xr_instance, xr_system_id, vk_instance, vk_physical_device, vk_device, vk_queue, vk_queue_family_index);
spaces[size_t(xr::spaces::view)] = xr_session.create_reference_space(XR_REFERENCE_SPACE_TYPE_VIEW);
spaces[size_t(xr::spaces::world)] = xr_session.create_reference_space(XR_REFERENCE_SPACE_TYPE_STAGE);
config.emplace(xr_system_id);
// HTC face tracker fails if created later
// we can destroy it right away, it actually stores static handles
if (xr_system_id.face_tracker_supported() == xr::face_tracker_type::htc)
{
auto props = xr_system_id.htc_face_tracking_properties();
xr::htc_face_tracker(xr_instance, xr_session, props.supportEyeFacialTracking, props.supportLipFacialTracking);
}
xr_session = xr::session(xr_instance, xr_system_id, vk_instance, vk_physical_device, vk_device, vk_queue_family_index);
{
auto spaces = xr_session.get_reference_spaces();
@@ -1323,6 +1280,70 @@ void application::initialize()
spdlog::info(" {}", xr::to_string(i));
}
spaces[size_t(xr::spaces::view)] = xr_session.create_reference_space(XR_REFERENCE_SPACE_TYPE_VIEW);
spaces[size_t(xr::spaces::world)] = xr_session.create_reference_space(XR_REFERENCE_SPACE_TYPE_STAGE);
config.emplace(xr_system_id);
if (hand_tracking_supported)
{
left_hand = xr_session.create_hand_tracker(XR_HAND_LEFT_EXT);
right_hand = xr_session.create_hand_tracker(XR_HAND_RIGHT_EXT);
}
if (utils::contains(xr_extensions, XR_FB_FACE_TRACKING2_EXTENSION_NAME))
{
XrSystemFaceTrackingProperties2FB fb_face2_properties = xr_system_id.fb_face_tracking2_properties();
spdlog::info(" FB face tracking support: {}", (bool)fb_face2_properties.supportsVisualFaceTracking);
if (fb_face2_properties.supportsVisualFaceTracking)
face_tracker.emplace<xr::fb_face_tracker2>(xr_instance, xr_session);
}
if (std::holds_alternative<std::monostate>(face_tracker) && utils::contains(xr_extensions, XR_HTC_FACIAL_TRACKING_EXTENSION_NAME))
{
XrSystemFacialTrackingPropertiesHTC htc_face_properties = xr_system_id.htc_face_tracking_properties();
spdlog::info(" HTC eye tracking support: {}", (bool)htc_face_properties.supportEyeFacialTracking);
spdlog::info(" HTC lip tracking support: {}", (bool)htc_face_properties.supportLipFacialTracking);
if (htc_face_properties.supportEyeFacialTracking || htc_face_properties.supportLipFacialTracking)
face_tracker.emplace<xr::htc_face_tracker>(xr_instance, xr_session, htc_face_properties.supportEyeFacialTracking, htc_face_properties.supportLipFacialTracking);
}
if (std::holds_alternative<std::monostate>(face_tracker) && eye_gaze_supported)
{
switch (guess_model())
{
case model::pico_4_pro:
case model::pico_4_enterprise:
spdlog::info(" PICO face tracking support: true");
face_tracker.emplace<xr::pico_face_tracker>(xr_instance, xr_session);
break;
default:
break;
}
}
if (utils::contains_all(xr_extensions, std::array{XR_FB_BODY_TRACKING_EXTENSION_NAME, XR_META_BODY_TRACKING_FULL_BODY_EXTENSION_NAME, XR_META_BODY_TRACKING_FIDELITY_EXTENSION_NAME}))
{
XrSystemBodyTrackingPropertiesFB fb_body_properties = xr_system_id.fb_body_tracking_properties();
spdlog::info(" FB body tracking support: {}", (bool)fb_body_properties.supportsBodyTracking);
if (fb_body_properties.supportsBodyTracking)
body_tracker.emplace<xr::fb_body_tracker>(xr_instance, xr_session);
}
if (std::holds_alternative<std::monostate>(body_tracker) && utils::contains_all(xr_extensions, std::array{XR_HTC_PATH_ENUMERATION_EXTENSION_NAME, XR_HTC_VIVE_XR_TRACKER_INTERACTION_EXTENSION_NAME}))
{
spdlog::info(" HTC body tracking support: true");
body_tracker.emplace<xr::htc_body_tracker>(xr_instance, xr_session);
}
if (std::holds_alternative<std::monostate>(body_tracker) && utils::contains(xr_extensions, XR_BD_BODY_TRACKING_EXTENSION_NAME))
{
XrSystemBodyTrackingPropertiesBD bd_body_properties = xr_system_id.bd_body_tracking_properties();
spdlog::info(" PICO body tracking support: {}", (bool)bd_body_properties.supportsBodyTracking);
if (bd_body_properties.supportsBodyTracking)
body_tracker.emplace<xr::pico_body_tracker>(xr_instance, xr_session);
}
vk::CommandPoolCreateInfo cmdpool_create_info;
cmdpool_create_info.queueFamilyIndex = vk_queue_family_index;
cmdpool_create_info.flags = vk::CommandPoolCreateFlagBits::eResetCommandBuffer;
@@ -1854,6 +1875,13 @@ void application::poll_events()
exit_requested = true;
}
break;
case XR_TYPE_EVENT_DATA_INTERACTION_PROFILE_CHANGED: {
if (auto * htc_body = std::get_if<xr::htc_body_tracker>(&body_tracker))
{
htc_body->update_active();
}
}
break;
case XR_TYPE_EVENT_DATA_REFERENCE_SPACE_CHANGE_PENDING:
break;
case XR_TYPE_EVENT_DATA_SESSION_STATE_CHANGED: {
+47 -12
View File
@@ -82,8 +82,6 @@ bool configuration::check_feature(feature f) const
{
std::lock_guard lock(mutex);
auto & system = application::get_system();
auto it = features.find(f);
if (it == features.end())
return false;
@@ -96,7 +94,7 @@ bool configuration::check_feature(feature f) const
case feature::microphone:
break;
case feature::hand_tracking:
if (not system.hand_tracking_supported())
if (not application::get_hand_tracking_supported())
return false;
break;
case feature::eye_gaze:
@@ -104,12 +102,50 @@ bool configuration::check_feature(feature f) const
return false;
break;
case feature::face_tracking:
if (system.face_tracker_supported() == xr::face_tracker_type::none)
return false;
switch (guess_model())
{
case model::htc_vive_focus_3:
case model::htc_vive_focus_vision:
case model::htc_vive_xr_elite:
if (not std::holds_alternative<xr::htc_face_tracker>(application::get_face_tracker()))
return false;
break;
case model::pico_4_pro:
case model::pico_4_enterprise:
if (not std::holds_alternative<xr::pico_face_tracker>(application::get_face_tracker()))
return false;
break;
default:
if (not std::holds_alternative<xr::fb_face_tracker2>(application::get_face_tracker()))
return false;
break;
}
break;
case feature::body_tracking:
if (system.body_tracker_supported() == xr::body_tracker_type::none)
return false;
switch (guess_model())
{
case model::meta_quest_3:
case model::meta_quest_3s:
if (not std::holds_alternative<xr::fb_body_tracker>(application::get_body_tracker()))
return false;
break;
case model::htc_vive_focus_3:
case model::htc_vive_xr_elite:
case model::htc_vive_focus_vision:
if (not std::holds_alternative<xr::htc_body_tracker>(application::get_body_tracker()))
return false;
break;
case model::pico_neo_3:
case model::pico_4:
case model::pico_4s:
case model::pico_4_pro:
case model::pico_4_enterprise:
if (not std::holds_alternative<xr::pico_body_tracker>(application::get_body_tracker()))
return false;
break;
default:
break;
}
break;
}
}
@@ -145,8 +181,8 @@ void configuration::set_feature(feature f, bool state)
configuration::configuration(xr::system & system)
{
passthrough_enabled = system.passthrough_supported() == xr::passthrough_type::color;
features[feature::hand_tracking] = system.hand_tracking_supported();
passthrough_enabled = system.passthrough_supported() == xr::system::passthrough_type::color;
features[feature::hand_tracking] = application::get_hand_tracking_supported();
try
{
simdjson::dom::parser parser;
@@ -204,7 +240,7 @@ configuration::configuration(xr::system & system)
features[i] = val.get_bool();
}
if (system.passthrough_supported() == xr::passthrough_type::none)
if (system.passthrough_supported() == xr::system::passthrough_type::no_passthrough)
passthrough_enabled = false;
if (auto val = root["override_foveation_enable"]; val.is_bool())
@@ -232,7 +268,7 @@ configuration::configuration(xr::system & system)
minimum_refresh_rate.reset();
resolution_scale = 1.4;
openxr_post_processing = {};
passthrough_enabled = system.passthrough_supported() == xr::passthrough_type::color;
passthrough_enabled = system.passthrough_supported() == xr::system::passthrough_type::color;
}
}
@@ -299,7 +335,6 @@ void configuration::save()
json << ",\"mic_unprocessed_audio\":" << std::boolalpha << mic_unprocessed_audio;
json << ",\"fb_lower_body\":" << std::boolalpha << fb_lower_body;
json << ",\"fb_hip\":" << std::boolalpha << fb_hip;
json << ",\"enable_stream_gui\":" << std::boolalpha << enable_stream_gui;
for (auto & [key, value]: features)
json << "," << key << ":" << std::boolalpha << value;
json << ",\"virtual_keyboard_layout\":" << json_string(virtual_keyboard_layout);
-92
View File
@@ -1,92 +0,0 @@
/*
* WiVRn VR streaming
* Copyright (C) 2022 Guillaume Meunier <guillaume.meunier@centraliens.net>
* Copyright (C) 2022 Patrick Nicolas <patricknicolas@laposte.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifdef VERT_SHADER
#if VSR
#extension GL_EXT_fragment_shading_rate: enable
#endif
layout (location = 0) in vec2 vPosition;
layout (location = 1) in uvec2 vUV;
layout(location = 0) out vec4 outUV;
layout(push_constant) uniform pc
{
ivec4 rgb_rect;
ivec4 a_rect;
};
void main()
{
gl_Position = vec4(vPosition, 0.0, 1.0);
#if VSR
gl_PrimitiveShadingRateEXT = int(bitfieldExtract(vUV.x, 28, 4));
vec2 uv = bitfieldInsert(vUV, uvec2(0), 28, 4);
#else
vec2 uv = vUV;
#endif
outUV.xy = (uv + rgb_rect.xy) / rgb_rect.zw;
outUV.zw = (uv + a_rect.xy) / a_rect.zw;
}
#endif
#ifdef FRAG_SHADER
layout(constant_id = 0) const int alpha = 1;
layout(constant_id = 1) const bool do_srgb = false;
layout(set = 0, binding = 0) uniform sampler2D rgb[alpha + 1];
layout(location = 0) in vec4 inUV;
layout(location = 0) out vec4 outColor;
float sRGB_to_linear(float x)
{
if (x <= 0.04045)
return x / 12.92;
return pow((x + 0.055) / 1.055, 2.4);
}
vec4 sRGB_to_linear_rgba(vec4 x)
{
return vec4(
sRGB_to_linear(x.r),
sRGB_to_linear(x.g),
sRGB_to_linear(x.b),
x.a);
}
void main()
{
if (alpha == 1)
outColor = vec4(texture(rgb[0], inUV.xy).rgb, texture(rgb[1], inUV.zw).r);
else
outColor = texture(rgb[0], inUV.xy).rgba;
if (do_srgb)
{
outColor = sRGB_to_linear_rgba(outColor);
}
}
#endif
-1
View File
@@ -18,7 +18,6 @@
pkgs.sdl2-compat
pkgs.librsvg
pkgs.libpng
pkgs.libarchive
];
extraNativeBuildInputs = [
pkgs.util-linux
@@ -0,0 +1,25 @@
From 90c3842f38985e0f8f06bb51d0e58cccf437526f Mon Sep 17 00:00:00 2001
From: galister <3123227-galister@users.noreply.gitlab.com>
Date: Mon, 19 Aug 2024 18:51:45 +0900
Subject: [PATCH 04/10] c/render: Add storage usage to distortion mesh
---
src/xrt/compositor/render/render_distortion.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/xrt/compositor/render/render_distortion.c b/src/xrt/compositor/render/render_distortion.c
index 8ac24db8e..5a7e400c3 100644
--- a/src/xrt/compositor/render/render_distortion.c
+++ b/src/xrt/compositor/render/render_distortion.c
@@ -42,7 +42,7 @@ create_distortion_image_and_view(struct vk_bundle *vk,
vk, // vk_bundle
extent, // extent
format, // format
- VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, // usage
+ VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT, // usage
&device_memory, // out_device_memory
&image); // out_image
VK_CHK_AND_RET(ret, "vk_create_image_simple");
--
2.50.1
@@ -0,0 +1,94 @@
From 5a791919ce1e01f2cb0034e4055bf22767a41121 Mon Sep 17 00:00:00 2001
From: Patrick Nicolas <patricknicolas@laposte.net>
Date: Sun, 3 Nov 2024 13:40:00 +0100
Subject: [PATCH 07/10] store alpha channel in layer 1
---
src/xrt/compositor/shaders/clear.comp | 4 ++--
src/xrt/compositor/shaders/distortion.comp | 18 ++++++++++++------
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/xrt/compositor/shaders/clear.comp b/src/xrt/compositor/shaders/clear.comp
index 036da401a..db8e5178e 100644
--- a/src/xrt/compositor/shaders/clear.comp
+++ b/src/xrt/compositor/shaders/clear.comp
@@ -10,7 +10,7 @@
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
-layout(set = 0, binding = 2) uniform writeonly restrict image2D target;
+layout(set = 0, binding = 2) uniform writeonly restrict image2DArray target;
layout(set = 0, binding = 3) uniform restrict Config
{
ivec4 views[2];
@@ -35,5 +35,5 @@ void main()
vec4 colour = vec4(from_linear_to_srgb(vec3(0.1)), 1.0);
- imageStore(target, ivec2(offset.x + ix, offset.y + iy), colour);
+ imageStore(target, ivec3(offset.x + ix, offset.y + iy, 0), colour);
}
diff --git a/src/xrt/compositor/shaders/distortion.comp b/src/xrt/compositor/shaders/distortion.comp
index e1dd1cb58..9ce46fe6f 100644
--- a/src/xrt/compositor/shaders/distortion.comp
+++ b/src/xrt/compositor/shaders/distortion.comp
@@ -18,7 +18,7 @@ layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
layout(set = 0, binding = 0) uniform sampler2D source[2];
layout(set = 0, binding = 1) uniform sampler2D distortion[6];
-layout(set = 0, binding = 2) uniform writeonly restrict image2D luma;
+layout(set = 0, binding = 2) uniform writeonly restrict image2DArray luma;
layout(set = 0, binding = 3, std140) uniform restrict Config
{
ivec4 views[2];
@@ -26,7 +26,7 @@ layout(set = 0, binding = 3, std140) uniform restrict Config
vec4 post_transform[2];
mat4 transform[2];
} ubo;
-layout(set = 0, binding = 4) uniform writeonly restrict image2D chroma;
+layout(set = 0, binding = 4) uniform writeonly restrict image2DArray chroma;
const mat3 color_space = mat3(
// clang-format off
@@ -122,6 +122,7 @@ void main()
ivec2 offset = ivec2(ubo.views[iz].xy);
ivec2 extent = ivec2(ubo.views[iz].zw);
vec2 cbcrs[4];
+ vec4 alpha;
for (int k = 0; k < 2; k += 1) {
uint iy = gl_GlobalInvocationID.y * 2 + k;
for (int j = 0; j < 2; j += 1) {
@@ -136,15 +137,16 @@ void main()
uv = transform_uv(uv, iz);
// Sample the source
- vec3 colour = textureLod(source[iz], uv, mix(lod.x, lod.y, 0.5)).rgb;
+ vec4 colour = textureLod(source[iz], uv, mix(lod.x, lod.y, 0.5));
- colour = rgb_to_ycbcr(from_linear_to_srgb(colour));
+ colour.rgb = rgb_to_ycbcr(from_linear_to_srgb(colour.rgb));
int i = k * 2 + j;
cbcrs[i] = colour.yz;
+ alpha[i] = colour.a;
if (ix < extent.x && iy < extent.y) {
- imageStore(luma, ivec2(offset.x + ix, offset.y + iy), vec4(colour.x));
+ imageStore(luma, ivec3(offset.x + ix, offset.y + iy, 0), vec4(colour.x));
}
}
}
@@ -152,5 +154,9 @@ void main()
return;
}
vec2 cbcr = mix(mix(cbcrs[0], cbcrs[1], 0.5), mix(cbcrs[2], cbcrs[3], 0.5), 0.5);
- imageStore(chroma, ivec2(offset.xy/2 + gl_GlobalInvocationID.xy), vec4(cbcr.x, cbcr.y, 0, 0));
+ imageStore(chroma, ivec3(offset.xy/2 + gl_GlobalInvocationID.xy, 0), vec4(cbcr.x, cbcr.y, 0, 0));
+
+ imageStore(chroma, ivec3(offset.xy/2 + gl_GlobalInvocationID.xy, 1), vec4(0.5, 0.5, 0, 0));
+ alpha = vec4(mix(mix(alpha[0], alpha[1], 0.5), mix(alpha[2], alpha[3], 0.5), 0.5));
+ imageStore(luma, ivec3(offset.xy/2 + gl_GlobalInvocationID.xy, 1), alpha);
}
--
2.50.1