From 802a96572e24a4b0054705f27b2e2a05595ab707 Mon Sep 17 00:00:00 2001 From: Patrick Nicolas Date: Tue, 11 Feb 2025 08:59:21 +0100 Subject: [PATCH] Probe for nvenc support --- server/encoder/encoder_settings.cpp | 47 +++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/server/encoder/encoder_settings.cpp b/server/encoder/encoder_settings.cpp index ec480a03..2727e805 100644 --- a/server/encoder/encoder_settings.cpp +++ b/server/encoder/encoder_settings.cpp @@ -180,6 +180,35 @@ static std::optional filter_codecs_vaapi(wivrn_vk_bundle & b } #endif +#if WIVRN_USE_NVENC +static bool probe_nvenc(wivrn_vk_bundle & bundle) +{ + static bool res = [&]() { + encoder_settings s{ + { + .width = 800, + .height = 600, + .video_width = 800, + .video_height = 600, + .codec = h264, + }, + encoder_nvenc, + default_bitrate, + }; + try + { + video_encoder_nvenc test(bundle, s, 60, 0); + return true; + } + catch (std::exception & e) + { + U_LOG_W("nvenc not supported: %s", e.what()); + return false; + } }(); + return res; +} +#endif + static void fill_defaults(wivrn_vk_bundle & bundle, const std::vector & headset_codecs, configuration::encoder & config) { if (config.name.empty()) @@ -187,14 +216,20 @@ static void fill_defaults(wivrn_vk_bundle & bundle, const std::vector