Support passthrough for stream

This commit is contained in:
Patrick Nicolas
2024-11-06 19:50:44 +01:00
parent 45412e3389
commit 410b112fcf
34 changed files with 571 additions and 260 deletions
+2 -2
View File
@@ -85,7 +85,7 @@ decoder::decoder(
uint8_t stream_index,
std::weak_ptr<scenes::stream> weak_scene,
shard_accumulator * accumulator) :
description(description), fps(fps), device(device), weak_scene(weak_scene), accumulator(accumulator)
description(description), stream_index(stream_index), fps(fps), device(device), weak_scene(weak_scene), accumulator(accumulator)
{
spdlog::info("hbm_mutex.native_handle() = {}", (void *)hbm_mutex.native_handle());
@@ -372,7 +372,7 @@ void decoder::create_sampler(const AHardwareBuffer_Desc & buffer_desc, vk::Andro
},
};
ycbcr_sampler = vk::raii::Sampler(device, sampler_info.get<vk::SamplerCreateInfo>());
ycbcr_sampler = vk::raii::Sampler(device, sampler_info.get());
}
std::shared_ptr<decoder::mapped_hardware_buffer> decoder::map_hardware_buffer(AImage * image)
+1
View File
@@ -85,6 +85,7 @@ public:
private:
wivrn::to_headset::video_stream_description::item description;
uint8_t stream_index;
float fps;
vk::raii::Device & device;
+2 -12
View File
@@ -28,6 +28,7 @@
#include "render/scene_data.h"
#include "render/scene_renderer.h"
#include "stream.h"
#include "utils/overloaded.h"
#include "version.h"
#include "wivrn_client.h"
#include "wivrn_packets.h"
@@ -573,17 +574,6 @@ static std::vector<XrCompositionLayerProjectionView> render_layer(std::vector<Xr
return std::get<0>(render_layer(views, color_swapchains, depth_swapchains, renderer, data, clear_color));
}
namespace
{
template <class... Ts>
struct overloaded : Ts...
{
using Ts::operator()...;
};
template <class... Ts>
overloaded(Ts...) -> overloaded<Ts...>;
} // namespace
// Return the vector v such that dot(v, x) > 0 iff x is on the side where the composition layer is visible
static glm::vec4 compute_ray_limits(const XrPosef & pose, float margin = 0)
{
@@ -873,7 +863,7 @@ void scenes::lobby::render(const XrFrameState & frame_state)
if (application::get_config().passthrough_enabled)
{
std::visit(
overloaded{
utils::overloaded{
[&](std::monostate &) {
assert(false);
},
+156 -95
View File
@@ -16,6 +16,7 @@
* 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 "utils/overloaded.h"
#define GLM_FORCE_RADIANS
#include "stream.h"
@@ -127,6 +128,7 @@ std::shared_ptr<scenes::stream> scenes::stream::create(std::unique_ptr<wivrn_ses
info.eye_gaze = config.check_feature(feature::eye_gaze);
info.face_tracking2_fb = config.check_feature(feature::face_tracking);
info.palm_pose = application::space(xr::spaces::palm_left) or application::space(xr::spaces::palm_right);
info.passthrough = self->system.passthrough_supported() != xr::system::passthrough_type::no_passthrough;
audio::get_audio_description(info);
if (not(config.check_feature(feature::microphone)))
@@ -259,7 +261,7 @@ void scenes::stream::push_blit_handle(shard_accumulator * decoder, std::shared_p
{
std::shared_lock lock(decoder_mutex);
std::unique_lock frame_lock(frames_mutex);
const auto stream = handle->feedback.stream_index;
auto stream = handle->feedback.stream_index;
if (stream < decoders.size())
{
assert(decoder == decoders[stream].decoder.get());
@@ -267,8 +269,8 @@ void scenes::stream::push_blit_handle(shard_accumulator * decoder, std::shared_p
std::swap(handle, decoders[stream].latest_frames[handle->feedback.frame_index % decoders[stream].latest_frames.size()]);
}
if (state_ != state::streaming && std::all_of(decoders.begin(), decoders.end(), [](accumulator_images & i) {
return i.latest_frames.back();
if (state_ != state::streaming and std::ranges::all_of(decoders, [](accumulator_images & i) {
return i.alpha() or not i.frames().empty();
}))
{
state_ = state::streaming;
@@ -282,6 +284,11 @@ void scenes::stream::push_blit_handle(shard_accumulator * decoder, std::shared_p
}
}
bool scenes::stream::accumulator_images::alpha() const
{
return decoder->desc().channels == wivrn::to_headset::video_stream_description::channels_t::alpha;
}
std::vector<uint64_t> scenes::stream::accumulator_images::frames() const
{
std::vector<uint64_t> result;
@@ -300,8 +307,11 @@ std::vector<std::shared_ptr<shard_accumulator::blit_handle>> scenes::stream::com
std::unique_lock lock(frames_mutex);
thread_local std::vector<shard_accumulator::blit_handle *> common_frames;
common_frames.clear();
const bool alpha = decoders[0].latest_frames[0] and decoders[0].latest_frames[0]->view_info.alpha;
for (size_t i = 0; i < decoders.size(); ++i)
{
if (decoders[i].alpha() and not alpha)
continue;
if (i == 0)
{
for (const auto & h: decoders[i].latest_frames)
@@ -324,7 +334,8 @@ std::vector<std::shared_ptr<shard_accumulator::blit_handle>> scenes::stream::com
// clang-format on
}
}
std::optional<uint64_t> frame_index;
std::vector<std::shared_ptr<shard_accumulator::blit_handle>> result;
result.reserve(decoders.size());
if (not common_frames.empty())
{
auto min = std::ranges::min_element(common_frames,
@@ -336,7 +347,14 @@ std::vector<std::shared_ptr<shard_accumulator::blit_handle>> scenes::stream::com
});
assert(*min);
frame_index = (*min)->feedback.frame_index;
auto frame_index = (*min)->feedback.frame_index;
for (const auto & decoder: decoders)
{
if (alpha or not decoder.alpha())
result.emplace_back(decoder.frame(frame_index));
else
result.emplace_back(nullptr);
}
}
else
{
@@ -353,22 +371,35 @@ std::vector<std::shared_ptr<shard_accumulator::blit_handle>> scenes::stream::com
}
spdlog::warn(frames);
}
for (const auto & decoder: decoders)
{
if (alpha or not decoder.alpha())
{
auto min = std::ranges::min_element(decoder.latest_frames,
std::ranges::less{},
[display_time](auto frame) {
if (not frame)
return std::numeric_limits<XrTime>::max();
return std::abs(frame->view_info.display_time - display_time);
});
result.emplace_back(*min);
}
else
result.emplace_back(nullptr);
}
}
std::vector<std::shared_ptr<shard_accumulator::blit_handle>> result;
result.reserve(decoders.size());
for (const auto & decoder: decoders)
result.push_back(decoder.frame(frame_index));
return result;
}
std::shared_ptr<shard_accumulator::blit_handle> scenes::stream::accumulator_images::frame(std::optional<uint64_t> id) const
std::shared_ptr<shard_accumulator::blit_handle> scenes::stream::accumulator_images::frame(uint64_t id) const
{
for (auto it = latest_frames.rbegin(); it != latest_frames.rend(); ++it)
{
if (not *it)
continue;
if (id and (*it)->feedback.frame_index != *id)
if ((*it)->feedback.frame_index != id)
continue;
return *it;
@@ -461,15 +492,25 @@ void scenes::stream::render(const XrFrameState & frame_state)
vert_specialization_info.setMapEntries(specialization_constants_desc);
vert_specialization_info.setData<float>(useful_size);
VkBool32 do_srgb = need_srgb_conversion(guess_model());
vk::SpecializationMapEntry frag_specialization_constant_desc{
.constantID = 0,
.offset = 0,
.size = sizeof(do_srgb),
std::array<VkBool32, 2> constants = {
need_srgb_conversion(guess_model()),
i.alpha(),
};
std::array frag_specialization_constant_desc = {
vk::SpecializationMapEntry{
.constantID = 0,
.offset = 0,
.size = sizeof(constants[0]),
},
vk::SpecializationMapEntry{
.constantID = 1,
.offset = sizeof(constants[0]),
.size = sizeof(constants[1]),
},
};
vk::SpecializationInfo frag_specialization_info;
frag_specialization_info.setMapEntries(frag_specialization_constant_desc);
frag_specialization_info.setData<VkBool32>(do_srgb);
frag_specialization_info.setData<VkBool32>(constants);
// Create graphics pipeline
vk::raii::ShaderModule vertex_shader = load_shader(device, "stream.vert");
@@ -511,7 +552,9 @@ void scenes::stream::render(const XrFrameState & frame_state)
.MultisampleState = {{
.rasterizationSamples = vk::SampleCountFlagBits::e1,
}},
.ColorBlendAttachments = {{.colorWriteMask = vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG | vk::ColorComponentFlagBits::eB}},
.ColorBlendAttachments = {
{.colorWriteMask = i.alpha() ? vk::ColorComponentFlagBits::eA
: vk::ColorComponentFlagBits::eA | vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG | vk::ColorComponentFlagBits::eB}},
.DynamicStates = {vk::DynamicState::eViewport, vk::DynamicState::eScissor},
.layout = *i.blit_pipeline_layout,
.renderPass = *blit_render_pass,
@@ -566,68 +609,67 @@ void scenes::stream::render(const XrFrameState & frame_state)
command_buffer.begin(begin_info);
// Keep a reference to the resources needed to blit the images until vkWaitForFences
std::vector<std::shared_ptr<shard_accumulator::blit_handle>> blit_handles;
command_buffer.resetQueryPool(*query_pool, 0, size_gpu_timestamps);
command_buffer.writeTimestamp(vk::PipelineStageFlagBits::eTopOfPipe, *query_pool, 0);
// Search for frame with desired display time on all decoders
// If no such frame exists, use the latest frame for each decoder
current_blit_handles = common_frame(frame_state.predictedDisplayTime);
std::array<XrPosef, 2> pose{};
std::array<XrFovf, 2> fov{};
std::array<wivrn::to_headset::foveation_parameter, 2> foveation{};
bool use_alpha = false;
// Blit images from the decoders
for (auto [i, blit_handle]: std::views::zip(decoders, current_blit_handles))
{
// Search for frame with desired display time on all decoders
// If no such frame exists, use the latest frame for each decoder
blit_handles = common_frame(frame_state.predictedDisplayTime);
if (not blit_handle)
continue;
// Blit images from the decoders
for (auto [i, blit_handle]: std::views::zip(decoders, blit_handles))
blit_handle->feedback.blitted = application::now();
if (blit_handle->feedback.blitted - blit_handle->feedback.received_from_decoder > 1'000'000'000)
state_ = stream::state::stalled;
++blit_handle->feedback.times_displayed;
blit_handle->feedback.displayed = frame_state.predictedDisplayTime;
pose = blit_handle->view_info.pose;
fov = blit_handle->view_info.fov;
foveation = blit_handle->view_info.foveation;
use_alpha = blit_handle->view_info.alpha;
vk::DescriptorImageInfo image_info{
.imageView = *blit_handle->image_view,
.imageLayout = vk::ImageLayout::eGeneral,
};
vk::WriteDescriptorSet descriptor_write{
.dstSet = i.descriptor_set,
.dstBinding = 0,
.dstArrayElement = 0,
.descriptorCount = 1,
.descriptorType = vk::DescriptorType::eCombinedImageSampler,
.pImageInfo = &image_info,
};
device.updateDescriptorSets(descriptor_write, {});
if (*blit_handle->current_layout != vk::ImageLayout::eGeneral)
{
if (not blit_handle)
continue;
blit_handle->feedback.blitted = application::now();
if (blit_handle->feedback.blitted - blit_handle->feedback.received_from_decoder > 1'000'000'000)
state_ = stream::state::stalled;
++blit_handle->feedback.times_displayed;
blit_handle->feedback.displayed = frame_state.predictedDisplayTime;
pose = blit_handle->view_info.pose;
fov = blit_handle->view_info.fov;
foveation = blit_handle->view_info.foveation;
vk::DescriptorImageInfo image_info{
.imageView = *blit_handle->image_view,
.imageLayout = vk::ImageLayout::eGeneral,
vk::ImageMemoryBarrier barrier{
.srcAccessMask = vk::AccessFlagBits::eNone,
.dstAccessMask = vk::AccessFlagBits::eMemoryRead,
.oldLayout = *blit_handle->current_layout,
.newLayout = vk::ImageLayout::eGeneral,
.image = blit_handle->image,
.subresourceRange = {
.aspectMask = vk::ImageAspectFlagBits::eColor,
.levelCount = 1,
.layerCount = 1,
},
};
vk::WriteDescriptorSet descriptor_write{
.dstSet = i.descriptor_set,
.dstBinding = 0,
.dstArrayElement = 0,
.descriptorCount = 1,
.descriptorType = vk::DescriptorType::eCombinedImageSampler,
.pImageInfo = &image_info,
};
device.updateDescriptorSets(descriptor_write, {});
if (*blit_handle->current_layout != vk::ImageLayout::eGeneral)
{
vk::ImageMemoryBarrier barrier{
.srcAccessMask = vk::AccessFlagBits::eNone,
.dstAccessMask = vk::AccessFlagBits::eMemoryRead,
.oldLayout = *blit_handle->current_layout,
.newLayout = vk::ImageLayout::eGeneral,
.image = blit_handle->image,
.subresourceRange = {
.aspectMask = vk::ImageAspectFlagBits::eColor,
.levelCount = 1,
.layerCount = 1,
},
};
command_buffer.pipelineBarrier(vk::PipelineStageFlagBits::eAllCommands, vk::PipelineStageFlagBits::eAllCommands, {}, {}, {}, barrier);
*blit_handle->current_layout = vk::ImageLayout::eGeneral;
}
command_buffer.pipelineBarrier(vk::PipelineStageFlagBits::eAllCommands, vk::PipelineStageFlagBits::eAllCommands, {}, {}, {}, barrier);
*blit_handle->current_layout = vk::ImageLayout::eGeneral;
}
}
@@ -650,20 +692,22 @@ void scenes::stream::render(const XrFrameState & frame_state)
{
if (not *decoder.blit_pipeline)
continue;
if (decoder.alpha() and not use_alpha)
continue;
command_buffer.bindPipeline(vk::PipelineBindPoint::eGraphics, *decoder.blit_pipeline);
const auto & description = decoder.decoder->desc();
int x0 = description.offset_x - x_offset;
int y0 = description.offset_y;
int x1 = x0 + description.width;
int y1 = y0 + description.height;
int x1 = x0 + description.width * description.subsampling;
int y1 = y0 + description.height * description.subsampling;
vk::Viewport viewport{
.x = (float)x0,
.y = (float)y0,
.width = (float)description.width,
.height = (float)description.height,
.width = float(description.width * description.subsampling),
.height = float(description.height * description.subsampling),
.minDepth = 0,
.maxDepth = 1,
};
@@ -710,9 +754,27 @@ void scenes::stream::render(const XrFrameState & frame_state)
submit_info.setCommandBuffers(*command_buffer);
queue.submit(submit_info, *fence);
XrEnvironmentBlendMode blend_mode = XR_ENVIRONMENT_BLEND_MODE_OPAQUE;
std::vector<XrCompositionLayerBaseHeader *> layers_base;
std::vector<XrCompositionLayerProjectionView> layer_view(view_count);
if (use_alpha)
{
session.enable_passthrough(system);
std::visit(
utils::overloaded{
[&](std::monostate &) {
assert(false);
},
[&](xr::passthrough_alpha_blend & p) {
blend_mode = XR_ENVIRONMENT_BLEND_MODE_ALPHA_BLEND;
},
[&](auto & p) {
layers_base.push_back(p.layer());
}},
session.get_passthrough());
}
for (size_t swapchain_index = 0; swapchain_index < view_count; swapchain_index++)
{
swapchains[swapchain_index].release();
@@ -738,7 +800,7 @@ void scenes::stream::render(const XrFrameState & frame_state)
XrCompositionLayerProjection layer{
.type = XR_TYPE_COMPOSITION_LAYER_PROJECTION,
.layerFlags = 0,
.layerFlags = XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT,
.space = application::space(xr::spaces::world),
.viewCount = (uint32_t)layer_view.size(),
.views = layer_view.data(),
@@ -747,7 +809,7 @@ void scenes::stream::render(const XrFrameState & frame_state)
std::vector<XrCompositionLayerQuad> imgui_layers;
if (imgui_ctx and plots_visible)
{
accumulate_metrics(frame_state.predictedDisplayTime, blit_handles, timestamps);
accumulate_metrics(frame_state.predictedDisplayTime, current_blit_handles, timestamps);
imgui_layers = plot_performance_metrics(frame_state.predictedDisplayTime);
}
@@ -761,7 +823,7 @@ void scenes::stream::render(const XrFrameState & frame_state)
try
{
session.end_frame(frame_state.predictedDisplayTime, layers_base);
session.end_frame(frame_state.predictedDisplayTime, layers_base, blend_mode);
}
catch (std::system_error & e)
{
@@ -774,8 +836,8 @@ void scenes::stream::render(const XrFrameState & frame_state)
// Network operations may be blocking, do them once everything was submitted
{
std::vector<serialization_packet> packets;
packets.reserve(blit_handles.size());
for (const auto & handle: blit_handles)
packets.reserve(current_blit_handles.size());
for (const auto & handle: current_blit_handles)
{
if (handle)
{
@@ -929,37 +991,36 @@ void scenes::stream::setup(const to_headset::video_stream_description & descript
{
vk::DescriptorPoolSize pool_size{
.type = vk::DescriptorType::eCombinedImageSampler,
.descriptorCount = uint32_t(description.items.size()),
.descriptorCount = uint32_t(2 * description.items.size()),
};
blit_descriptor_pool = vk::raii::DescriptorPool(
device,
vk::DescriptorPoolCreateInfo{
.maxSets = uint32_t(description.items.size()),
.maxSets = uint32_t(2 * description.items.size()),
.poolSizeCount = 1,
.pPoolSizes = &pool_size,
});
}
if (instance.has_extension(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME))
{
try
{
session.set_refresh_rate(description.fps);
}
catch (std::exception & e)
{
spdlog::warn("Failed to set refresh rate to {}: {}", description.fps, e.what());
}
}
for (const auto & [stream_index, item]: utils::enumerate(description.items))
{
spdlog::info("Creating decoder size {}x{} offset {},{}", item.width, item.height, item.offset_x, item.offset_y);
if (instance.has_extension(XR_FB_DISPLAY_REFRESH_RATE_EXTENSION_NAME))
{
try
{
session.set_refresh_rate(description.fps);
}
catch (std::exception & e)
{
spdlog::warn("Failed to set refresh rate to {}: {}", description.fps, e.what());
}
}
accumulator_images dec;
dec.decoder = std::make_unique<shard_accumulator>(device, physical_device, item, description.fps, shared_from_this(), stream_index);
decoders.push_back(std::move(dec));
decoders.push_back(accumulator_images{
.decoder = std::make_unique<shard_accumulator>(device, physical_device, item, description.fps, shared_from_this(), stream_index),
});
}
}
+5 -1
View File
@@ -27,6 +27,7 @@
#include "wifi_lock.h"
#include "wivrn_client.h"
#include "wivrn_packets.h"
#include "xr/passthrough.h"
#include <mutex>
#include <shared_mutex>
#include <thread>
@@ -60,7 +61,8 @@ private:
// latest frames from oldest to most recent
std::array<std::shared_ptr<wivrn::shard_accumulator::blit_handle>, image_buffer_size> latest_frames;
std::shared_ptr<wivrn::shard_accumulator::blit_handle> frame(std::optional<uint64_t> id) const;
std::shared_ptr<wivrn::shard_accumulator::blit_handle> frame(uint64_t id) const;
bool alpha() const;
std::vector<uint64_t> frames() const;
};
@@ -99,6 +101,8 @@ private:
std::optional<stream_reprojection> reprojector;
std::optional<xr::passthrough> passthrough;
vk::raii::Fence fence = nullptr;
vk::raii::CommandBuffer command_buffer = nullptr;
+2 -2
View File
@@ -45,12 +45,12 @@ void scenes::stream::process_packets()
void scenes::stream::operator()(to_headset::video_stream_data_shard && shard)
{
std::shared_lock lock(decoder_mutex);
if (shard.stream_item_idx >= decoders.size())
uint8_t idx = shard.stream_item_idx;
if (idx >= decoders.size())
{
// We don't know (yet?) about this stream, ignore packet
return;
}
auto idx = shard.stream_item_idx;
decoders[idx].decoder->push_shard(std::move(shard));
}
-3
View File
@@ -390,7 +390,6 @@ void stream_reprojection::reproject(vk::raii::CommandBuffer & command_buffer, in
ubo[source]->xc.y = foveation_parameters[source].y.center;
}
vk::ClearValue clear(vk::ClearColorValue(0, 0, 0, 0));
vk::RenderPassBeginInfo begin_info{
.renderPass = *renderpass,
.framebuffer = *framebuffers[destination],
@@ -398,8 +397,6 @@ void stream_reprojection::reproject(vk::raii::CommandBuffer & command_buffer, in
.offset = {0, 0},
.extent = extent,
},
.clearValueCount = 1,
.pClearValues = &clear,
};
command_buffer.pipelineBarrier(
+3 -1
View File
@@ -111,6 +111,8 @@ void scenes::stream::accumulate_metrics(XrTime predicted_display_time, const std
{
if (metrics.size() != global_metrics.size())
metrics.resize(global_metrics.size());
if (not bh)
continue;
// clang-format off
metrics[metrics_offset] = bh ? decoder_metric{
@@ -155,7 +157,7 @@ std::vector<XrCompositionLayerQuad> scenes::stream::plot_performance_metrics(XrT
// clang-format on
};
int n_plots = plots.size() + decoders.size();
int n_plots = plots.size() + decoder_metrics.size();
axis_scale.resize(n_plots);
int n_cols = 2;
+1 -1
View File
@@ -83,7 +83,7 @@ layout(location = 0) out vec4 outColor;
void main()
{
outColor = vec4(texture(texSampler, inUV).rgb, 1);
outColor = texture(texSampler, inUV).rgba;
}
#endif
+15 -10
View File
@@ -21,8 +21,8 @@
#ifdef VERT_SHADER
layout (constant_id = 0) const float useful_size_x = 1.0;
layout (constant_id = 1) const float useful_size_y = 1.0;
layout(constant_id = 0) const float useful_size_x = 1.0;
layout(constant_id = 1) const float useful_size_y = 1.0;
vec2 positions[3] = vec2[](
vec2(-1.0, -1.0),
@@ -46,6 +46,7 @@ void main()
#ifdef FRAG_SHADER
layout(binding = 0) uniform sampler2D texSampler;
layout(constant_id = 0) const bool do_srgb = true;
layout(constant_id = 1) const bool is_alpha = false;
layout(location = 0) in vec2 inUV;
@@ -53,19 +54,18 @@ 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);
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
);
sRGB_to_linear(x.r),
sRGB_to_linear(x.g),
sRGB_to_linear(x.b),
x.r);
}
void main()
@@ -77,6 +77,11 @@ void main()
else
{
outColor = texture(texSampler, inUV);
outColor.a = outColor.r;
}
if (!is_alpha)
{
outColor.a = 1;
}
}
#endif
+31
View File
@@ -0,0 +1,31 @@
/*
* WiVRn VR streaming
* Copyright (C) 2024 Guillaume Meunier <guillaume.meunier@centraliens.net>
* Copyright (C) 2024 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/>.
*/
#pragma once
namespace utils
{
template <class... Ts>
struct overloaded : Ts...
{
using Ts::operator()...;
};
template <class... Ts>
overloaded(Ts...) -> overloaded<Ts...>;
} // namespace utils
+6 -1
View File
@@ -21,8 +21,8 @@
#include "application.h"
#include "details/enumerate.h"
#include "xr/instance.h"
#include "utils/contains.h"
#include "xr/instance.h"
#include "xr/system.h"
#include <ranges>
#include <vulkan/vulkan.h>
@@ -347,6 +347,9 @@ void xr::session::sync_actions(XrActionSet action_set, const std::string & subac
void xr::session::enable_passthrough(xr::system & system)
{
if (not std::holds_alternative<std::monostate>(passthrough))
return;
if (system.passthrough_supported() == xr::system::passthrough_type::no_passthrough)
return;
@@ -366,5 +369,7 @@ void xr::session::enable_passthrough(xr::system & system)
void xr::session::disable_passthrough()
{
if (std::holds_alternative<std::monostate>(passthrough))
return;
passthrough.emplace<std::monostate>();
}