Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Vindicus999
2025-06-12 17:38:48 +00:00
15 changed files with 155 additions and 46 deletions
+8 -2
View File
@@ -235,6 +235,7 @@ static VkResult create_images(struct wivrn_comp_target * cn, vk::ImageUsageFlags
.usage = VMA_MEMORY_USAGE_AUTO,
});
cn->images[i].handle = image;
cn->wivrn_bundle->name(vk::Image(image), "comp target image");
}
for (uint32_t i = 0; i < cn->image_count; i++)
@@ -269,13 +270,17 @@ static VkResult create_images(struct wivrn_comp_target * cn, vk::ImageUsageFlags
});
cn->images[i].view = VkImageView(*item.image_view_y);
cn->images[i].view_cbcr = VkImageView(*item.image_view_cbcr);
cn->wivrn_bundle->name(item.image_view_y, "comp target image view (y)");
cn->wivrn_bundle->name(item.image_view_cbcr, "comp target image view (CbCr)");
}
cn->psc.fence = vk::raii::Fence(device, vk::FenceCreateInfo{.flags = vk::FenceCreateFlagBits::eSignaled});
cn->wivrn_bundle->name(cn->psc.fence, "comp target fence");
cn->psc.command_buffer = std::move(device.allocateCommandBuffers(
{.commandPool = *cn->command_pool,
.commandBufferCount = 1})[0]);
cn->wivrn_bundle->name(cn->psc.command_buffer, "comp target command buffer");
return VK_SUCCESS;
}
@@ -300,6 +305,7 @@ static bool comp_wivrn_init_post_vulkan(struct comp_target * ct, uint32_t prefer
.flags = vk::CommandPoolCreateFlagBits::eResetCommandBuffer,
.queueFamilyIndex = vk->queue_family_index,
});
cn->wivrn_bundle->name(cn->command_pool, "comp target command pool");
}
catch (std::exception & e)
{
@@ -792,8 +798,8 @@ wivrn_comp_target::~wivrn_comp_target()
static void comp_wivrn_destroy(struct comp_target * ct)
{
auto cn = (struct wivrn_comp_target *)ct;
destroy_images(cn);
cn->self = nullptr;
cn->cnx.unset_comp_target();
delete cn;
}
static void comp_wivrn_info_gpu(struct comp_target * ct, int64_t frame_id, int64_t gpu_start_ns, int64_t gpu_end_ns, int64_t when_ns)
-1
View File
@@ -78,7 +78,6 @@ struct pseudo_swapchain
struct wivrn_comp_target : public comp_target
{
std::shared_ptr<wivrn_comp_target> self;
to_headset::video_stream_description desc{};
wivrn_pacer pacer;
+3
View File
@@ -273,6 +273,9 @@ wivrn_foveation::wivrn_foveation(wivrn_vk_bundle & bundle, const xrt_hmd_parts &
.usage = VMA_MEMORY_USAGE_AUTO,
})
{
bundle.name(command_pool, "foveation command pool");
bundle.name(cmd, "foveation command buffer");
bundle.name(vk::Buffer(host_buffer), "foveation staging buffer");
}
void wivrn_foveation::update_tracking(const from_headset::tracking & tracking, const clock_offset & offset)
+39 -13
View File
@@ -89,9 +89,8 @@ struct wivrn_comp_target_factory : public comp_target_factory
static bool create_target(const struct comp_target_factory * ctf, struct comp_compositor * c, struct comp_target ** out_ct)
{
auto self = (wivrn_comp_target_factory *)ctf;
self->session.comp_target = std::make_shared<wivrn_comp_target>(self->session, c);
self->session.comp_target->self = self->session.comp_target;
*out_ct = self->session.comp_target.get();
self->session.comp_target = new wivrn_comp_target(self->session, c);
*out_ct = self->session.comp_target;
return true;
}
};
@@ -338,6 +337,12 @@ bool wivrn_session::connected()
return connection->is_active();
}
void wivrn_session::unset_comp_target()
{
std::lock_guard lock(comp_target_mutex);
comp_target = nullptr;
}
void wivrn_session::operator()(from_headset::headset_info_packet &&)
{
U_LOG_W("unexpected headset info packet, ignoring");
@@ -431,9 +436,11 @@ void wivrn_session::operator()(const from_headset::tracking & tracking)
right_hand.update_tracking(tracking, offset);
if (eye_tracker)
eye_tracker->update_tracking(tracking, offset);
assert(comp_target);
assert(comp_target->foveation);
comp_target->foveation->update_tracking(tracking, offset);
{
std::shared_lock lock(comp_target_mutex);
if (comp_target)
comp_target->foveation->update_tracking(tracking, offset);
}
if (fb_face2_tracker)
fb_face2_tracker->update_tracking(tracking, offset);
@@ -524,11 +531,14 @@ void wivrn_session::set_tracker_enabled(int index, bool enabled)
void wivrn_session::operator()(from_headset::feedback && feedback)
{
assert(comp_target);
clock_offset o = offset_est.get_offset();
if (not o)
return;
comp_target->on_feedback(feedback, o);
{
std::shared_lock lock(comp_target_mutex);
if (comp_target)
comp_target->on_feedback(feedback, o);
}
if (feedback.received_first_packet)
dump_time("receive_begin", feedback.frame_index, o.from_headset(feedback.received_first_packet), feedback.stream_index);
@@ -563,7 +573,11 @@ void wivrn_session::operator()(from_headset::visibility_mask_changed && mask)
void wivrn_session::operator()(from_headset::refresh_rate_changed && event)
{
comp_target->set_refresh_rate(event.to);
{
std::shared_lock lock(comp_target_mutex);
if (comp_target)
comp_target->set_refresh_rate(event.to);
}
push_event(
{
.display = {
@@ -587,7 +601,9 @@ void wivrn_session::operator()(to_monado::disconnect &&)
void wivrn_session::operator()(to_monado::set_bitrate && data)
{
comp_target->set_bitrate(data.bitrate_bps);
std::shared_lock lock(comp_target_mutex);
if (comp_target)
comp_target->set_bitrate(data.bitrate_bps);
}
struct refresh_rate_adjuster
@@ -647,8 +663,14 @@ void wivrn_session::run(std::stop_token stop)
{
offset_est.request_sample(*connection);
tracking_control.send(*connection);
if (comp_target->requested_refresh_rate == 0)
refresh.adjust(*connection);
{
std::shared_lock lock(comp_target_mutex);
if (comp_target)
{
if (comp_target->requested_refresh_rate == 0)
refresh.adjust(*connection);
}
}
connection->poll(*this, 20);
}
catch (const std::exception & e)
@@ -725,7 +747,11 @@ void wivrn_session::reconnect()
// const auto & info = connection->info();
// FIXME: ensure new client is compatible
comp_target->reset_encoders();
{
std::shared_lock lock(comp_target_mutex);
if (comp_target)
comp_target->reset_encoders();
}
if (audio_handle)
send_control(audio_handle->description());
+6 -2
View File
@@ -32,8 +32,8 @@
#include <fstream>
#include <memory>
#include <mutex>
#include <shared_mutex>
#include <thread>
#include <vector>
struct u_system;
struct xrt_space_overseer;
@@ -113,7 +113,9 @@ class wivrn_session : public xrt_system_devices
uint32_t num_generic_trackers;
std::array<std::unique_ptr<wivrn_generic_tracker>, from_headset::body_tracking::max_tracked_poses> generic_trackers;
std::array<bool, from_headset::body_tracking::max_tracked_poses> enabled_trackers;
std::shared_ptr<wivrn_comp_target> comp_target;
std::shared_mutex comp_target_mutex;
wivrn_comp_target * comp_target;
clock_offset_estimator offset_est;
@@ -146,6 +148,8 @@ public:
return connection->info();
};
void unset_comp_target();
wivrn_hmd & get_hmd()
{
return hmd;