[vlc-commits] direct3d11: catch texture mapping errors

Steve Lhomme git at videolan.org
Tue Mar 24 16:07:43 CET 2015


vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Tue Mar 24 13:00:54 2015 +0100| [4fa71c81f329da005e10d01abb55c4ac073341fd] | committer: Jean-Baptiste Kempf

direct3d11: catch texture mapping errors

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

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

 modules/video_output/msw/direct3d11.c |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/modules/video_output/msw/direct3d11.c b/modules/video_output/msw/direct3d11.c
index f98858b..d8c62c1 100644
--- a/modules/video_output/msw/direct3d11.c
+++ b/modules/video_output/msw/direct3d11.c
@@ -85,6 +85,7 @@ struct picture_sys_t
 {
     ID3D11Texture2D     *texture;
     ID3D11DeviceContext *context;
+    vout_display_t      *vd;
 };
 
 static int  Open(vlc_object_t *);
@@ -877,6 +878,7 @@ static int Direct3D11CreateResources(vout_display_t *vd, video_format_t *fmt)
 
     picsys->texture  = sys->d3dtexture;
     picsys->context  = sys->d3dcontext;
+    picsys->vd       = vd;
 
     picture_resource_t resource = { .p_sys = picsys };
     for (int i = 0; i < PICTURE_PLANE_MAX; i++)
@@ -925,8 +927,15 @@ static void Direct3D11DestroyResources(vout_display_t *vd)
 static int Direct3D11MapTexture(picture_t *picture)
 {
     D3D11_MAPPED_SUBRESOURCE mappedResource;
-    ID3D11DeviceContext_Map(picture->p_sys->context, (ID3D11Resource *)picture->p_sys->texture, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
-    CommonUpdatePicture(picture, NULL, mappedResource.pData, mappedResource.RowPitch);
+    HRESULT hr;
+    int res;
+    hr = ID3D11DeviceContext_Map(picture->p_sys->context, (ID3D11Resource *)picture->p_sys->texture, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
+    if( FAILED(hr) )
+    {
+        msg_Dbg( picture->p_sys->vd, "failed to map the texture (hr=0x%lX)", hr );
+        return VLC_EGENERIC;
+    }
+    res = CommonUpdatePicture(picture, NULL, mappedResource.pData, mappedResource.RowPitch);
     ID3D11DeviceContext_Unmap(picture->p_sys->context,(ID3D11Resource *)picture->p_sys->texture, 0);
-    return VLC_SUCCESS;
+    return res;
 }



More information about the vlc-commits mailing list