Use VK_KHR_video_maintenance1

This commit is contained in:
Patrick Nicolas
2025-08-08 14:06:01 +02:00
parent 5097ecef3b
commit 19ad856e59
7 changed files with 266 additions and 74 deletions
-26
View File
@@ -180,32 +180,6 @@ std::unique_ptr<video_encoder> video_encoder::create(
return res;
}
#if WIVRN_USE_VULKAN_ENCODE
std::pair<std::vector<vk::VideoProfileInfoKHR>, vk::ImageUsageFlags> video_encoder::get_create_image_info(const std::vector<encoder_settings> & settings)
{
std::pair<std::vector<vk::VideoProfileInfoKHR>, vk::ImageUsageFlags> result;
for (const auto & item: settings)
{
if (item.encoder_name == encoder_vulkan)
{
result.second |= vk::ImageUsageFlagBits::eVideoEncodeSrcKHR;
switch (item.codec)
{
case h264:
result.first.push_back(video_encoder_vulkan_h264::video_profile_info.get());
break;
case h265:
// result.first.push_back(video_encoder_vulkan_h265::video_profile_info.get());
break;
case av1:
throw std::runtime_error("av1 not supported for vulkan video encode");
}
}
}
return result;
}
#endif
static const uint64_t idr_throttle = 100;
video_encoder::video_encoder(uint8_t stream_idx, to_headset::video_stream_description::channels_t channels, double bitrate_multiplier, bool async_send) :
-5
View File
@@ -20,7 +20,6 @@
#pragma once
#include "driver/clock_offset.h"
#include "wivrn_config.h"
#include "wivrn_packets.h"
#include <atomic>
@@ -114,10 +113,6 @@ public:
int input_height,
float fps);
#if WIVRN_USE_VULKAN_ENCODE
static std::pair<std::vector<vk::VideoProfileInfoKHR>, vk::ImageUsageFlags> get_create_image_info(const std::vector<encoder_settings> &);
#endif
video_encoder(uint8_t stream_idx, to_headset::video_stream_description::channels_t channels, double bitrate_multiplier, bool async_send);
virtual ~video_encoder();
+4 -2
View File
@@ -15,6 +15,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "vk/vk_helpers.h"
#include "video_encoder_vulkan.h"
#include "encoder/encoder_settings.h"
@@ -266,7 +268,7 @@ void wivrn::video_encoder_vulkan::init(const vk::VideoCapabilitiesKHR & video_ca
.layerCount = 1},
};
if (rect.offset != vk::Offset2D{0, 0})
if (rect.offset != vk::Offset2D{0, 0} or not vk.vk.features.video_maintenance_1)
{
image_view_template.subresourceRange.baseArrayLayer = 0;
for (size_t i = 0; i < num_slots; ++i)
@@ -478,7 +480,7 @@ std::pair<bool, vk::Semaphore> wivrn::video_encoder_vulkan::present_image(vk::Im
video_cmd_buf.begin({.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit});
// If we encode from top left corner, encode from the source image directly
bool encode_direct = rect.offset == vk::Offset2D{0, 0};
bool encode_direct = not slot_item.tmp_image;
vk::ImageView image_view;