[vlc-commits] d3d11_quad: move D3D11_RenderQuad in a separate file

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


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Mon May 28 13:05:52 2018 +0200| [14e215d88f5d587b0be97c6584c4ad473b6ed82b] | committer: Steve Lhomme

d3d11_quad: move D3D11_RenderQuad in a separate file

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

 modules/video_output/Makefile.am        |  2 +-
 modules/video_output/win32/d3d11_quad.c | 65 +++++++++++++++++++++++++++++++++
 modules/video_output/win32/d3d11_quad.h |  6 +++
 modules/video_output/win32/direct3d11.c | 27 --------------
 4 files changed, 72 insertions(+), 28 deletions(-)

diff --git a/modules/video_output/Makefile.am b/modules/video_output/Makefile.am
index cd92f12918..06502f7118 100644
--- a/modules/video_output/Makefile.am
+++ b/modules/video_output/Makefile.am
@@ -299,7 +299,7 @@ libdirect3d11_plugin_la_SOURCES += video_output/win32/events.c \
  video_output/win32/events.h \
  video_output/win32/sensors.cpp \
  video_output/win32/win32touch.c video_output/win32/win32touch.h \
- video_output/win32/d3d11_quad.h
+ video_output/win32/d3d11_quad.c video_output/win32/d3d11_quad.h
 libdirect3d11_plugin_la_LIBADD += -lgdi32
 else
 libdirect3d11_plugin_la_LIBADD += -ld3d11
diff --git a/modules/video_output/win32/d3d11_quad.c b/modules/video_output/win32/d3d11_quad.c
new file mode 100644
index 0000000000..8a0c19cbeb
--- /dev/null
+++ b/modules/video_output/win32/d3d11_quad.c
@@ -0,0 +1,65 @@
+/*****************************************************************************
+ * d3d11_quad.c: Direct3D11 Qaud handling
+ *****************************************************************************
+ * Copyright (C) 2017-2018 VLC authors and VideoLAN
+ *
+ * Authors: Steve Lhomme <robux4 at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <assert.h>
+#include <vlc_common.h>
+
+#if !defined(_WIN32_WINNT) || _WIN32_WINNT < _WIN32_WINNT_WIN7
+# undef _WIN32_WINNT
+# define _WIN32_WINNT _WIN32_WINNT_WIN7
+#endif
+
+#define COBJMACROS
+#include <d3d11.h>
+
+#include "d3d11_quad.h"
+
+void D3D11_RenderQuad(d3d11_device_t *d3d_dev, d3d_quad_t *quad, ID3D11ShaderResourceView *resourceView[D3D11_MAX_SHADER_VIEW],
+                      ID3D11RenderTargetView *d3drenderTargetView)
+{
+    UINT offset = 0;
+
+    ID3D11DeviceContext_OMSetRenderTargets(d3d_dev->d3dcontext, 1, &d3drenderTargetView, NULL);
+
+    /* Render the quad */
+    /* vertex shader */
+    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 )
+        ID3D11DeviceContext_VSSetConstantBuffers(d3d_dev->d3dcontext, 0, 1, &quad->pVertexShaderConstants);
+
+    ID3D11DeviceContext_VSSetShader(d3d_dev->d3dcontext, quad->d3dvertexShader, NULL, 0);
+
+    /* pixel shader */
+    ID3D11DeviceContext_PSSetShader(d3d_dev->d3dcontext, quad->d3dpixelShader, NULL, 0);
+
+    ID3D11DeviceContext_PSSetConstantBuffers(d3d_dev->d3dcontext, 0, quad->PSConstantsCount, quad->pPixelShaderConstants);
+    ID3D11DeviceContext_PSSetShaderResources(d3d_dev->d3dcontext, 0, quad->resourceCount, resourceView);
+
+    ID3D11DeviceContext_RSSetViewports(d3d_dev->d3dcontext, 1, &quad->cropViewport);
+
+    ID3D11DeviceContext_DrawIndexed(d3d_dev->d3dcontext, quad->indexCount, 0, 0);
+}
diff --git a/modules/video_output/win32/d3d11_quad.h b/modules/video_output/win32/d3d11_quad.h
index f21324bf2a..d708664736 100644
--- a/modules/video_output/win32/d3d11_quad.h
+++ b/modules/video_output/win32/d3d11_quad.h
@@ -23,6 +23,8 @@
 #ifndef VLC_D3D11_QUAD_H
 #define VLC_D3D11_QUAD_H
 
+#include "../../video_chroma/d3d11_fmt.h"
+
 typedef struct {
     FLOAT Opacity;
     FLOAT BoundaryX;
@@ -53,4 +55,8 @@ typedef struct
     PS_CONSTANT_BUFFER        shaderConstants;
 } d3d_quad_t;
 
+void D3D11_RenderQuad(d3d11_device_t *, d3d_quad_t *,
+                      ID3D11ShaderResourceView *resourceViews[D3D11_MAX_SHADER_VIEW],
+                      ID3D11RenderTargetView *);
+
 #endif /* VLC_D3D11_QUAD_H */
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index d669151194..50c8a1c93e 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -1058,33 +1058,6 @@ static void UpdateQuadLuminanceScale(vout_display_t *vd, d3d_quad_t *quad, float
         quad->shaderConstants.LuminanceScale = old;
 }
 
-static void D3D11_RenderQuad(d3d11_device_t *d3d_dev, d3d_quad_t *quad, ID3D11ShaderResourceView *resourceView[D3D11_MAX_SHADER_VIEW],
-                             ID3D11RenderTargetView *d3drenderTargetView)
-{
-    UINT offset = 0;
-
-    ID3D11DeviceContext_OMSetRenderTargets(d3d_dev->d3dcontext, 1, &d3drenderTargetView, NULL);
-
-    /* Render the quad */
-    /* vertex shader */
-    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 )
-        ID3D11DeviceContext_VSSetConstantBuffers(d3d_dev->d3dcontext, 0, 1, &quad->pVertexShaderConstants);
-
-    ID3D11DeviceContext_VSSetShader(d3d_dev->d3dcontext, quad->d3dvertexShader, NULL, 0);
-
-    /* pixel shader */
-    ID3D11DeviceContext_PSSetShader(d3d_dev->d3dcontext, quad->d3dpixelShader, NULL, 0);
-
-    ID3D11DeviceContext_PSSetConstantBuffers(d3d_dev->d3dcontext, 0, quad->PSConstantsCount, quad->pPixelShaderConstants);
-    ID3D11DeviceContext_PSSetShaderResources(d3d_dev->d3dcontext, 0, quad->resourceCount, resourceView);
-
-    ID3D11DeviceContext_RSSetViewports(d3d_dev->d3dcontext, 1, &quad->cropViewport);
-
-    ID3D11DeviceContext_DrawIndexed(d3d_dev->d3dcontext, quad->indexCount, 0, 0);
-}
-
 static float GetFormatLuminance(vlc_object_t *o, const video_format_t *fmt)
 {
     switch (fmt->transfer)



More information about the vlc-commits mailing list