[vlc-commits] d3d11: allow more that one texture in the shader

Steve Lhomme git at videolan.org
Fri Oct 23 13:02:40 CEST 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Oct 23 08:53:34 2020 +0200| [c2ca19baf8e6ddf2b2586c880891893fae9daa02] | committer: Steve Lhomme

d3d11: allow more that one texture in the shader

They are passed by D3D11_MAX_SHADER_VIEW amount of resource views each (many of
them can be unused).

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

 modules/video_output/win32/d3d11_shaders.c | 11 ++++++-----
 modules/video_output/win32/d3d11_shaders.h |  7 ++++---
 modules/video_output/win32/direct3d11.c    |  4 ++--
 3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/modules/video_output/win32/d3d11_shaders.c b/modules/video_output/win32/d3d11_shaders.c
index 75e8529de2..2e58ade861 100644
--- a/modules/video_output/win32/d3d11_shaders.c
+++ b/modules/video_output/win32/d3d11_shaders.c
@@ -61,7 +61,7 @@ static const char* globPixelShaderDefault = "\
     float4x4 Colorspace;\n\
     float4x4 Primaries;\n\
   };\n\
-  Texture2D%s shaderTexture[" STRINGIZE(D3D11_MAX_SHADER_VIEW) "];\n\
+  Texture2D%s shaderTexture[%d];\n\
   SamplerState SamplerStates[2];\n\
   \n\
   struct PS_INPUT\n\
@@ -207,7 +207,7 @@ bool IsRGBShader(const d3d_format_t *cfg)
 
 static HRESULT CompileTargetShader(vlc_object_t *o, const d3d11_shader_compiler_t *compiler,
                                    d3d11_device_t *d3d_dev,
-                                   bool texture_array,
+                                   bool texture_array, size_t texture_count,
                                    const char *psz_sampler,
                                    const char *psz_src_to_linear,
                                    const char *psz_primaries_transform,
@@ -218,6 +218,7 @@ static HRESULT CompileTargetShader(vlc_object_t *o, const d3d11_shader_compiler_
 {
     char *shader;
     int allocated = asprintf(&shader, globPixelShaderDefault, texture_array ? "Array" : "",
+                             texture_count * D3D11_MAX_SHADER_VIEW,
                              psz_src_to_linear, psz_linear_to_display,
                              psz_primaries_transform, psz_tone_mapping,
                              psz_adjust_range, psz_move_planes, psz_sampler);
@@ -255,7 +256,7 @@ static HRESULT CompileTargetShader(vlc_object_t *o, const d3d11_shader_compiler_
 
 HRESULT (D3D11_CompilePixelShader)(vlc_object_t *o, const d3d11_shader_compiler_t *compiler,
                                  d3d11_device_t *d3d_dev,
-                                 bool texture_array,
+                                 bool texture_array, size_t texture_count,
                                  const display_info_t *display, bool sharp,
                                  video_transfer_func_t transfer,
                                  video_color_primaries_t primaries, bool src_full_range,
@@ -629,13 +630,13 @@ HRESULT (D3D11_CompilePixelShader)(vlc_object_t *o, const d3d11_shader_compiler_
         }
     }
 
-    hr = CompileTargetShader(o, compiler, d3d_dev, texture_array,
+    hr = CompileTargetShader(o, compiler, d3d_dev, texture_array, texture_count,
                                      psz_sampler[0], psz_src_to_linear,
                                      psz_primaries_transform,
                                      psz_linear_to_display, psz_tone_mapping,
                                      psz_adjust_range, psz_move_planes[0], &quad->d3dpixelShader[0]);
     if (!FAILED(hr) && psz_sampler[1])
-        hr = CompileTargetShader(o, compiler, d3d_dev, texture_array,
+        hr = CompileTargetShader(o, compiler, d3d_dev, texture_array, texture_count,
                                  psz_sampler[1], psz_src_to_linear,
                                  psz_primaries_transform,
                                  psz_linear_to_display, psz_tone_mapping,
diff --git a/modules/video_output/win32/d3d11_shaders.h b/modules/video_output/win32/d3d11_shaders.h
index fa5f4bc737..ff52633ddf 100644
--- a/modules/video_output/win32/d3d11_shaders.h
+++ b/modules/video_output/win32/d3d11_shaders.h
@@ -110,12 +110,13 @@ int D3D11_InitShaders(vlc_object_t *, d3d11_shader_compiler_t *);
 void D3D11_ReleaseShaders(d3d11_shader_compiler_t *);
 
 HRESULT D3D11_CompilePixelShader(vlc_object_t *, const d3d11_shader_compiler_t *,
-                                 d3d11_device_t *, bool texture_array, const display_info_t *, bool sharp,
+                                 d3d11_device_t *, bool texture_array, size_t texture_count,
+                                 const display_info_t *, bool sharp,
                                  video_transfer_func_t, video_color_primaries_t,
                                  bool src_full_range,
                                  d3d_quad_t *);
-#define D3D11_CompilePixelShader(a,b,c,d,e,f,g,h,i,j) \
-    D3D11_CompilePixelShader(VLC_OBJECT(a),b,c,d,e,f,g,h,i,j)
+#define D3D11_CompilePixelShader(a,b,c,d,e,f,g,h,i,j,k) \
+    D3D11_CompilePixelShader(VLC_OBJECT(a),b,c,d,e,f,g,h,i,j,k)
 void D3D11_ReleasePixelShader(d3d_quad_t *);
 
 HRESULT D3D11_CompileFlatVertexShader(vlc_object_t *, const d3d11_shader_compiler_t *, d3d11_device_t *, d3d_vertex_shader_t *);
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 3d9d55b2ba..2f10951e4c 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -988,7 +988,7 @@ static int Direct3D11CreateFormatResources(vout_display_t *vd, const video_forma
     sys->legacy_shader = sys->d3d_dev->feature_level < D3D_FEATURE_LEVEL_10_0 || !CanUseTextureArray(vd) ||
             BogusZeroCopy(vd);
 
-    hr = D3D11_CompilePixelShader(vd, &sys->shaders, sys->d3d_dev, !sys->legacy_shader,
+    hr = D3D11_CompilePixelShader(vd, &sys->shaders, sys->d3d_dev, !sys->legacy_shader, 1,
                                   &sys->display, false, fmt->transfer, fmt->primaries,
                                   fmt->color_range == COLOR_RANGE_FULL,
                                   &sys->picQuad);
@@ -1085,7 +1085,7 @@ static int Direct3D11CreateGenericResources(vout_display_t *vd)
 
     if (sys->regionQuad.textureFormat != NULL)
     {
-        hr = D3D11_CompilePixelShader(vd, &sys->shaders, sys->d3d_dev, !sys->legacy_shader,
+        hr = D3D11_CompilePixelShader(vd, &sys->shaders, sys->d3d_dev, !sys->legacy_shader, 1,
                                       &sys->display, true, TRANSFER_FUNC_SRGB, COLOR_PRIMARIES_SRGB, true,
                                       &sys->regionQuad);
         if (FAILED(hr))



More information about the vlc-commits mailing list