Release swapchain earlier

Encoders now have a buffer for next image so that they can encode one
and the compositor write to an other one.
This commit is contained in:
Patrick Nicolas
2024-09-11 23:41:10 +02:00
parent 517b572c75
commit 7e8c479cc5
11 changed files with 311 additions and 253 deletions
+8 -3
View File
@@ -72,9 +72,13 @@ private:
protected:
uint8_t stream_idx;
static const uint8_t num_slots = 2;
private:
std::mutex mutex;
std::array<std::atomic<bool>, num_slots> busy = {false, false};
uint8_t next_present = 0;
uint8_t next_encode = 0;
// temporary data
wivrn_session * cnx;
@@ -104,8 +108,7 @@ public:
VideoEncoder(bool async_send = false);
virtual ~VideoEncoder();
// called on present to submit command buffers for the image.
virtual void PresentImage(vk::Image y_cbcr, vk::raii::CommandBuffer & cmd_buf) = 0;
void PresentImage(vk::Image y_cbcr, vk::raii::CommandBuffer & cmd_buf);
// The other end lost a frame and needs to resynchronize
void SyncNeeded();
@@ -115,8 +118,10 @@ public:
uint64_t frame_index);
protected:
// called on present to submit command buffers for the image.
virtual void present_image(vk::Image y_cbcr, vk::raii::CommandBuffer & cmd_buf, uint8_t slot) = 0;
// called when command buffer finished executing
virtual std::optional<data> encode(bool idr, std::chrono::steady_clock::time_point target_timestamp) = 0;
virtual std::optional<data> encode(bool idr, std::chrono::steady_clock::time_point target_timestamp, uint8_t slot) = 0;
void SendData(std::span<uint8_t> data, bool end_of_frame);
};