[vlc-devel] [PATCH 16/19] d3d11_surface: avoid a cast between ID3D11Texture2D* and ID3D11Resource*

Steve Lhomme robux4 at videolabs.io
Thu Feb 2 14:54:16 CET 2017


---
 modules/video_chroma/d3d11_surface.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/modules/video_chroma/d3d11_surface.c b/modules/video_chroma/d3d11_surface.c
index 655c697..65227a3 100644
--- a/modules/video_chroma/d3d11_surface.c
+++ b/modules/video_chroma/d3d11_surface.c
@@ -54,7 +54,10 @@ vlc_module_end ()
 
 struct filter_sys_t {
     copy_cache_t     cache;
-    ID3D11Texture2D  *staging;
+    union {
+        ID3D11Texture2D  *staging;
+        ID3D11Resource   *staging_resource;
+    };
     vlc_mutex_t      staging_lock;
 };
 
@@ -108,12 +111,12 @@ static void D3D11_YUY2(filter_t *p_filter, picture_t *src, picture_t *dst)
     D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc;
     ID3D11VideoDecoderOutputView_GetDesc( p_sys->decoder, &viewDesc );
 
-    ID3D11DeviceContext_CopySubresourceRegion(p_sys->context, (ID3D11Resource*) sys->staging,
+    ID3D11DeviceContext_CopySubresourceRegion(p_sys->context, sys->staging_resource,
                                               0, 0, 0, 0,
                                               p_sys->resource, viewDesc.Texture2D.ArraySlice,
                                               NULL);
 
-    HRESULT hr = ID3D11DeviceContext_Map(p_sys->context, (ID3D11Resource*) sys->staging,
+    HRESULT hr = ID3D11DeviceContext_Map(p_sys->context, sys->staging_resource,
                                          0, D3D11_MAP_READ, 0, &lock);
     if (FAILED(hr)) {
         msg_Err(p_filter, "Failed to map source surface. (hr=0x%0lx)", hr);
@@ -167,7 +170,7 @@ static void D3D11_YUY2(filter_t *p_filter, picture_t *src, picture_t *dst)
     }
 
     /* */
-    ID3D11DeviceContext_Unmap(p_sys->context, (ID3D11Resource*)sys->staging, 0);
+    ID3D11DeviceContext_Unmap(p_sys->context, sys->staging_resource, 0);
     vlc_mutex_unlock(&sys->staging_lock);
 }
 
@@ -189,12 +192,12 @@ static void D3D11_NV12(filter_t *p_filter, picture_t *src, picture_t *dst)
     D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc;
     ID3D11VideoDecoderOutputView_GetDesc( p_sys->decoder, &viewDesc );
 
-    ID3D11DeviceContext_CopySubresourceRegion(p_sys->context, (ID3D11Resource*) sys->staging,
+    ID3D11DeviceContext_CopySubresourceRegion(p_sys->context, sys->staging_resource,
                                               0, 0, 0, 0,
                                               p_sys->resource, viewDesc.Texture2D.ArraySlice,
                                               NULL);
 
-    HRESULT hr = ID3D11DeviceContext_Map(p_sys->context, (ID3D11Resource*) sys->staging,
+    HRESULT hr = ID3D11DeviceContext_Map(p_sys->context, sys->staging_resource,
                                          0, D3D11_MAP_READ, 0, &lock);
     if (FAILED(hr)) {
         msg_Err(p_filter, "Failed to map source surface. (hr=0x%0lx)", hr);
@@ -219,7 +222,7 @@ static void D3D11_NV12(filter_t *p_filter, picture_t *src, picture_t *dst)
     }
 
     /* */
-    ID3D11DeviceContext_Unmap(p_sys->context, (ID3D11Resource*)sys->staging, 0);
+    ID3D11DeviceContext_Unmap(p_sys->context, sys->staging_resource, 0);
     vlc_mutex_unlock(&sys->staging_lock);
 }
 
-- 
2.10.2



More information about the vlc-devel mailing list