pass through HTC_facial_tracking

This commit is contained in:
galister
2025-02-08 10:24:15 +01:00
committed by xytovl
parent 22186f0043
commit 261bb2c600
20 changed files with 567 additions and 13 deletions
+71
View File
@@ -0,0 +1,71 @@
/*
* WiVRn VR streaming
* Copyright (C) 2024 galister <galister@librevr.org>
*
* 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/>.
*/
#include "htc_face_tracker.h"
#include "wivrn_packets.h"
#include "xr/instance.h"
#include <openxr/openxr.h>
static PFN_xrDestroyFacialTrackerHTC xrDestroyFacialTrackerHTC{};
XrResult xr::destroy_htc_face_tracker(XrFacialTrackerHTC id)
{
return xrDestroyFacialTrackerHTC(id);
}
xr::htc_face_tracker::htc_face_tracker(instance & inst, XrFacialTrackerHTC h, XrFacialTrackingTypeHTC facialTrackingTypeHTC)
{
id = h;
xrGetFacialExpressionsHTC = inst.get_proc<PFN_xrGetFacialExpressionsHTC>("xrGetFacialExpressionsHTC");
xrDestroyFacialTrackerHTC = inst.get_proc<PFN_xrDestroyFacialTrackerHTC>("xrDestroyFacialTrackerHTC");
trackerType = facialTrackingTypeHTC;
}
void xr::htc_face_tracker::get_weights(XrTime time, wivrn::from_headset::tracking::htc_face & out_expressions)
{
if (!id || !xrGetFacialExpressionsHTC)
return;
XrFacialExpressionsHTC expressions{
.type = XR_TYPE_FACIAL_EXPRESSIONS_HTC,
.next = nullptr,
.sampleTime = time,
};
bool * is_active;
switch (trackerType)
{
case XR_FACIAL_TRACKING_TYPE_EYE_DEFAULT_HTC:
expressions.expressionCount = out_expressions.eye.size();
expressions.expressionWeightings = out_expressions.eye.data();
is_active = &out_expressions.eye_active;
break;
case XR_FACIAL_TRACKING_TYPE_LIP_DEFAULT_HTC:
expressions.expressionCount = out_expressions.lip.size();
expressions.expressionWeightings = out_expressions.lip.data();
is_active = &out_expressions.lip_active;
break;
default:
throw std::system_error(1, std::generic_category(), "htc_face_tracker with unknown trackerType");
}
CHECK_XR(xrGetFacialExpressionsHTC(id, &expressions));
*is_active = expressions.isActive;
}
+43
View File
@@ -0,0 +1,43 @@
/*
* WiVRn VR streaming
* Copyright (C) 2024 galister <galister@librevr.org>
*
* 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/>.
*/
#pragma once
#include "utils/handle.h"
#include "wivrn_packets.h"
#include <openxr/openxr.h>
namespace xr
{
class instance;
XrResult destroy_htc_face_tracker(XrFacialTrackerHTC);
class htc_face_tracker : public utils::handle<XrFacialTrackerHTC, destroy_htc_face_tracker>
{
PFN_xrGetFacialExpressionsHTC xrGetFacialExpressionsHTC{};
PFN_xrDestroyFacialTrackerHTC xrDestroyFacialTrackerHTC{};
XrFacialTrackingTypeHTC trackerType{};
public:
htc_face_tracker() = default;
htc_face_tracker(instance & inst, XrFacialTrackerHTC h, XrFacialTrackingTypeHTC facialTrackingTypeHTC);
void get_weights(XrTime time, struct wivrn::from_headset::tracking::htc_face & out_expressions);
};
} // namespace xr
+17
View File
@@ -21,6 +21,7 @@
#include "application.h"
#include "details/enumerate.h"
#include "openxr/openxr.h"
#include "utils/contains.h"
#include "xr/instance.h"
#include "xr/system.h"
@@ -119,6 +120,22 @@ xr::fb_face_tracker2 xr::session::create_fb_face_tracker2()
return {*inst, ft};
}
xr::htc_face_tracker xr::session::create_htc_face_tracker(XrFacialTrackingTypeHTC facialTrackingType)
{
XrFacialTrackerCreateInfoHTC create_info{
.type = XR_TYPE_FACIAL_TRACKER_CREATE_INFO_HTC,
.next = nullptr,
.facialTrackingType = facialTrackingType,
};
XrFacialTrackerHTC ft;
auto xrCreateFacialTrackerHTC = inst->get_proc<PFN_xrCreateFacialTrackerHTC>("xrCreateFacialTrackerHTC");
assert(xrCreateFacialTrackerHTC);
CHECK_XR(xrCreateFacialTrackerHTC(id, &create_info, &ft));
return {*inst, ft, facialTrackingType};
}
std::vector<vk::Format> xr::session::get_swapchain_formats() const
{
std::vector<vk::Format> formats;
+2
View File
@@ -28,6 +28,7 @@
#include "fb_face_tracker2.h"
#include "hand_tracker.h"
#include "htc_face_tracker.h"
#include "passthrough.h"
#include "space.h"
@@ -50,6 +51,7 @@ public:
space create_action_space(XrAction action, const XrPosef & pose = {{0, 0, 0, 1}, {0, 0, 0}});
hand_tracker create_hand_tracker(XrHandEXT hand, XrHandJointSetEXT hand_joint_set = XR_HAND_JOINT_SET_DEFAULT_EXT);
fb_face_tracker2 create_fb_face_tracker2();
htc_face_tracker create_htc_face_tracker(XrFacialTrackingTypeHTC);
std::vector<vk::Format> get_swapchain_formats() const;
+18
View File
@@ -123,6 +123,24 @@ XrSystemFaceTrackingProperties2FB xr::system::fb_face_tracking2_properties() con
return face_tracking_prop;
}
XrSystemFacialTrackingPropertiesHTC xr::system::htc_face_tracking_properties() const
{
if (!id)
throw std::invalid_argument("this");
XrSystemFacialTrackingPropertiesHTC face_tracking_prop{
.type = XR_TYPE_SYSTEM_FACIAL_TRACKING_PROPERTIES_HTC,
};
XrSystemProperties prop{
.type = XR_TYPE_SYSTEM_PROPERTIES,
.next = &face_tracking_prop,
};
CHECK_XR(xrGetSystemProperties(*inst, id, &prop));
return face_tracking_prop;
}
xr::system::passthrough_type xr::system::passthrough_supported() const
{
if (utils::contains(environment_blend_modes(XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO), XR_ENVIRONMENT_BLEND_MODE_ALPHA_BLEND))
+1
View File
@@ -63,6 +63,7 @@ public:
XrSystemHandTrackingPropertiesEXT hand_tracking_properties() const;
XrSystemEyeGazeInteractionPropertiesEXT eye_gaze_interaction_properties() const;
XrSystemFaceTrackingProperties2FB fb_face_tracking2_properties() const;
XrSystemFacialTrackingPropertiesHTC htc_face_tracking_properties() const;
passthrough_type passthrough_supported() const;
XrGraphicsRequirementsVulkan2KHR graphics_requirements() const;