[vlc-commits] d3d11_quad: move the vertex input layout in the Quad

Steve Lhomme git at videolan.org
Mon May 28 13:25:32 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at videolabs.io> | Thu Dec 21 18:35:22 2017 +0100| [5269cb157f237a2aa421761526f4d86493d97946] | committer: Steve Lhomme

d3d11_quad: move the vertex input layout in the Quad

(this is not necessary as long as we all use the same one on the same context)

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

 modules/video_output/win32/d3d11_quad.c |  6 +++++-
 modules/video_output/win32/d3d11_quad.h |  5 +++--
 modules/video_output/win32/direct3d11.c | 16 +++++++++-------
 3 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/modules/video_output/win32/d3d11_quad.c b/modules/video_output/win32/d3d11_quad.c
index 9b7e809742..34001ec637 100644
--- a/modules/video_output/win32/d3d11_quad.c
+++ b/modules/video_output/win32/d3d11_quad.c
@@ -50,7 +50,10 @@ void D3D11_RenderQuad(d3d11_device_t *d3d_dev, d3d_quad_t *quad,
     ID3D11DeviceContext_OMSetRenderTargets(d3d_dev->d3dcontext, 1, &d3drenderTargetView, NULL);
 
     /* Render the quad */
+    ID3D11DeviceContext_IASetPrimitiveTopology(d3d_dev->d3dcontext, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
+
     /* vertex shader */
+    ID3D11DeviceContext_IASetInputLayout(d3d_dev->d3dcontext, quad->pVertexLayout);
     ID3D11DeviceContext_IASetVertexBuffers(d3d_dev->d3dcontext, 0, 1, &quad->pVertexBuffer, &quad->vertexStride, &offset);
     ID3D11DeviceContext_IASetIndexBuffer(d3d_dev->d3dcontext, quad->pIndexBuffer, DXGI_FORMAT_R16_UINT, 0);
     if ( quad->pVertexShaderConstants )
@@ -616,7 +619,7 @@ void D3D11_UpdateQuadLuminanceScale(vlc_object_t *o, d3d11_device_t *d3d_dev, d3
 #undef D3D11_SetupQuad
 int D3D11_SetupQuad(vlc_object_t *o, d3d11_device_t *d3d_dev, const video_format_t *fmt, d3d_quad_t *quad,
                     const display_info_t *displayFormat, const RECT *output,
-                    ID3D11VertexShader *d3dvertexShader,
+                    ID3D11VertexShader *d3dvertexShader, ID3D11InputLayout *pVertexLayout,
                     video_projection_mode_t projection, video_orientation_t orientation)
 {
     HRESULT hr;
@@ -777,6 +780,7 @@ int D3D11_SetupQuad(vlc_object_t *o, d3d11_device_t *d3d_dev, const video_format
         goto error;
 
     quad->d3dvertexShader = d3dvertexShader;
+    quad->pVertexLayout   = pVertexLayout;
     quad->resourceCount = DxgiResourceCount(quad->formatInfo);
 
     return VLC_SUCCESS;
diff --git a/modules/video_output/win32/d3d11_quad.h b/modules/video_output/win32/d3d11_quad.h
index 788b7a1c13..6297a23042 100644
--- a/modules/video_output/win32/d3d11_quad.h
+++ b/modules/video_output/win32/d3d11_quad.h
@@ -44,6 +44,7 @@ typedef struct
     ID3D11Buffer              *pPixelShaderConstants[2];
     UINT                       PSConstantsCount;
     ID3D11PixelShader         *d3dpixelShader;
+    ID3D11InputLayout         *pVertexLayout;
     D3D11_VIEWPORT            cropViewport;
     unsigned int              i_width;
     unsigned int              i_height;
@@ -73,9 +74,9 @@ void D3D11_ReleaseQuad(d3d_quad_t *);
 
 int D3D11_SetupQuad(vlc_object_t *, d3d11_device_t *, const video_format_t *, d3d_quad_t *,
                     const display_info_t *, const RECT *,
-                    ID3D11VertexShader *, video_projection_mode_t,
+                    ID3D11VertexShader *, ID3D11InputLayout *, video_projection_mode_t,
                     video_orientation_t);
-#define D3D11_SetupQuad(a,b,c,d,e,f,g,h,i)  D3D11_SetupQuad(VLC_OBJECT(a),b,c,d,e,f,g,h,i)
+#define D3D11_SetupQuad(a,b,c,d,e,f,g,h,i,j)  D3D11_SetupQuad(VLC_OBJECT(a),b,c,d,e,f,g,h,i,j)
 
 bool D3D11_UpdateQuadPosition( vlc_object_t *, d3d11_device_t *, d3d_quad_t *,
                                const RECT *output, video_orientation_t );
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 070dcd72fc..5576e6fcfc 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -105,6 +105,7 @@ struct vout_display_sys_t
     ID3D11RenderTargetView   *d3drenderTargetView;
     ID3D11DepthStencilView   *d3ddepthStencilView;
 
+    ID3D11InputLayout         *pVertexLayout;
     ID3D11VertexShader        *flatVSShader;
     ID3D11VertexShader        *projectionVSShader;
 
@@ -332,6 +333,7 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned pool_size)
 
     if (D3D11_SetupQuad( vd, &sys->d3d_dev, &surface_fmt, &sys->picQuad, &sys->display, &sys->sys.rect_src_clipped,
                    vd->fmt.projection_mode == PROJECTION_MODE_RECTANGULAR ? sys->flatVSShader : sys->projectionVSShader,
+                   sys->pVertexLayout,
                    surface_fmt.projection_mode, vd->fmt.orientation ) != VLC_SUCCESS) {
         msg_Err(vd, "Could not Create the main quad picture.");
         return NULL;
@@ -1582,9 +1584,8 @@ static int Direct3D11CreateGenericResources(vout_display_t *vd)
     { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT,    0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0},
     };
 
-    ID3D11InputLayout* pVertexLayout = NULL;
     hr = ID3D11Device_CreateInputLayout(sys->d3d_dev.d3ddevice, layout, 2, (void *)ID3D10Blob_GetBufferPointer(pVSBlob),
-                                        ID3D10Blob_GetBufferSize(pVSBlob), &pVertexLayout);
+                                        ID3D10Blob_GetBufferSize(pVSBlob), &sys->pVertexLayout);
 
     ID3D10Blob_Release(pVSBlob);
 
@@ -1592,8 +1593,6 @@ static int Direct3D11CreateGenericResources(vout_display_t *vd)
       msg_Err(vd, "Failed to create the vertex input layout. (hr=0x%lX)", hr);
       return VLC_EGENERIC;
     }
-    ID3D11DeviceContext_IASetInputLayout(sys->d3d_dev.d3dcontext, pVertexLayout);
-    ID3D11InputLayout_Release(pVertexLayout);
 
     pVSBlob = D3D11_CompileShader(vd, &sys->hd3d, &sys->d3d_dev, globVertexShaderProjection, false);
     if (!pVSBlob)
@@ -1609,8 +1608,6 @@ static int Direct3D11CreateGenericResources(vout_display_t *vd)
     }
     ID3D10Blob_Release(pVSBlob);
 
-    ID3D11DeviceContext_IASetPrimitiveTopology(sys->d3d_dev.d3dcontext, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
-
     UpdatePicQuadPosition(vd);
 
     D3D11_SAMPLER_DESC sampDesc;
@@ -1667,6 +1664,11 @@ static void Direct3D11DestroyResources(vout_display_t *vd)
 
     ReleasePictureSys(&sys->stagingSys);
 
+    if (sys->pVertexLayout)
+    {
+        ID3D11InputLayout_Release(sys->pVertexLayout);
+        sys->pVertexLayout = NULL;
+    }
     if (sys->flatVSShader)
     {
         ID3D11VertexShader_Release(sys->flatVSShader);
@@ -1794,7 +1796,7 @@ static int Direct3D11MapSubpicture(vout_display_t *vd, int *subpicture_region_co
 
             d3dquad->formatInfo = sys->d3dregion_format;
             err = D3D11_SetupQuad( vd, &sys->d3d_dev, &r->fmt, d3dquad, &sys->display, &output,
-                             sys->flatVSShader, PROJECTION_MODE_RECTANGULAR, ORIENT_NORMAL );
+                             sys->flatVSShader, sys->pVertexLayout, PROJECTION_MODE_RECTANGULAR, ORIENT_NORMAL );
             if (err != VLC_SUCCESS) {
                 msg_Err(vd, "Failed to create %dx%d quad for OSD",
                         r->fmt.i_visible_width, r->fmt.i_visible_height);



More information about the vlc-commits mailing list