[vlc-commits] direct3d11: check the pointers before mapping the texture

2018-03-21 Thread Steve Lhomme
vlc/vlc-3.0 | branch: master | Steve Lhomme  | Wed Mar 21 
09:56:35 2018 +0100| [a1fca1187092e13631a502533d822d401b09d557] | committer: 
Hugo Beauzée-Luyssen

direct3d11: check the pointers before mapping the texture

And use the proper slice, even though it's currently always 0

Ref #20103

(cherry picked from commit 72375dd63c2fcde4409aa00ff9fedf6fc60c9852)
Signed-off-by: Hugo Beauzée-Luyssen 

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

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

diff --git a/modules/video_output/win32/direct3d11.c 
b/modules/video_output/win32/direct3d11.c
index 2e62f22b64..843b771475 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -399,7 +399,19 @@ static int Direct3D11MapPoolTexture(picture_t *picture)
 picture_sys_t *p_sys = picture->p_sys;
 D3D11_MAPPED_SUBRESOURCE mappedResource;
 HRESULT hr;
-hr = ID3D11DeviceContext_Map(p_sys->context, 
p_sys->resource[KNOWN_DXGI_INDEX], 0, D3D11_MAP_WRITE_DISCARD, 0, 
&mappedResource);
+
+ID3D11Device *dev;
+ID3D11DeviceContext_GetDevice(p_sys->context, &dev);
+ID3D11Device_Release(dev);
+
+#ifndef NDEBUG
+D3D11_TEXTURE2D_DESC dsc;
+ID3D11Texture2D_GetDesc(p_sys->texture[KNOWN_DXGI_INDEX], &dsc);
+assert(dsc.CPUAccessFlags & D3D11_CPU_ACCESS_WRITE);
+assert(dsc.Usage & D3D11_USAGE_DYNAMIC);
+#endif
+
+hr = ID3D11DeviceContext_Map(p_sys->context, 
p_sys->resource[KNOWN_DXGI_INDEX], p_sys->slice_index, D3D11_MAP_WRITE_DISCARD, 
0, &mappedResource);
 if( FAILED(hr) )
 {
 return VLC_EGENERIC;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] direct3d11: check the pointers before mapping the texture

2018-03-21 Thread Steve Lhomme
vlc | branch: master | Steve Lhomme  | Wed Mar 21 09:56:35 
2018 +0100| [72375dd63c2fcde4409aa00ff9fedf6fc60c9852] | committer: Steve Lhomme

direct3d11: check the pointers before mapping the texture

And use the proper slice, even though it's currently always 0

Ref #20103

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

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

diff --git a/modules/video_output/win32/direct3d11.c 
b/modules/video_output/win32/direct3d11.c
index 55d918a4b7..919bd2e6b2 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -399,7 +399,19 @@ static int Direct3D11MapPoolTexture(picture_t *picture)
 picture_sys_t *p_sys = picture->p_sys;
 D3D11_MAPPED_SUBRESOURCE mappedResource;
 HRESULT hr;
-hr = ID3D11DeviceContext_Map(p_sys->context, 
p_sys->resource[KNOWN_DXGI_INDEX], 0, D3D11_MAP_WRITE_DISCARD, 0, 
&mappedResource);
+
+ID3D11Device *dev;
+ID3D11DeviceContext_GetDevice(p_sys->context, &dev);
+ID3D11Device_Release(dev);
+
+#ifndef NDEBUG
+D3D11_TEXTURE2D_DESC dsc;
+ID3D11Texture2D_GetDesc(p_sys->texture[KNOWN_DXGI_INDEX], &dsc);
+assert(dsc.CPUAccessFlags & D3D11_CPU_ACCESS_WRITE);
+assert(dsc.Usage & D3D11_USAGE_DYNAMIC);
+#endif
+
+hr = ID3D11DeviceContext_Map(p_sys->context, 
p_sys->resource[KNOWN_DXGI_INDEX], p_sys->slice_index, D3D11_MAP_WRITE_DISCARD, 
0, &mappedResource);
 if( FAILED(hr) )
 {
 return VLC_EGENERIC;

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits