Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Vindicus999
2025-10-30 01:51:27 +00:00
11 changed files with 235 additions and 161 deletions
+1 -1
View File
@@ -106,6 +106,6 @@ SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
Standard: Latest
TabWidth: 8
UseTab: ForIndentation
+2 -2
View File
@@ -17,7 +17,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/clang-format-action@v4.13.0
uses: jidicula/clang-format-action@2c659fea724e981e94741c0e7db663982cd7d3f4
with:
clang-format-version: '18'
clang-format-version: '21'
check-path: ${{ matrix.path }}
+1 -2
View File
@@ -1674,8 +1674,7 @@ void application::run()
#else
void application::run()
{
struct sigaction act
{};
struct sigaction act{};
act.sa_handler = [](int) {
instance().exit_requested = true;
};
+1 -1
View File
@@ -74,7 +74,7 @@ glm::quat cubic_spline(const glm::quat & a, const glm::quat & vb, const glm::qua
td * (t3 - t2) * va);
}
template <auto components::node::*Field>
template <auto components::node::* Field>
void apply_track(entt::registry & scene, const components::animation_track_impl<Field> & track, float current_time)
{
entt::entity target = track.target;
+1 -1
View File
@@ -174,7 +174,7 @@ struct animation_track_base
interpolation_t interpolation;
};
template <auto node::*Field>
template <auto node::* Field>
struct animation_track_impl : animation_track_base
{
static const constexpr auto field = Field;
+1 -1
View File
@@ -262,7 +262,7 @@ private:
struct subplot
{
std::string title;
float scenes::stream::global_metric::*data;
float scenes::stream::global_metric::* data;
};
std::vector<subplot> subplots;
const char * unit;
+12 -12
View File
@@ -223,7 +223,7 @@ void scenes::stream::gui_performance_metrics()
for (const auto & [subtitle, data]: subplots)
{
getter_data gdata{
.data = (uintptr_t) & (global_metrics.data()->*data),
.data = (uintptr_t)&(global_metrics.data()->*data),
.stride = sizeof(global_metric),
.multiplier = multiplier,
};
@@ -260,57 +260,57 @@ void scenes::stream::gui_performance_metrics()
ImPlot::SetupAxesLimits(0, metrics.size() - 1, min_v * 1e3f, axis_scale[n] * 1e3f, ImGuiCond_Always);
getter_data getter_encode_begin{
.data = (uintptr_t) & (metrics.data()->encode_begin),
.data = (uintptr_t)&(metrics.data()->encode_begin),
.stride = sizeof(decoder_metric),
.multiplier = 1e3f};
getter_data getter_encode_end{
.data = (uintptr_t) & (metrics.data()->encode_end),
.data = (uintptr_t)&(metrics.data()->encode_end),
.stride = sizeof(decoder_metric),
.multiplier = 1e3f};
getter_data getter_send_begin{
.data = (uintptr_t) & (metrics.data()->send_begin),
.data = (uintptr_t)&(metrics.data()->send_begin),
.stride = sizeof(decoder_metric),
.multiplier = 1e3f};
getter_data getter_send_end{
.data = (uintptr_t) & (metrics.data()->send_end),
.data = (uintptr_t)&(metrics.data()->send_end),
.stride = sizeof(decoder_metric),
.multiplier = 1e3f};
getter_data getter_received_first_packet{
.data = (uintptr_t) & (metrics.data()->received_first_packet),
.data = (uintptr_t)&(metrics.data()->received_first_packet),
.stride = sizeof(decoder_metric),
.multiplier = 1e3f};
getter_data getter_received_last_packet{
.data = (uintptr_t) & (metrics.data()->received_last_packet),
.data = (uintptr_t)&(metrics.data()->received_last_packet),
.stride = sizeof(decoder_metric),
.multiplier = 1e3f};
getter_data getter_sent_to_decoder{
.data = (uintptr_t) & (metrics.data()->sent_to_decoder),
.data = (uintptr_t)&(metrics.data()->sent_to_decoder),
.stride = sizeof(decoder_metric),
.multiplier = 1e3f};
getter_data getter_received_from_decoder{
.data = (uintptr_t) & (metrics.data()->received_from_decoder),
.data = (uintptr_t)&(metrics.data()->received_from_decoder),
.stride = sizeof(decoder_metric),
.multiplier = 1e3f};
getter_data getter_blitted{
.data = (uintptr_t) & (metrics.data()->blitted),
.data = (uintptr_t)&(metrics.data()->blitted),
.stride = sizeof(decoder_metric),
.multiplier = 1e3f};
getter_data getter_displayed{
.data = (uintptr_t) & (metrics.data()->displayed),
.data = (uintptr_t)&(metrics.data()->displayed),
.stride = sizeof(decoder_metric),
.multiplier = 1e3f};
getter_data getter_predicted{
.data = (uintptr_t) & (metrics.data()->predicted_display),
.data = (uintptr_t)&(metrics.data()->predicted_display),
.stride = sizeof(decoder_metric),
.multiplier = 1e3f};
+60 -44
View File
@@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WiVRn-dashboard\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-10-20 20:55+0200\n"
"PO-Revision-Date: 2025-10-21 01:28+0200\n"
"POT-Creation-Date: 2025-10-26 13:46+0100\n"
"PO-Revision-Date: 2025-10-29 00:22+0100\n"
"Last-Translator: Álvaro De Quinta <blackcherry@danwin1210.de>\n"
"Language-Team: Spanish\n"
"Language: es\n"
@@ -19,47 +19,52 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Gtranslator 49.0\n"
#: dashboard/apk_installer.cpp:165
#: dashboard/apk_installer.cpp:137
#, kde-format
msgid "Cannot save APK file: %1"
msgstr "No se ha podido guardar el APK: %1"
#: dashboard/apk_installer.cpp:171
#, kde-format
msgid "Downloading APK: %1 MB / %2 MB"
msgstr "Descargando APK: %1 MB / %2 MB"
#: dashboard/apk_installer.cpp:167
#: dashboard/apk_installer.cpp:173
#, kde-format
msgid "Downloading APK: %1 MB"
msgstr "Descargando APK: %1 MB"
#: dashboard/apk_installer.cpp:176
#: dashboard/apk_installer.cpp:182
#, kde-format
msgid "Download cancelled"
msgstr "Descarga cancelada"
#: dashboard/apk_installer.cpp:192
#: dashboard/apk_installer.cpp:198
#, kde-format
msgid "Cannot download APK: %1"
msgstr "No se puede descargar el APK: %1"
#: dashboard/apk_installer.cpp:215
#: dashboard/apk_installer.cpp:221
#, kde-format
msgid "Installing APK"
msgstr "Instalando APK"
#: dashboard/apk_installer.cpp:219
#: dashboard/apk_installer.cpp:225
#, kde-format
msgid "adb failed to start: %1"
msgstr "Error al iniciar adb: %1"
#: dashboard/apk_installer.cpp:229
#: dashboard/apk_installer.cpp:235
#, kde-format
msgid "adb exited abnormally: %1"
msgstr "adb salió anormalmente: %1"
#: dashboard/apk_installer.cpp:237
#: dashboard/apk_installer.cpp:243
#, kde-format
msgid "The 'adb install' command failed: exit code %1"
msgstr "El comando 'adb install' falló: código de salida %1"
#: dashboard/apk_installer.cpp:242
#: dashboard/apk_installer.cpp:248
#, kde-format
msgid "Installation successful"
msgstr "Instalación completada con éxito"
@@ -85,6 +90,12 @@ msgstr "Comprobando la última versión..."
msgid "No APK is available for this version"
msgstr "No hay ningún APK disponible para esta versión"
#: dashboard/qml/ApkInstallPage.qml:45 dashboard/qml/Main.qml:311
#: dashboard/qml/Main.qml:396 dashboard/qml/WizardPage.qml:211
#, kde-format
msgid "ADB is not installed"
msgstr "ADB no está instalado"
#: dashboard/qml/ApkInstallPage.qml:47
#, kde-format
msgid "Connect a headset and make sure developer mode is enabled"
@@ -129,7 +140,7 @@ msgstr "Reinstalar WiVRn"
msgid "Install WiVRn"
msgstr "Instalar WiVRn"
#: dashboard/qml/HeadsetsPage.qml:12 dashboard/qml/Main.qml:375
#: dashboard/qml/HeadsetsPage.qml:12 dashboard/qml/Main.qml:401
#, kde-format
msgid "Headsets"
msgstr "Visores"
@@ -226,33 +237,44 @@ msgstr "Emparejar un nuevo visor"
msgid "Headset statistics"
msgstr "Estadísticas del visor"
#: dashboard/qml/Main.qml:129
#: dashboard/qml/Main.qml:130
#, kde-format
msgid "The server does not have CAP_SYS_NICE capabilities"
msgstr "El servidor no tiene capacidades CAP_SYS_NICE"
msgid "Avahi daemon is not installed"
msgstr "El servicio Avahi no está instalado"
#: dashboard/qml/Main.qml:136 dashboard/qml/Main.qml:150
#: dashboard/qml/Main.qml:138
#, kde-format
msgid "Avahi daemon is not started"
msgstr "El servicio Avahi no está iniciado"
#: dashboard/qml/Main.qml:145 dashboard/qml/Main.qml:160
#: dashboard/qml/Main.qml:174
#, kde-format
msgid "Fix it"
msgstr "Arreglarlo"
#: dashboard/qml/Main.qml:144
#: dashboard/qml/Main.qml:153
#, kde-format
msgid "The server does not have CAP_SYS_NICE capabilities"
msgstr "El servidor no tiene capacidades CAP_SYS_NICE"
#: dashboard/qml/Main.qml:168
#, kde-format
msgid "Firewall may not allow port 9757"
msgstr "El firewall podría no permitir el puerto 9757"
#: dashboard/qml/Main.qml:159
#: dashboard/qml/Main.qml:183
#, kde-format
msgid "The CAP_SYS_NICE capability will be used when the server is restarted"
msgstr "La capacidad CAP_SYS_NICE se utilizará cuando el servidor se reinicie"
#: dashboard/qml/Main.qml:165
#: dashboard/qml/Main.qml:189
#, kde-format
msgctxt "restart the server"
msgid "Restart now"
msgstr "Reiniciar ahora"
#: dashboard/qml/Main.qml:176
#: dashboard/qml/Main.qml:200
#, kde-format
msgid ""
"NVIDIA GPUs require at least driver version 565.77, current version is %1"
@@ -260,12 +282,12 @@ msgstr ""
"Las GPU NVIDIA requieren al menos la versión 565.77 del controlador, la "
"versión actual es %1"
#: dashboard/qml/Main.qml:182
#: dashboard/qml/Main.qml:206
#, kde-format
msgid "More info"
msgstr "Más información"
#: dashboard/qml/Main.qml:190
#: dashboard/qml/Main.qml:214
#, kde-format
msgid ""
"Use the Mesa (radv) driver for AMD GPUs\n"
@@ -274,7 +296,7 @@ msgstr ""
"Usa el controlador Mesa (radv) para las GPU AMD\n"
"La codificación por hardware con vaapi no funciona con AMDVLK y AMDGPU-PRO"
#: dashboard/qml/Main.qml:198
#: dashboard/qml/Main.qml:222
#, kde-format
msgid ""
"No OpenVR compatibility detected, Steam games won't be able to load VR.\n"
@@ -284,76 +306,75 @@ msgstr ""
"en VR.\n"
"Instala xrizer o OpenComposite."
#: dashboard/qml/Main.qml:207
#: dashboard/qml/Main.qml:231
#, kde-format
msgid "Server failed to start"
msgstr "El servidor no pudo iniciar"
#: dashboard/qml/Main.qml:213 dashboard/qml/TroubleshootPage.qml:85
#: dashboard/qml/Main.qml:237 dashboard/qml/TroubleshootPage.qml:85
#, kde-format
msgid "Open server logs"
msgstr "Abrir registros del servidor"
#: dashboard/qml/Main.qml:242
#: dashboard/qml/Main.qml:266
#, kde-format
msgctxt "whether the server is running, displayed in front of a checkbox"
msgid "Running"
msgstr "En ejecución"
#: dashboard/qml/Main.qml:257
#: dashboard/qml/Main.qml:281
#, kde-format
msgctxt "whether pairing is enabled, displayed in front of a checkbox"
msgid "Pairing"
msgstr "Emparejando"
#: dashboard/qml/Main.qml:270
#: dashboard/qml/Main.qml:294
#, kde-format
msgid "PIN: %1"
msgstr "PIN: %1"
#: dashboard/qml/Main.qml:278 dashboard/qml/WizardPage.qml:374
#: dashboard/qml/Main.qml:302 dashboard/qml/WizardPage.qml:374
#, kde-format
msgid "Connect by USB"
msgstr "Conectar por USB"
#: dashboard/qml/Main.qml:289
#: dashboard/qml/Main.qml:313
#, kde-format
msgid "No headset is connected or your headset is not in developer mode"
msgstr ""
"No hay ningún visor conectado o tu visor no está en modo desarrollador"
msgstr "No hay ningún visor conectado o tu visor no está en modo desarrollador"
#: dashboard/qml/Main.qml:297
#: dashboard/qml/Main.qml:321
#, kde-format
msgid "Disconnect"
msgstr "Desconectar"
#: dashboard/qml/Main.qml:314
#: dashboard/qml/Main.qml:338
#, kde-format
msgctxt "automatically started application"
msgid "Application"
msgstr "Aplicación"
#: dashboard/qml/Main.qml:335
#: dashboard/qml/Main.qml:359
#, kde-format
msgid "Steam information"
msgstr "Información de Steam"
#: dashboard/qml/Main.qml:354
#: dashboard/qml/Main.qml:380
#, kde-format
msgid "Wizard"
msgstr "Asistente"
#: dashboard/qml/Main.qml:361
#: dashboard/qml/Main.qml:387
#, kde-format
msgid "Install the app"
msgstr "Instalar aplicación"
#: dashboard/qml/Main.qml:382 dashboard/qml/SettingsPage.qml:14
#: dashboard/qml/Main.qml:408 dashboard/qml/SettingsPage.qml:14
#, kde-format
msgid "Settings"
msgstr "Ajustes"
#: dashboard/qml/Main.qml:389 dashboard/qml/TroubleshootPage.qml:10
#: dashboard/qml/Main.qml:415 dashboard/qml/TroubleshootPage.qml:10
#, kde-format
msgid "Troubleshoot"
msgstr "Solucionar problemas"
@@ -850,11 +871,6 @@ msgstr "O"
msgid "Install over USB"
msgstr "Instalar por USB"
#: dashboard/qml/WizardPage.qml:211
#, kde-format
msgid "ADB is not installed"
msgstr "ADB no está instalado"
#: dashboard/qml/WizardPage.qml:219
#, kde-format
msgid ""
+33 -33
View File
@@ -5,7 +5,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WiVRn 0.15\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-10-25 10:30+0200\n"
"POT-Creation-Date: 2025-10-26 13:31+0100\n"
"PO-Revision-Date: 2025-10-25 18:59+0200\n"
"Last-Translator: Álvaro De Quinta <blackcherry@danwin1210.de>\n"
"Language-Team: Spanish\n"
@@ -68,11 +68,11 @@ msgstr "No se puede conectar a {} ({}): {}"
msgid "Waiting for connection"
msgstr "Esperando conexión"
#: client/scenes/lobby.cpp:998
#: client/scenes/lobby.cpp:1000
msgid "Passthrough"
msgstr "Exterior"
#: client/scenes/lobby.cpp:1010
#: client/scenes/lobby.cpp:1012
msgid "Default environment"
msgstr "Entorno por defecto"
@@ -96,9 +96,9 @@ msgstr "Deshabilitado"
msgid "Disconnect"
msgstr "Desconectar"
#: client/scenes/lobby_gui.cpp:132 client/scenes/lobby_gui_customize.cpp:618
#: client/scenes/lobby_gui_customize.cpp:707
#: client/scenes/lobby_gui_customize.cpp:763 client/scenes/stream_gui.cpp:889
#: client/scenes/lobby_gui.cpp:132 client/scenes/lobby_gui_customize.cpp:653
#: client/scenes/lobby_gui_customize.cpp:744
#: client/scenes/lobby_gui_customize.cpp:800 client/scenes/stream_gui.cpp:889
msgid "Close"
msgstr "Cerrar"
@@ -135,7 +135,7 @@ msgstr "Puerto"
msgid "TCP only"
msgstr "Solo TCP"
#: client/scenes/lobby_gui.cpp:317 client/scenes/lobby_gui_customize.cpp:520
#: client/scenes/lobby_gui.cpp:317 client/scenes/lobby_gui_customize.cpp:555
#: client/scenes/stream_gui.cpp:857
msgid "Cancel"
msgstr "Cancelar"
@@ -241,7 +241,7 @@ msgstr "Activar seguimiento de manos"
#: client/scenes/lobby_gui.cpp:700 client/scenes/lobby_gui.cpp:712
#: client/scenes/lobby_gui.cpp:724 client/scenes/lobby_gui.cpp:741
#: client/scenes/lobby_gui_customize.cpp:505
#: client/scenes/lobby_gui_customize.cpp:540
msgid "This feature is not supported by your headset"
msgstr "Esta función no es compatible con tu visor"
@@ -471,26 +471,28 @@ msgstr ""
msgid "Press the grip button to move the main window"
msgstr "Pulsa el botón de agarre para mover la ventana principal"
#: client/scenes/lobby_gui_customize.cpp:328
#: client/scenes/lobby_gui_customize.cpp:363
#, c++-format
msgid "Author: {}"
msgstr "Autor: {}"
#: client/scenes/lobby_gui_customize.cpp:332
#: client/scenes/lobby_gui_customize.cpp:367
#, c++-format
msgid "Size: {:.1f} MB"
msgstr "Tamaño: {:.1f} MB"
#: client/scenes/lobby_gui_customize.cpp:412
#: client/scenes/lobby_gui_customize.cpp:447
msgid "Delete this model"
msgstr "Borrar este modelo"
#: client/scenes/lobby_gui_customize.cpp:448
#: client/scenes/lobby_gui_customize.cpp:483
#: client/scenes/lobby_gui_customize.cpp:689
#, c++-format
msgid "HTTP error {} when downloading {}"
msgstr "Error HTTP {} mientras se descargaba {}"
#: client/scenes/lobby_gui_customize.cpp:456
#: client/scenes/lobby_gui_customize.cpp:491
#: client/scenes/lobby_gui_customize.cpp:697
#, c++-format
msgid ""
"Curl error when downloading {}\n"
@@ -499,43 +501,29 @@ msgstr ""
"Error de Curl mientras se descargaba {}\n"
"{}: {}"
#: client/scenes/lobby_gui_customize.cpp:517
#: client/scenes/lobby_gui_customize.cpp:552
#, c-format
msgid "Really delete %s?"
msgstr "Seguro que quiere borrar %s?"
#: client/scenes/lobby_gui_customize.cpp:521
#: client/scenes/lobby_gui_customize.cpp:556
msgid "Delete"
msgstr "Borrar"
#: client/scenes/lobby_gui_customize.cpp:602
#: client/scenes/lobby_gui_customize.cpp:637
#, c++-format
msgid "Cannot load environment: {}"
msgstr "No se puede cargar el entorno: {}"
#: client/scenes/lobby_gui_customize.cpp:610
#: client/scenes/lobby_gui_customize.cpp:645
msgid "Loading environment"
msgstr "Cargando entorno"
#: client/scenes/lobby_gui_customize.cpp:654
#, c++-format
msgid "HTTP error {} when downloading index.json"
msgstr "Error HTTP {} mientras se descargaba index.json"
#: client/scenes/lobby_gui_customize.cpp:661
#, c++-format
msgid ""
"Curl error {} when downloading index.json\n"
"{}"
msgstr ""
"Error de Curl {} mientras se descargaba index.json\n"
"{}"
#: client/scenes/lobby_gui_customize.cpp:687
#: client/scenes/lobby_gui_customize.cpp:724
msgid "Download more environments"
msgstr "Descargar más entornos"
#: client/scenes/lobby_gui_customize.cpp:695
#: client/scenes/lobby_gui_customize.cpp:732
msgid "Open local glTF model"
msgstr "Abrir modelo glTF local"
@@ -695,6 +683,18 @@ msgstr "No se puede verificar el PIN"
msgid "Pairing is disabled on server"
msgstr "El emparejamiento está deshabilitado en el servidor."
#, c++-format
#~ msgid "HTTP error {} when downloading index.json"
#~ msgstr "Error HTTP {} mientras se descargaba index.json"
#, c++-format
#~ msgid ""
#~ "Curl error {} when downloading index.json\n"
#~ "{}"
#~ msgstr ""
#~ "Error de Curl {} mientras se descargaba index.json\n"
#~ "{}"
#~ msgid "Enable video passthrough in lobby"
#~ msgstr "Activar video passthrough en el lobby"
+116 -62
View File
@@ -130,6 +130,22 @@ static void check_profile_guid_supported(std::shared_ptr<video_encoder_nvenc_sha
}
}
NV_ENC_RC_PARAMS video_encoder_nvenc::get_rc_params(uint64_t bitrate, float framerate)
{
return {
.rateControlMode = NV_ENC_PARAMS_RC_CBR,
.averageBitRate = static_cast<uint32_t>(bitrate),
.vbvBufferSize = static_cast<uint32_t>(bitrate / framerate),
.vbvInitialDelay = static_cast<uint32_t>(bitrate / framerate),
.multiPass = NV_ENC_TWO_PASS_QUARTER_RESOLUTION};
}
void video_encoder_nvenc::set_init_params_fps(float framerate)
{
init_params.frameRateNum = framerate;
init_params.frameRateDen = 1;
}
video_encoder_nvenc::video_encoder_nvenc(
wivrn_vk_bundle & vk,
encoder_settings & settings,
@@ -157,13 +173,13 @@ video_encoder_nvenc::video_encoder_nvenc(
},
};
NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS params_ex = {
NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS session_params = {
.version = NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER,
.deviceType = NV_ENC_DEVICE_TYPE_CUDA,
.device = shared_state->cuda,
.apiVersion = NVENCAPI_VERSION,
};
NVENC_CHECK_NOENCODER(shared_state->fn.nvEncOpenEncodeSessionEx(&params_ex, &session_handle));
NVENC_CHECK_NOENCODER(shared_state->fn.nvEncOpenEncodeSessionEx(&session_params, &session_handle));
auto encodeGUID = encode_guid(settings.codec);
check_encode_guid_supported(shared_state, session_handle, encodeGUID);
@@ -182,18 +198,13 @@ video_encoder_nvenc::video_encoder_nvenc(
}};
NVENC_CHECK(shared_state->fn.nvEncGetEncodePresetConfigEx(session_handle, encodeGUID, presetGUID, tuningInfo, &preset_config));
NV_ENC_CONFIG params = preset_config.presetCfg;
config = preset_config.presetCfg;
// Bitrate control
params.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CBR;
params.rcParams.averageBitRate = bitrate;
params.rcParams.maxBitRate = bitrate;
params.rcParams.vbvBufferSize = bitrate / fps;
params.rcParams.vbvInitialDelay = bitrate / fps;
params.rcParams.multiPass = NV_ENC_TWO_PASS_QUARTER_RESOLUTION;
config.rcParams = get_rc_params(bitrate, fps);
params.gopLength = NVENC_INFINITE_GOPLENGTH;
params.frameIntervalP = 1;
config.gopLength = NVENC_INFINITE_GOPLENGTH;
config.frameIntervalP = 1;
NV_ENC_BIT_DEPTH bitDepth = NV_ENC_BIT_DEPTH_8;
if (settings.bit_depth == 10)
@@ -223,48 +234,48 @@ video_encoder_nvenc::video_encoder_nvenc(
if (bitDepth != NV_ENC_BIT_DEPTH_8)
throw std::runtime_error("nvenc: selected codec only supports 8-bit encoding");
params.encodeCodecConfig.h264Config.repeatSPSPPS = 1;
params.encodeCodecConfig.h264Config.maxNumRefFrames = 0;
params.encodeCodecConfig.h264Config.idrPeriod = NVENC_INFINITE_GOPLENGTH;
params.encodeCodecConfig.h264Config.h264VUIParameters.videoFullRangeFlag = 1;
config.encodeCodecConfig.h264Config.repeatSPSPPS = 1;
config.encodeCodecConfig.h264Config.maxNumRefFrames = 0;
config.encodeCodecConfig.h264Config.idrPeriod = NVENC_INFINITE_GOPLENGTH;
config.encodeCodecConfig.h264Config.h264VUIParameters.videoFullRangeFlag = 1;
break;
case video_codec::h265:
if (bitDepth == NV_ENC_BIT_DEPTH_10)
{
params.profileGUID = NV_ENC_HEVC_PROFILE_MAIN10_GUID;
check_profile_guid_supported(shared_state, session_handle, encodeGUID, params.profileGUID, "GPU doesn't support 10-bit depth with H.265 codec.");
config.profileGUID = NV_ENC_HEVC_PROFILE_MAIN10_GUID;
check_profile_guid_supported(shared_state, session_handle, encodeGUID, config.profileGUID, "GPU doesn't support 10-bit depth with H.265 codec.");
}
params.encodeCodecConfig.hevcConfig.inputBitDepth = bitDepth;
params.encodeCodecConfig.hevcConfig.outputBitDepth = bitDepth;
config.encodeCodecConfig.hevcConfig.inputBitDepth = bitDepth;
config.encodeCodecConfig.hevcConfig.outputBitDepth = bitDepth;
params.encodeCodecConfig.hevcConfig.repeatSPSPPS = 1;
params.encodeCodecConfig.hevcConfig.maxNumRefFramesInDPB = 0;
params.encodeCodecConfig.hevcConfig.idrPeriod = NVENC_INFINITE_GOPLENGTH;
params.encodeCodecConfig.hevcConfig.hevcVUIParameters.videoFullRangeFlag = 1;
config.encodeCodecConfig.hevcConfig.repeatSPSPPS = 1;
config.encodeCodecConfig.hevcConfig.maxNumRefFramesInDPB = 0;
config.encodeCodecConfig.hevcConfig.idrPeriod = NVENC_INFINITE_GOPLENGTH;
config.encodeCodecConfig.hevcConfig.hevcVUIParameters.videoFullRangeFlag = 1;
break;
case video_codec::av1:
if (bitDepth == NV_ENC_BIT_DEPTH_10)
{
params.profileGUID = NV_ENC_AV1_PROFILE_MAIN_GUID;
check_profile_guid_supported(shared_state, session_handle, encodeGUID, params.profileGUID, "GPU doesn't support 10-bit depth with AV1 codec.");
config.profileGUID = NV_ENC_AV1_PROFILE_MAIN_GUID;
check_profile_guid_supported(shared_state, session_handle, encodeGUID, config.profileGUID, "GPU doesn't support 10-bit depth with AV1 codec.");
}
params.encodeCodecConfig.av1Config.inputBitDepth = bitDepth;
params.encodeCodecConfig.av1Config.outputBitDepth = bitDepth;
config.encodeCodecConfig.av1Config.inputBitDepth = bitDepth;
config.encodeCodecConfig.av1Config.outputBitDepth = bitDepth;
params.encodeCodecConfig.av1Config.repeatSeqHdr = 1;
params.encodeCodecConfig.av1Config.maxNumRefFramesInDPB = 0;
params.encodeCodecConfig.av1Config.idrPeriod = NVENC_INFINITE_GOPLENGTH;
config.encodeCodecConfig.av1Config.repeatSeqHdr = 1;
config.encodeCodecConfig.av1Config.maxNumRefFramesInDPB = 0;
config.encodeCodecConfig.av1Config.idrPeriod = NVENC_INFINITE_GOPLENGTH;
break;
case video_codec::raw:
throw std::runtime_error("raw codec not supported for nvenc");
}
NV_ENC_INITIALIZE_PARAMS params2{
init_params = {
.version = NV_ENC_INITIALIZE_PARAMS_VER,
.encodeGUID = encodeGUID,
.presetGUID = presetGUID,
@@ -272,19 +283,20 @@ video_encoder_nvenc::video_encoder_nvenc(
.encodeHeight = settings.video_height,
.darWidth = settings.video_width,
.darHeight = settings.video_height,
.frameRateNum = (uint32_t)fps,
.frameRateDen = 1,
.enableEncodeAsync = 0,
.enablePTD = 1,
.encodeConfig = &params,
.encodeConfig = &config,
.tuningInfo = tuningInfo};
NVENC_CHECK(shared_state->fn.nvEncInitializeEncoder(session_handle, &params2));
NV_ENC_CREATE_BITSTREAM_BUFFER params3{
set_init_params_fps(fps);
NVENC_CHECK(shared_state->fn.nvEncInitializeEncoder(session_handle, &init_params));
NV_ENC_CREATE_BITSTREAM_BUFFER out_buf_params{
.version = NV_ENC_CREATE_BITSTREAM_BUFFER_VER,
};
NVENC_CHECK(shared_state->fn.nvEncCreateBitstreamBuffer(session_handle, &params3));
bitstreamBuffer = params3.bitstreamBuffer;
NVENC_CHECK(shared_state->fn.nvEncCreateBitstreamBuffer(session_handle, &out_buf_params));
outputBuffer = out_buf_params.bitstreamBuffer;
vk::DeviceSize buffer_size = rect.extent.width * settings.video_height * bytesPerPixel * 3 / 2;
@@ -329,23 +341,23 @@ video_encoder_nvenc::video_encoder_nvenc(
CU_CHECK(shared_state->cuda_fn->cuCtxPushCurrent(shared_state->cuda));
{
CUexternalMemory extmem;
CUDA_EXTERNAL_MEMORY_HANDLE_DESC param{
CUDA_EXTERNAL_MEMORY_HANDLE_DESC mem_handle_params{
.type = CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD,
.handle = {.fd = fd},
.size = memory_req.size,
.flags = 0,
};
CU_CHECK(shared_state->cuda_fn->cuImportExternalMemory(&extmem, &param));
CU_CHECK(shared_state->cuda_fn->cuImportExternalMemory(&extmem, &mem_handle_params));
CUDA_EXTERNAL_MEMORY_BUFFER_DESC map_param{
CUDA_EXTERNAL_MEMORY_BUFFER_DESC ext_map_params{
.offset = 0,
.size = buffer_size,
.flags = 0,
};
CU_CHECK(shared_state->cuda_fn->cuExternalMemoryGetMappedBuffer(&frame, extmem, &map_param));
CU_CHECK(shared_state->cuda_fn->cuExternalMemoryGetMappedBuffer(&frame, extmem, &ext_map_params));
}
NV_ENC_REGISTER_RESOURCE param3{
NV_ENC_REGISTER_RESOURCE resource_params{
.version = NV_ENC_REGISTER_RESOURCE_VER,
.resourceType = NV_ENC_INPUT_RESOURCE_TYPE_CUDADEVICEPTR,
.width = settings.video_width,
@@ -355,8 +367,8 @@ video_encoder_nvenc::video_encoder_nvenc(
.bufferFormat = (bitDepth == NV_ENC_BIT_DEPTH_10 ? NV_ENC_BUFFER_FORMAT_YUV420_10BIT : NV_ENC_BUFFER_FORMAT_NV12),
.bufferUsage = NV_ENC_INPUT_IMAGE,
};
NVENC_CHECK(shared_state->fn.nvEncRegisterResource(session_handle, &param3));
i.nvenc_resource = param3.registeredResource;
NVENC_CHECK(shared_state->fn.nvEncRegisterResource(session_handle, &resource_params));
i.nvenc_resource = resource_params.registeredResource;
}
CU_CHECK(shared_state->cuda_fn->cuCtxPopCurrent(NULL));
}
@@ -412,12 +424,54 @@ std::optional<video_encoder::data> video_encoder_nvenc::encode(bool idr, std::ch
{
CU_CHECK(shared_state->cuda_fn->cuCtxPushCurrent(shared_state->cuda));
NV_ENC_MAP_INPUT_RESOURCE param4{};
param4.version = NV_ENC_MAP_INPUT_RESOURCE_VER;
param4.registeredResource = in[slot].nvenc_resource;
NVENC_CHECK(shared_state->fn.nvEncMapInputResource(session_handle, &param4));
auto new_bitrate = pending_bitrate.exchange(0);
auto new_framerate = pending_framerate.exchange(0);
NV_ENC_PIC_PARAMS param{
if (new_bitrate || new_framerate)
{
if (new_framerate)
U_LOG_I("nvenc: reconfiguring framerate, new value: %f", new_framerate);
else
new_framerate = fps;
if (new_bitrate)
U_LOG_I("nvenc: reconfiguring bitrate, new value: %d", new_bitrate);
else
new_bitrate = bitrate;
config.rcParams = get_rc_params(new_bitrate, new_framerate);
set_init_params_fps(new_framerate);
NV_ENC_RECONFIGURE_PARAMS reconfig_params{
.version = NV_ENC_RECONFIGURE_PARAMS_VER,
.reInitEncodeParams = init_params,
.resetEncoder = 1,
.forceIDR = 1};
try
{
NVENC_CHECK(shared_state->fn.nvEncReconfigureEncoder(session_handle, &reconfig_params));
fps = new_framerate;
bitrate = new_bitrate;
idr = true;
U_LOG_I("nvenc: reconfiguring succeeded.");
}
catch (const std::exception & e)
{
U_LOG_E("nvenc: reconfiguring failed.");
config.rcParams = get_rc_params(bitrate, fps);
set_init_params_fps(fps);
}
}
NV_ENC_MAP_INPUT_RESOURCE inp_resource_params{
.version = NV_ENC_MAP_INPUT_RESOURCE_VER,
.registeredResource = in[slot].nvenc_resource};
NVENC_CHECK(shared_state->fn.nvEncMapInputResource(session_handle, &inp_resource_params));
NV_ENC_PIC_PARAMS frame_params{
.version = NV_ENC_PIC_PARAMS_VER,
.inputWidth = rect.extent.width,
.inputHeight = rect.extent.height,
@@ -425,26 +479,26 @@ std::optional<video_encoder::data> video_encoder_nvenc::encode(bool idr, std::ch
.encodePicFlags = uint32_t(idr ? NV_ENC_PIC_FLAG_FORCEIDR | NV_ENC_PIC_FLAG_OUTPUT_SPSPPS : 0),
.frameIdx = 0,
.inputTimeStamp = 0,
.inputBuffer = param4.mappedResource,
.outputBitstream = bitstreamBuffer,
.bufferFmt = param4.mappedBufferFmt,
.inputBuffer = inp_resource_params.mappedResource,
.outputBitstream = outputBuffer,
.bufferFmt = inp_resource_params.mappedBufferFmt,
.pictureStruct = NV_ENC_PIC_STRUCT_FRAME,
};
NVENC_CHECK(shared_state->fn.nvEncEncodePicture(session_handle, &param));
NVENC_CHECK(shared_state->fn.nvEncEncodePicture(session_handle, &frame_params));
NV_ENC_LOCK_BITSTREAM param2{
NV_ENC_LOCK_BITSTREAM buf_lock_params{
.version = NV_ENC_LOCK_BITSTREAM_VER,
.doNotWait = 0,
.outputBitstream = bitstreamBuffer,
.outputBitstream = outputBuffer,
};
NVENC_CHECK(shared_state->fn.nvEncLockBitstream(session_handle, &param2));
NVENC_CHECK(shared_state->fn.nvEncLockBitstream(session_handle, &buf_lock_params));
CU_CHECK(shared_state->cuda_fn->cuCtxPopCurrent(NULL));
return data{
.encoder = this,
.span = std::span((uint8_t *)param2.bitstreamBufferPtr, param2.bitstreamSizeInBytes),
.mem = std::shared_ptr<void>(param2.bitstreamBufferPtr, [this](void *) {
NVENCSTATUS status = shared_state->fn.nvEncUnlockBitstream(session_handle, bitstreamBuffer);
.span = std::span((uint8_t *)buf_lock_params.bitstreamBufferPtr, buf_lock_params.bitstreamSizeInBytes),
.mem = std::shared_ptr<void>(buf_lock_params.bitstreamBufferPtr, [this](void *) {
NVENCSTATUS status = shared_state->fn.nvEncUnlockBitstream(session_handle, outputBuffer);
if (status != NV_ENC_SUCCESS)
U_LOG_E("%s:%d: %d, %s", __FILE__, __LINE__, status, shared_state->fn.nvEncGetLastErrorString(session_handle));
}),
@@ -475,14 +529,14 @@ std::array<int, 2> video_encoder_nvenc::get_max_size(video_codec codec)
{NV_ENC_CAPS_WIDTH_MAX, &result[1]},
})
{
NV_ENC_CAPS_PARAM cap_param{
NV_ENC_CAPS_PARAM cap_params{
.version = NV_ENC_CAPS_PARAM_VER,
.capsToQuery = NV_ENC_CAPS_WIDTH_MAX,
};
check_encode_guid_supported(state, session_handle, encodeGUID);
NVENCSTATUS status = state->fn.nvEncGetEncodeCaps(session_handle, encodeGUID, &cap_param, res);
NVENCSTATUS status = state->fn.nvEncGetEncodeCaps(session_handle, encodeGUID, &cap_params, res);
if (status != NV_ENC_SUCCESS)
{
throw std::runtime_error("nvenc get_max_size: failed to get caps");
+7 -2
View File
@@ -40,7 +40,9 @@ private:
std::shared_ptr<video_encoder_nvenc_shared_state> shared_state;
void * session_handle = nullptr;
NV_ENC_OUTPUT_PTR bitstreamBuffer;
NV_ENC_OUTPUT_PTR outputBuffer;
NV_ENC_CONFIG config;
NV_ENC_INITIALIZE_PARAMS init_params;
struct in_t
{
@@ -51,9 +53,12 @@ private:
std::array<in_t, num_slots> in;
float fps;
int bitrate;
uint64_t bitrate;
int bytesPerPixel = 1;
NV_ENC_RC_PARAMS get_rc_params(uint64_t bitrate, float framerate);
void set_init_params_fps(float framerate);
public:
video_encoder_nvenc(wivrn_vk_bundle & vk, encoder_settings & settings, float fps, uint8_t stream_idx);
~video_encoder_nvenc();