Commit 4fa71c81 authored by Steve Lhomme's avatar Steve Lhomme Committed by Jean-Baptiste Kempf

direct3d11: catch texture mapping errors

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 1dcc337d
......@@ -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;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment