[vlc-commits] direct3d11: the number of pixel shaders depends on the number of render targets

Steve Lhomme git at videolan.org
Wed Feb 10 11:06:47 UTC 2021


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Feb 10 10:31:58 2021 +0100| [549d93fe790bcfbdd69858d132c3246dc2d7c644] | committer: Steve Lhomme

direct3d11: the number of pixel shaders depends on the number of render targets

At most we have 2 rendering targets (when rendering to NV12/P010).

The cropping is also tied to the number of rendering targets.

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

 modules/video_output/win32/d3d11_quad.c    | 8 +++-----
 modules/video_output/win32/d3d11_shaders.h | 4 ++--
 modules/video_output/win32/direct3d11.c    | 2 +-
 3 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/modules/video_output/win32/d3d11_quad.c b/modules/video_output/win32/d3d11_quad.c
index ac4d880285..4f0423d844 100644
--- a/modules/video_output/win32/d3d11_quad.c
+++ b/modules/video_output/win32/d3d11_quad.c
@@ -67,7 +67,7 @@ void D3D11_RenderQuad(d3d11_device_t *d3d_dev, d3d11_quad_t *quad, d3d11_vertex_
     ID3D11DeviceContext_PSSetConstantBuffers(d3d_dev->d3dcontext, 0, ARRAY_SIZE(quad->pPixelShaderConstants), quad->pPixelShaderConstants);
     assert(quad->resourceCount <= DXGI_MAX_SHADER_VIEW);
 
-    for (size_t i=0; i<DXGI_MAX_SHADER_VIEW; i++)
+    for (size_t i=0; i<ARRAY_SIZE(quad->d3dpixelShader); i++)
     {
         if (!quad->d3dpixelShader[i])
             break;
@@ -1144,7 +1144,7 @@ int D3D11_SetupQuad(vlc_object_t *o, d3d11_device_t *d3d_dev, const video_format
 
     ShaderUpdateConstants(o, d3d_dev, quad, PS_CONST_COLORSPACE, &colorspace);
 
-    for (size_t i=0; i<DXGI_MAX_SHADER_VIEW; i++)
+    for (size_t i=0; i<ARRAY_SIZE(quad->cropViewport); i++)
     {
         quad->cropViewport[i].MinDepth = 0.0f;
         quad->cropViewport[i].MaxDepth = 1.0f;
@@ -1201,8 +1201,7 @@ void D3D11_UpdateViewport(d3d11_quad_t *quad, const RECT *rect, const d3d_format
             if ( display->formatTexture != DXGI_FORMAT_NV12 &&
                  display->formatTexture != DXGI_FORMAT_P010 )
             {
-                quad->cropViewport[1] = quad->cropViewport[2] =
-                quad->cropViewport[3] = quad->cropViewport[0];
+                quad->cropViewport[1] = quad->cropViewport[0];
                 break;
             }
             /* fallthrough */
@@ -1212,7 +1211,6 @@ void D3D11_UpdateViewport(d3d11_quad_t *quad, const RECT *rect, const d3d_format
             quad->cropViewport[1].TopLeftY = quad->cropViewport[0].TopLeftY / 2;
             quad->cropViewport[1].Width    = quad->cropViewport[0].Width / 2;
             quad->cropViewport[1].Height   = quad->cropViewport[0].Height / 2;
-            quad->cropViewport[2] = quad->cropViewport[1];
             break;
         }
         break;
diff --git a/modules/video_output/win32/d3d11_shaders.h b/modules/video_output/win32/d3d11_shaders.h
index cb149c63d2..dc0f89b7f3 100644
--- a/modules/video_output/win32/d3d11_shaders.h
+++ b/modules/video_output/win32/d3d11_shaders.h
@@ -91,9 +91,9 @@ typedef struct
     ID3D11Buffer              *viewpointShaderConstant;
     ID3D11Buffer              *pPixelShaderConstants[2];
     UINT                       PSConstantsCount;
-    ID3D11PixelShader         *d3dpixelShader[DXGI_MAX_SHADER_VIEW];
+    ID3D11PixelShader         *d3dpixelShader[DXGI_MAX_RENDER_TARGET];
     ID3D11SamplerState        *SamplerStates[2];
-    D3D11_VIEWPORT            cropViewport[DXGI_MAX_SHADER_VIEW];
+    D3D11_VIEWPORT            cropViewport[DXGI_MAX_RENDER_TARGET];
     unsigned int              i_width;
     unsigned int              i_height;
     video_projection_mode_t   projection;
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 0d905cd95b..f34602cde4 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -1372,7 +1372,7 @@ static int Direct3D11MapSubpicture(vout_display_t *vd, int *subpicture_region_co
                 continue;
             }
             quad_picture = (*region)[i];
-            for (size_t j=0; j<DXGI_MAX_SHADER_VIEW; j++)
+            for (size_t j=0; j<ARRAY_SIZE(sys->regionQuad.d3dpixelShader); j++)
             {
                 /* TODO use something more accurate if we have different formats */
                 if (sys->regionQuad.d3dpixelShader[j])



More information about the vlc-commits mailing list