From 66b7b1fabb2246da46857c22dc02269b4106d8de Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Sat, 23 Aug 2025 11:07:48 +0200 Subject: [PATCH] Return image to swapchain after encode is done Vulkan video encode may use the original image, only mark it as free once it is done encoding. --- server/driver/wivrn_comp_target.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/server/driver/wivrn_comp_target.cpp b/server/driver/wivrn_comp_target.cpp index b529e359..46a0be4e 100644 --- a/server/driver/wivrn_comp_target.cpp +++ b/server/driver/wivrn_comp_target.cpp @@ -483,20 +483,6 @@ static void comp_wivrn_present_thread(std::stop_token stop_token, wivrn_comp_tar auto res = vk.device.waitForFences(*cn->psc.fence, true, UINT64_MAX); - // Update encoder status, release image - if ((cn->psc.status &= ~status_bit) == 0) - { - cn->psc.status.notify_all(); - for (auto & img: cn->psc.images) - { - if (img.status == pseudo_swapchain::status_t::encoding) - { - img.status = pseudo_swapchain::status_t::free; - break; - } - } - } - try { for (auto & encoder: encoders) @@ -513,6 +499,20 @@ static void comp_wivrn_present_thread(std::stop_token stop_token, wivrn_comp_tar { // Ignore errors } + + // Update encoder status, release image + if ((cn->psc.status &= ~status_bit) == 0) + { + cn->psc.status.notify_all(); + for (auto & img: cn->psc.images) + { + if (img.status == pseudo_swapchain::status_t::encoding) + { + img.status = pseudo_swapchain::status_t::free; + break; + } + } + } } }