expose wivrn_comp_target class

This commit is contained in:
Patrick Nicolas
2023-12-14 23:42:08 +01:00
parent a8c8e7f4b9
commit 6e14bac589
3 changed files with 90 additions and 83 deletions
+19 -81
View File
@@ -32,59 +32,6 @@
static const uint8_t image_free = 0;
static const uint8_t image_acquired = 1;
struct pseudo_swapchain
{
struct pseudo_swapchain_memory
{
VkFence fence;
VkDeviceMemory memory;
VkCommandBuffer present_cmd;
uint8_t status; // bitmask of consumer status, index 0 for acquired, the rest for each encoder
uint64_t frame_index;
to_headset::video_stream_data_shard::view_info_t view_info{};
} * images{};
std::mutex mutex;
std::condition_variable cv;
};
struct wivrn_comp_target : public comp_target
{
//! Compositor frame pacing helper
struct u_pacing_compositor * upc{};
vk_cmd_pool pool;
float fps;
int64_t current_frame_id;
// Monotonic counter, for video stream
uint64_t frame_index = 0;
struct pseudo_swapchain psc;
VkColorSpaceKHR color_space;
struct encoder_thread
{
int index;
os_thread_helper thread;
encoder_thread()
{
os_thread_helper_init(&thread);
}
~encoder_thread()
{
os_thread_helper_stop_and_wait(&thread);
os_thread_helper_destroy(&thread);
}
};
std::list<encoder_thread> encoder_threads;
std::vector<std::shared_ptr<VideoEncoder>> encoders;
std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx;
};
static void target_init_semaphores(struct wivrn_comp_target * cn);
@@ -751,36 +698,27 @@ static void comp_wivrn_info_gpu(struct comp_target * ct, int64_t frame_id, uint6
u_pc_info_gpu(cn->upc, frame_id, gpu_start_ns, gpu_end_ns, when_ns);
}
/*
*
* 'Exported' functions.
*
*/
comp_target * comp_target_wivrn_create(std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx, struct comp_compositor * c, float fps)
wivrn_comp_target::wivrn_comp_target(std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx, struct comp_compositor * c, float fps) :
comp_target{},
cnx(cnx)
{
wivrn_comp_target * cn = new wivrn_comp_target{};
// FIXME: monado may need a fix to set the correct pose when timewarping
c->debug.atw_off = true;
cn->cnx = cnx;
cn->check_ready = comp_wivrn_check_ready;
cn->create_images = comp_wivrn_create_images;
cn->has_images = comp_wivrn_has_images;
cn->acquire = comp_wivrn_acquire;
cn->present = comp_wivrn_present;
cn->calc_frame_pacing = comp_wivrn_calc_frame_pacing;
cn->mark_timing_point = comp_wivrn_mark_timing_point;
cn->update_timings = comp_wivrn_update_timings;
cn->info_gpu = comp_wivrn_info_gpu;
cn->destroy = comp_wivrn_destroy;
cn->init_pre_vulkan = comp_wivrn_init_pre_vulkan;
cn->init_post_vulkan = comp_wivrn_init_post_vulkan;
cn->set_title = comp_wivrn_set_title;
cn->flush = comp_wivrn_flush;
cn->fps = fps;
cn->c = c;
return cn;
check_ready = comp_wivrn_check_ready;
create_images = comp_wivrn_create_images;
has_images = comp_wivrn_has_images;
acquire = comp_wivrn_acquire;
present = comp_wivrn_present;
calc_frame_pacing = comp_wivrn_calc_frame_pacing;
mark_timing_point = comp_wivrn_mark_timing_point;
update_timings = comp_wivrn_update_timings;
info_gpu = comp_wivrn_info_gpu;
destroy = comp_wivrn_destroy;
init_pre_vulkan = comp_wivrn_init_pre_vulkan;
init_post_vulkan = comp_wivrn_init_post_vulkan;
set_title = comp_wivrn_set_title;
flush = comp_wivrn_flush;
this->fps = fps;
this->c = c;
}
+70 -1
View File
@@ -22,5 +22,74 @@
#include "wivrn_session.h"
#include "main/comp_target.h"
#include "vk/vk_cmd_pool.h"
comp_target * comp_target_wivrn_create(std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx, struct comp_compositor *c, float fps);
#include <condition_variable>
#include <list>
#include <memory>
#include <vector>
struct u_pacing_compositor;
namespace xrt::drivers::wivrn
{
class VideoEncoder;
struct pseudo_swapchain
{
struct pseudo_swapchain_memory
{
VkFence fence;
VkDeviceMemory memory;
VkCommandBuffer present_cmd;
uint8_t status; // bitmask of consumer status, index 0 for acquired, the rest for each encoder
uint64_t frame_index;
to_headset::video_stream_data_shard::view_info_t view_info{};
} * images{};
std::mutex mutex;
std::condition_variable cv;
};
struct wivrn_comp_target : public comp_target
{
//! Compositor frame pacing helper
u_pacing_compositor * upc{};
vk_cmd_pool pool;
float fps;
int64_t current_frame_id;
// Monotonic counter, for video stream
uint64_t frame_index = 0;
pseudo_swapchain psc;
VkColorSpaceKHR color_space;
struct encoder_thread
{
int index;
os_thread_helper thread;
encoder_thread()
{
os_thread_helper_init(&thread);
}
~encoder_thread()
{
os_thread_helper_stop_and_wait(&thread);
os_thread_helper_destroy(&thread);
}
};
std::list<encoder_thread> encoder_threads;
std::vector<std::shared_ptr<VideoEncoder>> encoders;
std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx;
wivrn_comp_target(std::shared_ptr<xrt::drivers::wivrn::wivrn_session> cnx, struct comp_compositor * c, float fps);
};
} // namespace xrt::drivers::wivrn
+1 -1
View File
@@ -59,7 +59,7 @@ 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;
*out_ct = comp_target_wivrn_create(self->session, c, self->fps);
*out_ct = new wivrn_comp_target(self->session, c, self->fps);
return true;
}
};