From 7404e5fce2726a56901aaf021291db6b600ba533 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 3 Aug 2023 19:41:35 -0500 Subject: [PATCH] Prefer D3D11VA for FSE V-Sync off --- app/streaming/video/ffmpeg-renderers/d3d11va.cpp | 9 +++++++++ app/streaming/video/ffmpeg-renderers/dxva2.cpp | 14 +++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/streaming/video/ffmpeg-renderers/d3d11va.cpp b/app/streaming/video/ffmpeg-renderers/d3d11va.cpp index 45121990..679287f3 100644 --- a/app/streaming/video/ffmpeg-renderers/d3d11va.cpp +++ b/app/streaming/video/ffmpeg-renderers/d3d11va.cpp @@ -367,6 +367,15 @@ bool D3D11VARenderer::initialize(PDECODER_PARAMETERS params) hr); // Non-fatal } + + // DXVA2 may let us take over for FSE V-sync off cases. However, if we don't have DXGI_FEATURE_PRESENT_ALLOW_TEARING + // then we should not attempt to do this unless there's no other option (HDR, DXVA2 failed in pass 1, etc). + if (!m_AllowTearing && m_DecoderSelectionPass == 0 && !(params->videoFormat & VIDEO_FORMAT_MASK_10BIT) && + (SDL_GetWindowFlags(params->window) & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN) { + SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION, + "Defaulting to DXVA2 for FSE without DXGI_FEATURE_PRESENT_ALLOW_TEARING support"); + return false; + } } SDL_SysWMinfo info; diff --git a/app/streaming/video/ffmpeg-renderers/dxva2.cpp b/app/streaming/video/ffmpeg-renderers/dxva2.cpp index 4d827fee..a016fea0 100644 --- a/app/streaming/video/ffmpeg-renderers/dxva2.cpp +++ b/app/streaming/video/ffmpeg-renderers/dxva2.cpp @@ -568,9 +568,11 @@ bool DXVA2Renderer::initializeDevice(SDL_Window* window, bool enableVsync) return false; } - // If we have a WDDM 2.0 or later display driver and we're not running in - // full-screen exclusive mode (or we're on a multi-GPU system in FSE), - // prefer the D3D11VA renderer. + // If we have a WDDM 2.0 or later display driver, prefer the D3D11VA renderer + // in all of the following cases: + // - Multi-GPU systems + // - Windowed and borderless windowed modes + // - Full-screen exclusive with V-sync off // // D3D11VA is better in this case because it can enable tearing in non-FSE // modes when the user has V-Sync disabled. In non-FSE V-Sync cases, D3D11VA @@ -601,6 +603,12 @@ bool DXVA2Renderer::initializeDevice(SDL_Window* window, bool enableVsync) d3d9ex->Release(); return false; } + else if (!enableVsync) { + SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, + "Defaulting to D3D11VA for FSE V-Sync Off mode"); + d3d9ex->Release(); + return false; + } } D3DCAPS9 deviceCaps;