Use inplace_vectors in stream.cpp
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include "boost/pfr/core.hpp"
|
||||
#include "decoder/shard_accumulator.h"
|
||||
#include "hardware.h"
|
||||
#include "inplace_vector.hpp"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "utils/contains.h"
|
||||
#include "utils/named_thread.h"
|
||||
@@ -51,6 +52,7 @@
|
||||
#endif
|
||||
|
||||
using namespace wivrn;
|
||||
using namespace beman::inplace_vector;
|
||||
|
||||
// clang-format off
|
||||
static const std::unordered_map<std::string, device_id> device_ids = {
|
||||
@@ -588,8 +590,7 @@ std::array<std::shared_ptr<shard_accumulator::blit_handle>, 3> scenes::stream::c
|
||||
if (decoders.empty())
|
||||
return {};
|
||||
std::unique_lock lock(frames_mutex);
|
||||
thread_local std::vector<shard_accumulator::blit_handle *> common_frames;
|
||||
common_frames.clear();
|
||||
inplace_vector<shard_accumulator::blit_handle *, decoder_count> common_frames;
|
||||
const bool alpha = decoders[0].latest_frames[0] and decoders[0].latest_frames[0]->view_info.alpha;
|
||||
for (size_t i = 0; i < view_count + alpha; ++i)
|
||||
{
|
||||
@@ -602,7 +603,7 @@ std::array<std::shared_ptr<shard_accumulator::blit_handle>, 3> scenes::stream::c
|
||||
else
|
||||
{
|
||||
// clang-format off
|
||||
std::erase_if(common_frames,
|
||||
erase_if(common_frames,
|
||||
[this, i](auto & left)
|
||||
{
|
||||
return std::ranges::none_of(
|
||||
@@ -615,7 +616,7 @@ std::array<std::shared_ptr<shard_accumulator::blit_handle>, 3> scenes::stream::c
|
||||
// clang-format on
|
||||
}
|
||||
}
|
||||
std::array<std::shared_ptr<shard_accumulator::blit_handle>, view_count + 1> result;
|
||||
std::array<std::shared_ptr<shard_accumulator::blit_handle>, decoder_count> result;
|
||||
if (not common_frames.empty())
|
||||
{
|
||||
auto min = std::ranges::min_element(common_frames,
|
||||
@@ -958,9 +959,9 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
vk::SubmitInfo submit_info;
|
||||
submit_info.setCommandBuffers(*command_buffer);
|
||||
|
||||
std::vector<vk::Semaphore> semaphores;
|
||||
std::vector<uint64_t> semaphore_vals;
|
||||
std::vector<vk::PipelineStageFlags> wait_stages;
|
||||
inplace_vector<vk::Semaphore, decoder_count> semaphores;
|
||||
inplace_vector<uint64_t, decoder_count> semaphore_vals;
|
||||
inplace_vector<vk::PipelineStageFlags, decoder_count> wait_stages;
|
||||
for (auto b: current_blit_handles)
|
||||
{
|
||||
if (b and b->semaphore)
|
||||
@@ -1069,8 +1070,8 @@ void scenes::stream::render(const XrFrameState & frame_state)
|
||||
// Network operations may be blocking, do them once everything was submitted
|
||||
{
|
||||
// Keep a copy of the feedback packets as they can be modified if they're encrypted
|
||||
std::vector<from_headset::feedback> feedbacks;
|
||||
std::vector<serialization_packet> packets;
|
||||
inplace_vector<from_headset::feedback, decoder_count> feedbacks;
|
||||
inplace_vector<serialization_packet, decoder_count> packets;
|
||||
|
||||
feedbacks.reserve(current_blit_handles.size());
|
||||
packets.reserve(current_blit_handles.size());
|
||||
|
||||
@@ -53,6 +53,7 @@ public:
|
||||
|
||||
private:
|
||||
static const size_t view_count = 2;
|
||||
static const size_t decoder_count = view_count + 1;
|
||||
|
||||
struct accumulator_images
|
||||
{
|
||||
@@ -68,7 +69,7 @@ private:
|
||||
|
||||
// for frames inside accumulator images
|
||||
std::mutex frames_mutex;
|
||||
std::array<std::shared_ptr<wivrn::shard_accumulator::blit_handle>, view_count + 1> common_frame(XrTime display_time);
|
||||
std::array<std::shared_ptr<wivrn::shard_accumulator::blit_handle>, decoder_count> common_frame(XrTime display_time);
|
||||
|
||||
std::unique_ptr<wivrn_session> network_session;
|
||||
std::atomic<bool> exiting = false;
|
||||
@@ -86,7 +87,7 @@ private:
|
||||
|
||||
std::shared_mutex decoder_mutex;
|
||||
std::optional<to_headset::video_stream_description> video_stream_description;
|
||||
std::array<accumulator_images, view_count + 1> decoders; // Locked by decoder_mutex
|
||||
std::array<accumulator_images, decoder_count> decoders; // Locked by decoder_mutex
|
||||
|
||||
std::optional<stream_defoveator> defoveator;
|
||||
|
||||
@@ -162,7 +163,7 @@ private:
|
||||
void update_gui_position(xr::spaces controller);
|
||||
|
||||
// Keep a reference to the resources needed to blit the images until vkWaitForFences
|
||||
std::array<std::shared_ptr<wivrn::shard_accumulator::blit_handle>, view_count + 1> current_blit_handles;
|
||||
std::array<std::shared_ptr<wivrn::shard_accumulator::blit_handle>, decoder_count> current_blit_handles;
|
||||
|
||||
XrTime running_application_req = 0;
|
||||
thread_safe<to_headset::running_applications> running_applications;
|
||||
@@ -302,7 +303,7 @@ private:
|
||||
float compact_cpu_time = 0;
|
||||
float compact_gpu_time = 0;
|
||||
|
||||
void accumulate_metrics(XrTime predicted_display_time, const std::array<std::shared_ptr<wivrn::shard_accumulator::blit_handle>, view_count + 1> & blit_handles, const gpu_timestamps & timestamps);
|
||||
void accumulate_metrics(XrTime predicted_display_time, const std::array<std::shared_ptr<wivrn::shard_accumulator::blit_handle>, decoder_count> & blit_handles, const gpu_timestamps & timestamps);
|
||||
void gui_performance_metrics();
|
||||
void gui_compact_view();
|
||||
void gui_settings(float predicted_display_period);
|
||||
|
||||
Reference in New Issue
Block a user