[vlc-commits] direct3d11: use DXGI_SWAP_EFFECT_FLIP_DISCARD on Windows 10

Steve Lhomme git at videolan.org
Wed Oct 17 12:02:27 CEST 2018


vlc/vlc-3.0 | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon Oct 15 12:54:29 2018 +0200| [736c0e86d05212c37db1992690ca982dff3b920c] | committer: Steve Lhomme

direct3d11: use DXGI_SWAP_EFFECT_FLIP_DISCARD on Windows 10

See https://docs.microsoft.com/en-us/windows/desktop/direct3ddxgi/for-best-performance--use-dxgi-flip-model

(cherry picked from commit d4f178086f313c759dca1b471666216226bba3d6)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=736c0e86d05212c37db1992690ca982dff3b920c
---

 modules/video_output/win32/direct3d11.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 186c76476b..339dfef07c 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -751,7 +751,18 @@ static void FillSwapChainDesc(vout_display_t *vd, DXGI_SWAP_CHAIN_DESC1 *out)
         break;
     }
     //out->Flags = 512; // DXGI_SWAP_CHAIN_FLAG_YUV_VIDEO;
-    out->SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
+
+    bool isWin10OrGreater = false;
+    HMODULE hKernelBase = GetModuleHandle(TEXT("kernelbase.dll"));
+    if (likely(hKernelBase != NULL))
+    {
+        isWin10OrGreater = GetProcAddress(hKernelBase, "VirtualAllocFromApp") != NULL;
+        FreeLibrary(hKernelBase);
+    }
+    if (isWin10OrGreater)
+        out->SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
+    else
+        out->SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
 }
 #endif
 



More information about the vlc-commits mailing list