[vlc-commits] direct3d11: implement the pixel format fallback

Steve Lhomme git at videolan.org
Mon Mar 23 18:11:58 CET 2015


vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Mon Mar 23 15:15:47 2015 +0100| [1d8905ecdb2adb1987caa5a131677d929d471b40] | committer: Jean-Baptiste Kempf

direct3d11: implement the pixel format fallback

NV12 is not supported in Windows 7 [1] so we need to fallback to RGBA

1: https://msdn.microsoft.com/en-us/library/windows/desktop/bb173059%28v=vs.85%29.aspx#DXGI_FORMAT_NV12

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1d8905ecdb2adb1987caa5a131677d929d471b40
---

 modules/video_output/msw/direct3d11.c |   23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/modules/video_output/msw/direct3d11.c b/modules/video_output/msw/direct3d11.c
index 1adcde5..3cc10b9 100644
--- a/modules/video_output/msw/direct3d11.c
+++ b/modules/video_output/msw/direct3d11.c
@@ -192,10 +192,6 @@ static int Open(vlc_object_t *object)
     if (CommonInit(vd))
         goto error;
 
-    /* TODO : A fallback system */
-    vd->sys->d3dFormat = d3d_formats[0].format;
-    vd->sys->vlcFormat = d3d_formats[0].fourcc;
-
     video_format_t fmt;
     if (Direct3D11Open(vd, &fmt)) {
         msg_Err(vd, "Direct3D11 could not be opened");
@@ -586,6 +582,25 @@ static int Direct3D11Open(vout_display_t *vd, video_format_t *fmt)
 # endif
 #endif
 
+    for (unsigned i = 0; d3d_formats[i].name != 0; i++)
+    {
+        UINT i_formatSupport;
+        if( SUCCEEDED( ID3D11Device_CheckFormatSupport(sys->d3ddevice,
+                                                       d3d_formats[i].format,
+                                                       &i_formatSupport)) &&
+                ( i_formatSupport & D3D11_FORMAT_SUPPORT_TEXTURE2D ))
+        {
+            msg_Dbg(vd, "Using pixel format %s", d3d_formats[i].name );
+            sys->d3dFormat = d3d_formats[i].format;
+            sys->vlcFormat = d3d_formats[i].fourcc;
+            break;
+        }
+    }
+    if ( !sys->vlcFormat ) {
+       msg_Err(vd, "Could not get a suitable texture pixel format");
+       return VLC_EGENERIC;
+    }
+
     UpdateRects(vd, NULL, NULL, true);
 
     if (Direct3D11CreateResources(vd, fmt)) {



More information about the vlc-commits mailing list