passthru FB_face_tracking2
This commit is contained in:
@@ -741,6 +741,7 @@ void application::initialize()
|
||||
opt_extensions.push_back(XR_EXT_EYE_GAZE_INTERACTION_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_FB_PASSTHROUGH_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_HTC_PASSTHROUGH_EXTENSION_NAME);
|
||||
opt_extensions.push_back(XR_FB_FACE_TRACKING2_EXTENSION_NAME);
|
||||
|
||||
for (const auto & i: interaction_profiles)
|
||||
{
|
||||
@@ -800,6 +801,13 @@ void application::initialize()
|
||||
eye_gaze_supported = eye_gaze_properties.supportsEyeGazeInteraction;
|
||||
}
|
||||
|
||||
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);
|
||||
fb_face_tracking2_supported = fb_face2_properties.supportsVisualFaceTracking;
|
||||
}
|
||||
|
||||
switch (xr_system_id.passthrough_supported())
|
||||
{
|
||||
case xr::system::passthrough_type::no_passthrough:
|
||||
@@ -848,6 +856,11 @@ void application::initialize()
|
||||
right_hand = xr_session.create_hand_tracker(XR_HAND_RIGHT_EXT);
|
||||
}
|
||||
|
||||
if (fb_face_tracking2_supported)
|
||||
{
|
||||
fb_face_tracker2 = xr_session.create_fb_face_tracker2();
|
||||
}
|
||||
|
||||
vk::CommandPoolCreateInfo cmdpool_create_info;
|
||||
cmdpool_create_info.queueFamilyIndex = vk_queue_family_index;
|
||||
cmdpool_create_info.flags = vk::CommandPoolCreateFlagBits::eResetCommandBuffer;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "configuration.h"
|
||||
#include "xr/fb_face_tracker2.h"
|
||||
#include "xr/hand_tracker.h"
|
||||
#ifdef __ANDROID__
|
||||
#include <android_native_app_glue.h>
|
||||
@@ -127,6 +128,9 @@ class application : public singleton<application>
|
||||
xr::hand_tracker left_hand;
|
||||
xr::hand_tracker right_hand;
|
||||
|
||||
bool fb_face_tracking2_supported = false;
|
||||
xr::fb_face_tracker2 fb_face_tracker2;
|
||||
|
||||
bool eye_gaze_supported = false;
|
||||
|
||||
bool session_running = false;
|
||||
@@ -412,6 +416,11 @@ public:
|
||||
return instance().hand_tracking_supported;
|
||||
}
|
||||
|
||||
static bool get_fb_face_tracking2_supported()
|
||||
{
|
||||
return instance().fb_face_tracking2_supported;
|
||||
}
|
||||
|
||||
static bool get_eye_gaze_supported()
|
||||
{
|
||||
return instance().eye_gaze_supported;
|
||||
@@ -427,6 +436,11 @@ public:
|
||||
return instance().right_hand;
|
||||
}
|
||||
|
||||
static xr::fb_face_tracker2 & get_fb_face_tracker2()
|
||||
{
|
||||
return instance().fb_face_tracker2;
|
||||
}
|
||||
|
||||
static const std::vector<std::string> & get_xr_extensions()
|
||||
{
|
||||
return instance().xr_extensions;
|
||||
|
||||
@@ -121,6 +121,7 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
|
||||
|
||||
info.hand_tracking = application::get_hand_tracking_supported();
|
||||
info.eye_gaze = application::get_eye_gaze_supported();
|
||||
info.face_tracking2_fb = application::get_fb_face_tracking2_supported();
|
||||
|
||||
audio::get_audio_description(info);
|
||||
if (not application::get_config().microphone)
|
||||
|
||||
@@ -197,12 +197,15 @@ void scenes::stream::tracking()
|
||||
for (XrDuration Δt = 0; Δt <= prediction; Δt += std::max<XrDuration>(1, prediction))
|
||||
{
|
||||
from_headset::hand_tracking hands{};
|
||||
from_headset::fb_face2 fb_face2{};
|
||||
|
||||
packet.production_timestamp = t0;
|
||||
hands.production_timestamp = t0;
|
||||
fb_face2.production_timestamp = t0;
|
||||
|
||||
packet.timestamp = t0 + Δt;
|
||||
hands.timestamp = t0 + Δt;
|
||||
fb_face2.timestamp = t0 + Δt;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -243,6 +246,14 @@ void scenes::stream::tracking()
|
||||
t.resume();
|
||||
}
|
||||
|
||||
if (application::get_fb_face_tracking2_supported())
|
||||
{
|
||||
application::get_fb_face_tracker2().get_weights(t0 + Δt, &fb_face2);
|
||||
t.pause();
|
||||
network_session->send_stream(fb_face2);
|
||||
t.resume();
|
||||
}
|
||||
|
||||
XrDuration busy_time = t.count();
|
||||
// Target: polling between 1 and 5ms, with 20% busy time
|
||||
tracking_period = std::clamp<XrDuration>(std::lerp(tracking_period, busy_time * 5, 0.2), 1'000'000, 5'000'000);
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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 "fb_face_tracker2.h"
|
||||
#include "wivrn_packets.h"
|
||||
#include <cstdint>
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
static PFN_xrDestroyFaceTracker2FB xrDestroyFaceTracker2FB{};
|
||||
|
||||
XrResult xr::destroy_fb_face_tracker2(XrFaceTracker2FB id)
|
||||
{
|
||||
return xrDestroyFaceTracker2FB(id);
|
||||
}
|
||||
|
||||
xr::fb_face_tracker2::fb_face_tracker2(instance & inst, XrFaceTracker2FB h)
|
||||
{
|
||||
id = h;
|
||||
xrGetFaceExpressionWeights2FB = inst.get_proc<PFN_xrGetFaceExpressionWeights2FB>("xrGetFaceExpressionWeights2FB");
|
||||
xrDestroyFaceTracker2FB = inst.get_proc<PFN_xrDestroyFaceTracker2FB>("xrDestroyFaceTracker2FB");
|
||||
}
|
||||
|
||||
void xr::fb_face_tracker2::get_weights(XrTime time, xrt::drivers::wivrn::from_headset::fb_face2 * out_expressions)
|
||||
{
|
||||
if (!id || !xrGetFaceExpressionWeights2FB)
|
||||
return;
|
||||
|
||||
XrFaceExpressionInfo2FB info{
|
||||
.type = XR_TYPE_FACE_EXPRESSION_INFO2_FB,
|
||||
.next = nullptr,
|
||||
.time = time,
|
||||
};
|
||||
|
||||
XrFaceExpressionWeights2FB expression_weights{
|
||||
.type = XR_TYPE_FACE_EXPRESSION_WEIGHTS2_FB,
|
||||
.next = nullptr,
|
||||
.weightCount = (uint32_t)out_expressions->weights.size(),
|
||||
.weights = out_expressions->weights.data(),
|
||||
.confidenceCount = (uint32_t)out_expressions->confidences.size(),
|
||||
.confidences = out_expressions->confidences.data(),
|
||||
};
|
||||
|
||||
CHECK_XR(xrGetFaceExpressionWeights2FB(id, &info, &expression_weights));
|
||||
|
||||
out_expressions->is_valid = expression_weights.isValid;
|
||||
out_expressions->is_eye_following_blendshapes_valid = expression_weights.isEyeFollowingBlendshapesValid;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 "../common/wivrn_packets.h"
|
||||
#include "utils/handle.h"
|
||||
#include <array>
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
#include "instance.h"
|
||||
|
||||
namespace xr
|
||||
{
|
||||
XrResult destroy_fb_face_tracker2(XrFaceTracker2FB);
|
||||
|
||||
class fb_face_tracker2 : public utils::handle<XrFaceTracker2FB, destroy_fb_face_tracker2>
|
||||
{
|
||||
PFN_xrGetFaceExpressionWeights2FB xrGetFaceExpressionWeights2FB{};
|
||||
PFN_xrDestroyFaceTracker2FB xrDestroyFaceTracker2FB{};
|
||||
|
||||
public:
|
||||
fb_face_tracker2() = default;
|
||||
fb_face_tracker2(instance & inst, XrFaceTracker2FB h);
|
||||
fb_face_tracker2(fb_face_tracker2 &&) = default;
|
||||
fb_face_tracker2 & operator=(fb_face_tracker2 &&) = default;
|
||||
|
||||
~fb_face_tracker2()
|
||||
{
|
||||
if (id != XR_NULL_HANDLE && xrDestroyFaceTracker2FB)
|
||||
xrDestroyFaceTracker2FB(id);
|
||||
}
|
||||
|
||||
void get_weights(XrTime time, struct xrt::drivers::wivrn::from_headset::fb_face2 * out_expressions);
|
||||
};
|
||||
} // namespace xr
|
||||
@@ -94,6 +94,28 @@ xr::hand_tracker xr::session::create_hand_tracker(XrHandEXT hand, XrHandJointSet
|
||||
}};
|
||||
}
|
||||
|
||||
xr::fb_face_tracker2 xr::session::create_fb_face_tracker2()
|
||||
{
|
||||
XrFaceTrackingDataSource2FB data_sources[1];
|
||||
data_sources[0] = XR_FACE_TRACKING_DATA_SOURCE2_VISUAL_FB;
|
||||
|
||||
XrFaceTrackerCreateInfo2FB create_info{
|
||||
.type = XR_TYPE_FACE_TRACKER_CREATE_INFO2_FB,
|
||||
.next = nullptr,
|
||||
.faceExpressionSet = XR_FACE_EXPRESSION_SET2_DEFAULT_FB,
|
||||
.requestedDataSourceCount = 1,
|
||||
.requestedDataSources = data_sources,
|
||||
};
|
||||
|
||||
XrFaceTracker2FB ft;
|
||||
|
||||
auto xrCreateFaceTracker2FB = inst->get_proc<PFN_xrCreateFaceTracker2FB>("xrCreateFaceTracker2FB");
|
||||
assert(xrCreateFaceTracker2FB);
|
||||
|
||||
CHECK_XR(xrCreateFaceTracker2FB(id, &create_info, &ft));
|
||||
return {*inst, ft};
|
||||
}
|
||||
|
||||
std::vector<vk::Format> xr::session::get_swapchain_formats() const
|
||||
{
|
||||
std::vector<vk::Format> formats;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <vulkan/vulkan_raii.hpp>
|
||||
#include <openxr/openxr.h>
|
||||
|
||||
#include "fb_face_tracker2.h"
|
||||
#include "hand_tracker.h"
|
||||
#include "space.h"
|
||||
|
||||
@@ -46,6 +47,7 @@ public:
|
||||
space create_reference_space(XrReferenceSpaceType ref, const XrPosef & pose = {{0, 0, 0, 1}, {0, 0, 0}});
|
||||
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();
|
||||
|
||||
std::vector<vk::Format> get_swapchain_formats() const;
|
||||
|
||||
|
||||
@@ -105,6 +105,24 @@ XrSystemEyeGazeInteractionPropertiesEXT xr::system::eye_gaze_interaction_propert
|
||||
return eye_gaze_prop;
|
||||
}
|
||||
|
||||
XrSystemFaceTrackingProperties2FB xr::system::fb_face_tracking2_properties() const
|
||||
{
|
||||
if (!id)
|
||||
throw std::invalid_argument("this");
|
||||
|
||||
XrSystemFaceTrackingProperties2FB face_tracking_prop{
|
||||
.type = XR_TYPE_SYSTEM_FACE_TRACKING_PROPERTIES2_FB,
|
||||
};
|
||||
|
||||
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))
|
||||
|
||||
@@ -62,6 +62,7 @@ public:
|
||||
XrSystemProperties properties() const;
|
||||
XrSystemHandTrackingPropertiesEXT hand_tracking_properties() const;
|
||||
XrSystemEyeGazeInteractionPropertiesEXT eye_gaze_interaction_properties() const;
|
||||
XrSystemFaceTrackingProperties2FB fb_face_tracking2_properties() const;
|
||||
passthrough_type passthrough_supported() const;
|
||||
|
||||
XrGraphicsRequirementsVulkan2KHR graphics_requirements() const;
|
||||
|
||||
Reference in New Issue
Block a user