[vlc-devel] [PATCH] direct3d11: catch texture mapping errors

Steve Lhomme robUx4 at videolabs.io
Tue Mar 24 13:00:54 CET 2015


---
 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 f6fb16f..ef912dc 100644
--- a/modules/video_output/msw/direct3d11.c
+++ b/modules/video_output/msw/direct3d11.c
@@ -101,6 +101,7 @@ struct picture_sys_t
 {
     ID3D11Texture2D     *texture;
     ID3D11DeviceContext *context;
+    vout_display_t      *vd;
 };
 
 static int  Open(vlc_object_t *);
@@ -910,6 +911,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++)
@@ -958,8 +960,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;
 }
-- 
2.3.2




More information about the vlc-devel mailing list