[vlc-commits] d3d11_fmt: pass the whole texture array to AllocateShaderView()

Steve Lhomme git at videolan.org
Tue Jun 13 15:01:53 CEST 2017


vlc | branch: master | Steve Lhomme <robux4 at videolabs.io> | Thu Jun  8 14:48:51 2017 +0200| [1487330548a4f36b922059a46686b62ad04a9778] | committer: Jean-Baptiste Kempf

d3d11_fmt: pass the whole texture array to AllocateShaderView()

For CPU formats mapped to GPU each texture of the array may be different.

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

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

 modules/codec/avcodec/d3d11va.c         | 7 +++++--
 modules/video_chroma/d3d11_fmt.h        | 6 +++---
 modules/video_output/win32/direct3d11.c | 6 +++---
 3 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index 85c6969c46..9100568598 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -819,7 +819,7 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id, const video_forma
                 break;
             }
 
-            AllocateShaderView(VLC_OBJECT(va), dx_sys->d3ddev, textureFmt, pic->p_sys->texture[KNOWN_DXGI_INDEX], pic->p_sys->slice_index, pic->p_sys->resourceView);
+            AllocateShaderView(VLC_OBJECT(va), dx_sys->d3ddev, textureFmt, pic->p_sys->texture, pic->p_sys->slice_index, pic->p_sys->resourceView);
 
             dx_sys->hw_surface[surface_idx] = pic->p_sys->decoder;
         }
@@ -888,7 +888,10 @@ static int DxCreateDecoderSurfaces(vlc_va_t *va, int codec_id, const video_forma
             }
 
             if (texDesc.BindFlags & D3D11_BIND_SHADER_RESOURCE)
-                AllocateShaderView(VLC_OBJECT(va), dx_sys->d3ddev, textureFmt, p_texture, dx_sys->surface_count, &sys->resourceView[dx_sys->surface_count * D3D11_MAX_SHADER_VIEW]);
+            {
+                ID3D11Texture2D *textures[D3D11_MAX_SHADER_VIEW] = {p_texture, p_texture, p_texture};
+                AllocateShaderView(VLC_OBJECT(va), dx_sys->d3ddev, textureFmt, textures, dx_sys->surface_count, &sys->resourceView[dx_sys->surface_count * D3D11_MAX_SHADER_VIEW]);
+            }
         }
     }
     msg_Dbg(va, "ID3D11VideoDecoderOutputView succeed with %d surfaces (%dx%d)",
diff --git a/modules/video_chroma/d3d11_fmt.h b/modules/video_chroma/d3d11_fmt.h
index 6c3f6e06ba..25130f147b 100644
--- a/modules/video_chroma/d3d11_fmt.h
+++ b/modules/video_chroma/d3d11_fmt.h
@@ -107,14 +107,14 @@ static inline void ReleasePictureSys(picture_sys_t *p_sys)
 /* map texture planes to resource views */
 static inline int AllocateShaderView(vlc_object_t *obj, ID3D11Device *d3ddevice,
                               const d3d_format_t *format,
-                              ID3D11Texture2D *p_texture, UINT slice_index,
+                              ID3D11Texture2D *p_texture[D3D11_MAX_SHADER_VIEW], UINT slice_index,
                               ID3D11ShaderResourceView *resourceView[D3D11_MAX_SHADER_VIEW])
 {
     HRESULT hr;
     int i;
     D3D11_SHADER_RESOURCE_VIEW_DESC resviewDesc = { 0 };
     D3D11_TEXTURE2D_DESC texDesc;
-    ID3D11Texture2D_GetDesc(p_texture, &texDesc);
+    ID3D11Texture2D_GetDesc(p_texture[0], &texDesc);
     assert(texDesc.BindFlags & D3D11_BIND_SHADER_RESOURCE);
 
     if (texDesc.ArraySize == 1)
@@ -136,7 +136,7 @@ static inline int AllocateShaderView(vlc_object_t *obj, ID3D11Device *d3ddevice,
             resourceView[i] = NULL;
         else
         {
-            hr = ID3D11Device_CreateShaderResourceView(d3ddevice, (ID3D11Resource*)p_texture, &resviewDesc, &resourceView[i]);
+            hr = ID3D11Device_CreateShaderResourceView(d3ddevice, (ID3D11Resource*)p_texture[i], &resviewDesc, &resourceView[i]);
             if (FAILED(hr)) {
                 msg_Err(obj, "Could not Create the Texture ResourceView %d slice %d. (hr=0x%lX)", i, slice_index, hr);
                 break;
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index a324f9a79c..07894850dd 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -761,7 +761,7 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned pool_size)
             sys->stagingSys.texture[plane] = textures[plane];
 
         if (AllocateShaderView(VLC_OBJECT(vd), sys->d3ddevice, sys->picQuadConfig,
-                               textures[0], 0, sys->stagingSys.resourceView))
+                               textures, 0, sys->stagingSys.resourceView))
             goto error;
     } else
 #endif
@@ -773,7 +773,7 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned pool_size)
 
         for (picture_count = 0; picture_count < pool_size; picture_count++) {
             if (AllocateShaderView(VLC_OBJECT(vd), sys->d3ddevice, sys->picQuadConfig,
-                                   pictures[picture_count]->p_sys->texture[0], picture_count,
+                                   pictures[picture_count]->p_sys->texture, picture_count,
                                    pictures[picture_count]->p_sys->resourceView))
                 goto error;
         }
@@ -2769,7 +2769,7 @@ static int Direct3D11MapSubpicture(vout_display_t *vd, int *subpicture_region_co
                 d3dquad->picSys.texture[plane] = textures[plane];
             }
             if (AllocateShaderView(VLC_OBJECT(vd), sys->d3ddevice, sys->d3dregion_format,
-                                   d3dquad->picSys.texture[0], 0,
+                                   d3dquad->picSys.texture, 0,
                                    d3dquad->picSys.resourceView)) {
                 msg_Err(vd, "Failed to create %dx%d shader view for OSD",
                         r->fmt.i_visible_width, r->fmt.i_visible_height);



More information about the vlc-commits mailing list