From 0223394725f2300d812564afe8377fcd7da13d58 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 17 Dec 2023 18:53:13 -0600 Subject: [PATCH] Fix manual codec options when using Vulkan for HDR For now, we can't switch between GL and Vulkan on a single window, so performing decoder probes with 8-bit formats may activate EGLRenderer which breaks Vulkan on our window. It also speeds up stream launch validation for HDR cases in general, since we don't perform unnecessary decoder probes for 8-bit profiles when the user wanted 10-bit. --- app/streaming/session.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index 46c43450..367a39bf 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -716,6 +716,15 @@ bool Session::initialize() if (m_Preferences->enableHdr) { m_StreamConfig.supportedVideoFormats |= VIDEO_FORMAT_AV1_MAIN10; } + + // We'll try to fall back to HEVC first if AV1 fails. We'd rather not fall back + // straight to H.264 if the user asked for AV1 and the host doesn't support it. + if (m_StreamConfig.supportedVideoFormats & VIDEO_FORMAT_AV1_MAIN8) { + m_StreamConfig.supportedVideoFormats |= VIDEO_FORMAT_H265; + } + if (m_StreamConfig.supportedVideoFormats & VIDEO_FORMAT_AV1_MAIN10) { + m_StreamConfig.supportedVideoFormats |= VIDEO_FORMAT_H265_MAIN10; + } break; } @@ -812,21 +821,13 @@ bool Session::validateLaunch(SDL_Window* testWindow) emitLaunchWarning(tr("Your host software or GPU doesn't support encoding AV1.")); } - // We'll try to fall back to HEVC first if AV1 fails. We'd rather not fall back - // straight to H.264 if the user asked for AV1 and the host doesn't support it. - if (m_StreamConfig.supportedVideoFormats & VIDEO_FORMAT_AV1_MAIN8) { - m_StreamConfig.supportedVideoFormats |= VIDEO_FORMAT_H265; - } - if (m_StreamConfig.supportedVideoFormats & VIDEO_FORMAT_AV1_MAIN10) { - m_StreamConfig.supportedVideoFormats |= VIDEO_FORMAT_H265_MAIN10; - } - // Moonlight-common-c will handle this case already, but we want // to set this explicitly here so we can do our hardware acceleration // check below. m_StreamConfig.supportedVideoFormats &= ~VIDEO_FORMAT_MASK_AV1; } - else if (m_Preferences->videoDecoderSelection == StreamingPreferences::VDS_AUTO && // Force hardware decoding checked below + else if (!m_Preferences->enableHdr && // HDR is checked below + m_Preferences->videoDecoderSelection == StreamingPreferences::VDS_AUTO && // Force hardware decoding checked below m_Preferences->videoCodecConfig != StreamingPreferences::VCC_AUTO && // Auto VCC is already checked in initialize() !isHardwareDecodeAvailable(testWindow, m_Preferences->videoDecoderSelection, @@ -849,7 +850,8 @@ bool Session::validateLaunch(SDL_Window* testWindow) // check below. m_StreamConfig.supportedVideoFormats &= ~VIDEO_FORMAT_MASK_H265; } - else if (m_Preferences->videoDecoderSelection == StreamingPreferences::VDS_AUTO && // Force hardware decoding checked below + else if (!m_Preferences->enableHdr && // HDR is checked below + m_Preferences->videoDecoderSelection == StreamingPreferences::VDS_AUTO && // Force hardware decoding checked below m_Preferences->videoCodecConfig != StreamingPreferences::VCC_AUTO && // Auto VCC is already checked in initialize() !isHardwareDecodeAvailable(testWindow, m_Preferences->videoDecoderSelection,