[vlc-devel] [PATCH] D3D9: use flipex when overlay is detected

Jean-Baptiste Kempf jb at videolan.org
Sat Apr 16 17:19:52 CEST 2016


---
 modules/video_output/msw/common.h    |  1 +
 modules/video_output/msw/direct3d9.c | 21 ++++++++++++++++++---
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/modules/video_output/msw/common.h b/modules/video_output/msw/common.h
index 09408a8..2e123ce 100644
--- a/modules/video_output/msw/common.h
+++ b/modules/video_output/msw/common.h
@@ -214,6 +214,7 @@ struct vout_display_sys_t
     LPDIRECT3DDEVICE9       d3ddev;
     D3DPRESENT_PARAMETERS   d3dpp;
     bool                    use_d3d9ex;
+    bool                    has_overlay;
 
     // scene objects
     LPDIRECT3DTEXTURE9      d3dtex;
diff --git a/modules/video_output/msw/direct3d9.c b/modules/video_output/msw/direct3d9.c
index f9e68a8..2c55a3e 100644
--- a/modules/video_output/msw/direct3d9.c
+++ b/modules/video_output/msw/direct3d9.c
@@ -48,6 +48,15 @@
 #include <windows.h>
 #include <d3d9.h>
 
+
+#ifndef D3DPRESENT_FORCEIMMEDIATE
+# define D3DPRESENT_FORCEIMMEDIATE 0x00000100L
+#endif
+#ifndef D3DCAPS_OVERLAY
+# define D3DCAPS_OVERLAY 0x00000800L
+#endif
+
+
 #include "common.h"
 #include "builtin_shaders.h"
 
@@ -648,6 +657,12 @@ static int Direct3D9Create(vout_display_t *vd)
         return VLC_EGENERIC;
     }
 
+    /* In theory, we should try with IDirect3D9ExOverlayExtension */
+    if (sys->d3dcaps.Caps & D3DCAPS_OVERLAY) {
+        sys->has_overlay = true;
+        msg_Dbg(vd, "Device supports hardware overlay. Win7+" );
+    }
+
     return VLC_SUCCESS;
 }
 
@@ -701,11 +716,11 @@ static int Direct3D9FillPresentationParameters(vout_display_t *vd)
                                           d3ddm.Width);
     d3dpp->BackBufferHeight       = __MAX((unsigned int)GetSystemMetrics(SM_CYVIRTUALSCREEN),
                                           d3ddm.Height);
-    d3dpp->SwapEffect             = D3DSWAPEFFECT_COPY;
+    d3dpp->SwapEffect             = vd->sys->has_overlay ? D3DSWAPEFFECT_FLIPEX : D3DSWAPEFFECT_COPY;
     d3dpp->MultiSampleType        = D3DMULTISAMPLE_NONE;
-    d3dpp->PresentationInterval   = D3DPRESENT_INTERVAL_DEFAULT;
+    d3dpp->PresentationInterval   = vd->sys->has_overlay ? D3DPRESENT_FORCEIMMEDIATE : D3DPRESENT_INTERVAL_DEFAULT;
     d3dpp->BackBufferFormat       = d3ddm.Format;
-    d3dpp->BackBufferCount        = 1;
+    d3dpp->BackBufferCount        = vd->sys->has_overlay ? 2: 1;
     d3dpp->EnableAutoDepthStencil = FALSE;
 
     /* */
-- 
2.8.0.rc3



More information about the vlc-devel mailing list