vlc/vlc-3.0 | branch: master | Steve Lhomme <rob...@ycbcr.xyz> | Tue Feb 13 
13:03:59 2018 +0100| [7235af7e902bf0e4cb7ed223352883cdc2cd5c8e] | committer: 
Hugo Beauzée-Luyssen

direct3d11: only give initialized resource views to the shader

May help solving 394ea0e5-7f32-4463-86d4-5a30f65ae243

(cherry picked from commit de40ab5dfc3efd932ed3d298674353bbcf427578)
Signed-off-by: Hugo Beauzée-Luyssen <h...@beauzee.fr>

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

 modules/video_chroma/dxgi_fmt.c         | 10 ++++++++++
 modules/video_chroma/dxgi_fmt.h         |  1 +
 modules/video_output/win32/direct3d11.c |  6 +++++-
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/modules/video_chroma/dxgi_fmt.c b/modules/video_chroma/dxgi_fmt.c
index 384c6b599b..e15664245f 100644
--- a/modules/video_chroma/dxgi_fmt.c
+++ b/modules/video_chroma/dxgi_fmt.c
@@ -147,3 +147,13 @@ const char *DxgiVendorStr(int gpu_vendor)
     }
     return vendors[i].name;
 }
+
+UINT DxgiResourceCount(const d3d_format_t *d3d_fmt)
+{
+    for (UINT count=0; count<D3D11_MAX_SHADER_VIEW; count++)
+    {
+        if (d3d_fmt->resourceFormat[count] == DXGI_FORMAT_UNKNOWN)
+            return count;
+    }
+    return D3D11_MAX_SHADER_VIEW;
+}
diff --git a/modules/video_chroma/dxgi_fmt.h b/modules/video_chroma/dxgi_fmt.h
index 71282655b3..d9fb8d7ad5 100644
--- a/modules/video_chroma/dxgi_fmt.h
+++ b/modules/video_chroma/dxgi_fmt.h
@@ -54,5 +54,6 @@ vlc_fourcc_t DxgiFormatFourcc(DXGI_FORMAT format);
 const d3d_format_t *GetRenderFormatList(void);
 void DxgiFormatMask(DXGI_FORMAT format, video_format_t *);
 const char *DxgiVendorStr(int gpu_vendor);
+UINT DxgiResourceCount(const d3d_format_t *);
 
 #endif /* include-guard */
diff --git a/modules/video_output/win32/direct3d11.c 
b/modules/video_output/win32/direct3d11.c
index 3f21572f8e..ab2a31e939 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -103,6 +103,7 @@ typedef struct {
 typedef struct
 {
     picture_sys_t             picSys;
+    UINT                      resourceCount;
     ID3D11Buffer              *pVertexBuffer;
     UINT                      vertexCount;
     ID3D11VertexShader        *d3dvertexShader;
@@ -647,6 +648,7 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned 
pool_size)
         if (is_d3d11_opaque(surface_fmt.i_chroma) && !sys->legacy_shader)
 #endif
         {
+            sys->picQuad.resourceCount = DxgiResourceCount(sys->picQuadConfig);
             for (picture_count = 0; picture_count < pool_size; 
picture_count++) {
                 if (AllocateShaderView(VLC_OBJECT(vd), sys->d3d_dev.d3ddevice, 
sys->picQuadConfig,
                                        
pictures[picture_count]->p_sys->texture, picture_count,
@@ -1079,7 +1081,7 @@ static void DisplayD3DPicture(vout_display_sys_t *sys, 
d3d_quad_t *quad, ID3D11S
     ID3D11DeviceContext_PSSetShader(sys->d3d_dev.d3dcontext, 
quad->d3dpixelShader, NULL, 0);
 
     ID3D11DeviceContext_PSSetConstantBuffers(sys->d3d_dev.d3dcontext, 0, 
quad->PSConstantsCount, quad->pPixelShaderConstants);
-    ID3D11DeviceContext_PSSetShaderResources(sys->d3d_dev.d3dcontext, 0, 
D3D11_MAX_SHADER_VIEW, resourceView);
+    ID3D11DeviceContext_PSSetShaderResources(sys->d3d_dev.d3dcontext, 0, 
quad->resourceCount, resourceView);
 
     ID3D11DeviceContext_RSSetViewports(sys->d3d_dev.d3dcontext, 1, 
&quad->cropViewport);
 
@@ -2061,6 +2063,7 @@ static int Direct3D11CreateFormatResources(vout_display_t 
*vd, const video_forma
             return VLC_EGENERIC;
         }
 
+        sys->picQuad.resourceCount = DxgiResourceCount(sys->picQuadConfig);
         if (AllocateShaderView(VLC_OBJECT(vd), sys->d3d_dev.d3ddevice, 
sys->picQuadConfig,
                                textures, 0, sys->stagingSys.resourceView))
         {
@@ -2944,6 +2947,7 @@ static int Direct3D11MapSubpicture(vout_display_t *vd, 
int *subpicture_region_co
                 continue;
             }
 
+            d3dquad->resourceCount = DxgiResourceCount(sys->d3dregion_format);
             if (AllocateShaderView(VLC_OBJECT(vd), sys->d3d_dev.d3ddevice, 
sys->d3dregion_format,
                                    d3dquad->picSys.texture, 0,
                                    d3dquad->picSys.resourceView)) {

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

Reply via email to