[vlc-commits] direct3d11: map the single texture only once for DXGI mapped FourCCs

Steve Lhomme git at videolan.org
Thu Aug 22 13:15:53 CEST 2019


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Thu Aug 22 12:53:06 2019 +0200| [c94b8d80c88f827abb717cb16e03878220852b50] | committer: Steve Lhomme

direct3d11: map the single texture only once for DXGI mapped FourCCs

There's only one texture create for all planes.

Fixes CPU NV12 displaying.

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

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

diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 733a249bd8..278973911b 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -629,7 +629,7 @@ static void PreparePicture(vout_display_t *vd, picture_t *picture, subpicture_t
 {
     vout_display_sys_t *sys = vd->sys;
 
-    if (sys->picQuad.textureFormat->formatTexture == DXGI_FORMAT_UNKNOWN || !is_d3d11_opaque(picture->format.i_chroma))
+    if (sys->picQuad.textureFormat->formatTexture == DXGI_FORMAT_UNKNOWN)
     {
         D3D11_MAPPED_SUBRESOURCE mappedResource;
         int i;
@@ -659,6 +659,30 @@ static void PreparePicture(vout_display_t *vd, picture_t *picture, subpicture_t
                 ID3D11DeviceContext_Unmap(sys->d3d_dev.d3dcontext, sys->stagingSys.resource[i], 0);
         }
     }
+    else if (!is_d3d11_opaque(picture->format.i_chroma))
+    {
+        D3D11_MAPPED_SUBRESOURCE mappedResource;
+        HRESULT hr;
+
+        hr = ID3D11DeviceContext_Map(sys->d3d_dev.d3dcontext, sys->stagingSys.resource[0],
+                                        0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
+        if( unlikely(FAILED(hr)) )
+            msg_Err(vd, "Failed to map the %4.4s staging picture. (hr=0x%lX)", (const char*)&picture->format.i_chroma, hr);
+        else
+        {
+            uint8_t *buf = mappedResource.pData;
+            for (int i = 0; i < picture->i_planes; i++)
+            {
+                sys->stagingPlanes[i].p_pixels = buf;
+
+                plane_CopyPixels(&sys->stagingPlanes[i], &picture->p[i]);
+
+                buf += sys->stagingPlanes[i].i_pitch * sys->stagingPlanes[i].i_lines;
+            }
+
+            ID3D11DeviceContext_Unmap(sys->d3d_dev.d3dcontext, sys->stagingSys.resource[0], 0);
+        }
+    }
     else
     {
         picture_sys_d3d11_t *p_sys = ActivePictureSys(picture);



More information about the vlc-commits mailing list