[vlc-commits] d3d11_shaders: move the vertex shader sources in d3d11_shaders

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


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Feb 20 17:44:40 2018 +0100| [3a2fabe650988e556dcb8c597b0467384aadf89f] | committer: Steve Lhomme

d3d11_shaders: move the vertex shader sources in d3d11_shaders

And share them for anyone to use.

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

 modules/video_output/win32/d3d11_shaders.c | 55 +++++++++++++++++++++++++++++
 modules/video_output/win32/d3d11_shaders.h |  3 ++
 modules/video_output/win32/direct3d11.c    | 56 ------------------------------
 3 files changed, 58 insertions(+), 56 deletions(-)

diff --git a/modules/video_output/win32/d3d11_shaders.c b/modules/video_output/win32/d3d11_shaders.c
index 101149e0d8..0b2a65353a 100644
--- a/modules/video_output/win32/d3d11_shaders.c
+++ b/modules/video_output/win32/d3d11_shaders.c
@@ -133,6 +133,61 @@ static const char* globPixelShaderDefault = "\
   }\n\
 ";
 
+const char* globVertexShaderFlat = "\
+struct VS_INPUT\n\
+{\n\
+  float4 Position   : POSITION;\n\
+  float4 Texture    : TEXCOORD0;\n\
+};\n\
+\n\
+struct VS_OUTPUT\n\
+{\n\
+  float4 Position   : SV_POSITION;\n\
+  float4 Texture    : TEXCOORD0;\n\
+};\n\
+\n\
+VS_OUTPUT main( VS_INPUT In )\n\
+{\n\
+  return In;\n\
+}\n\
+";
+
+const char* globVertexShaderProjection = "\n\
+cbuffer VS_PROJECTION_CONST : register(b0)\n\
+{\n\
+   float4x4 RotX;\n\
+   float4x4 RotY;\n\
+   float4x4 RotZ;\n\
+   float4x4 View;\n\
+   float4x4 Projection;\n\
+};\n\
+struct VS_INPUT\n\
+{\n\
+  float4 Position   : POSITION;\n\
+  float4 Texture    : TEXCOORD0;\n\
+};\n\
+\n\
+struct VS_OUTPUT\n\
+{\n\
+  float4 Position   : SV_POSITION;\n\
+  float4 Texture    : TEXCOORD0;\n\
+};\n\
+\n\
+VS_OUTPUT main( VS_INPUT In )\n\
+{\n\
+  VS_OUTPUT Output;\n\
+  float4 pos = In.Position;\n\
+  pos = mul(RotY, pos);\n\
+  pos = mul(RotX, pos);\n\
+  pos = mul(RotZ, pos);\n\
+  pos = mul(View, pos);\n\
+  pos = mul(Projection, pos);\n\
+  Output.Position = pos;\n\
+  Output.Texture = In.Texture;\n\
+  return Output;\n\
+}\n\
+";
+
 bool IsRGBShader(const d3d_format_t *cfg)
 {
     return cfg->resourceFormat[0] != DXGI_FORMAT_R8_UNORM &&
diff --git a/modules/video_output/win32/d3d11_shaders.h b/modules/video_output/win32/d3d11_shaders.h
index d965d9472e..737700e6f3 100644
--- a/modules/video_output/win32/d3d11_shaders.h
+++ b/modules/video_output/win32/d3d11_shaders.h
@@ -46,6 +46,9 @@ typedef struct {
     unsigned                 luminance_peak;
 } display_info_t;
 
+const char* globVertexShaderFlat;
+const char* globVertexShaderProjection;
+
 ID3DBlob* D3D11_CompileShader(vlc_object_t *, const d3d11_handle_t *, const d3d11_device_t *,
                               const char *psz_shader, bool pixel);
 #define D3D11_CompileShader(a,b,c,d,e)  D3D11_CompileShader(VLC_OBJECT(a),b,c,d,e)
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 87e66f943d..2974844436 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -189,62 +189,6 @@ static void UpdatePicQuadPosition(vout_display_t *);
 
 static int Control(vout_display_t *vd, int query, va_list args);
 
-/* TODO: Move to a direct3d11_shaders header */
-static const char* globVertexShaderFlat = "\
-  struct VS_INPUT\
-  {\
-    float4 Position   : POSITION;\
-    float4 Texture    : TEXCOORD0;\
-  };\
-  \
-  struct VS_OUTPUT\
-  {\
-    float4 Position   : SV_POSITION;\
-    float4 Texture    : TEXCOORD0;\
-  };\
-  \
-  VS_OUTPUT main( VS_INPUT In )\
-  {\
-    return In;\
-  }\
-";
-
-static const char* globVertexShaderProjection = "\
-  cbuffer VS_PROJECTION_CONST : register(b0)\
-  {\
-     float4x4 RotX;\
-     float4x4 RotY;\
-     float4x4 RotZ;\
-     float4x4 View;\
-     float4x4 Projection;\
-  };\
-  struct VS_INPUT\
-  {\
-    float4 Position   : POSITION;\
-    float4 Texture    : TEXCOORD0;\
-  };\
-  \
-  struct VS_OUTPUT\
-  {\
-    float4 Position   : SV_POSITION;\
-    float4 Texture    : TEXCOORD0;\
-  };\
-  \
-  VS_OUTPUT main( VS_INPUT In )\
-  {\
-    VS_OUTPUT Output;\
-    float4 pos = In.Position;\
-    pos = mul(RotY, pos);\
-    pos = mul(RotX, pos);\
-    pos = mul(RotZ, pos);\
-    pos = mul(View, pos);\
-    pos = mul(Projection, pos);\
-    Output.Position = pos;\
-    Output.Texture = In.Texture;\
-    return Output;\
-  }\
-";
-
 static int Direct3D11MapPoolTexture(picture_t *picture)
 {
     picture_sys_t *p_sys = picture->p_sys;



More information about the vlc-commits mailing list