[vlc-commits] d3d_shaders: always define the DXGI_MAX_RENDER_TARGET textures in the shader

Steve Lhomme git at videolan.org
Wed Feb 10 11:07:00 UTC 2021


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Feb  3 11:43:08 2021 +0100| [2c8f24849f514ac6521832398016c3f1bb308ed6] | committer: Steve Lhomme

d3d_shaders: always define the DXGI_MAX_RENDER_TARGET textures in the shader

In most cases we won't use the extra textures.

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

 modules/video_output/win32/d3d11_shaders.c |  4 ++--
 modules/video_output/win32/d3d11_shaders.h |  6 +++---
 modules/video_output/win32/d3d_shaders.c   | 14 +++++++-------
 modules/video_output/win32/d3d_shaders.h   |  2 +-
 modules/video_output/win32/direct3d11.c    |  4 ++--
 5 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/modules/video_output/win32/d3d11_shaders.c b/modules/video_output/win32/d3d11_shaders.c
index 39eef96ef4..18aa1bca2f 100644
--- a/modules/video_output/win32/d3d11_shaders.c
+++ b/modules/video_output/win32/d3d11_shaders.c
@@ -39,7 +39,7 @@
 #include "d3d11_shaders.h"
 HRESULT (D3D11_CompilePixelShader)(vlc_object_t *o, const d3d_shader_compiler_t *compiler,
                                  d3d11_device_t *d3d_dev,
-                                 bool texture_array, size_t texture_count,
+                                 bool texture_array,
                                  const display_info_t *display, bool sharp,
                                  video_transfer_func_t transfer,
                                  video_color_primaries_t primaries, bool src_full_range,
@@ -73,7 +73,7 @@ HRESULT (D3D11_CompilePixelShader)(vlc_object_t *o, const d3d_shader_compiler_t
     }
 
     hr = D3D_CompilePixelShader(o, compiler, d3d_dev->feature_level, texture_array,
-                                texture_count, display, transfer, primaries,
+                                display, transfer, primaries,
                                 src_full_range, quad->generic.textureFormat, pPSBlob);
 
     if (SUCCEEDED(hr))
diff --git a/modules/video_output/win32/d3d11_shaders.h b/modules/video_output/win32/d3d11_shaders.h
index 22487879bd..f076d949aa 100644
--- a/modules/video_output/win32/d3d11_shaders.h
+++ b/modules/video_output/win32/d3d11_shaders.h
@@ -54,13 +54,13 @@ typedef struct
 } d3d11_quad_t;
 
 HRESULT D3D11_CompilePixelShader(vlc_object_t *, const d3d_shader_compiler_t *,
-                                 d3d11_device_t *, bool texture_array, size_t texture_count,
+                                 d3d11_device_t *, bool texture_array,
                                  const display_info_t *, bool sharp,
                                  video_transfer_func_t, video_color_primaries_t,
                                  bool src_full_range,
                                  d3d11_quad_t *);
-#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)
+#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)
 void D3D11_ReleasePixelShader(d3d11_quad_t *);
 
 HRESULT D3D11_CompileFlatVertexShader(vlc_object_t *, const d3d_shader_compiler_t *, d3d11_device_t *, d3d11_vertex_shader_t *);
diff --git a/modules/video_output/win32/d3d_shaders.c b/modules/video_output/win32/d3d_shaders.c
index e44d714db0..be4674a1e5 100644
--- a/modules/video_output/win32/d3d_shaders.c
+++ b/modules/video_output/win32/d3d_shaders.c
@@ -62,7 +62,7 @@ static const char* globPixelShaderDefault = "\
     float4x4 Colorspace;\n\
     float4x4 Primaries;\n\
   };\n\
-  Texture2D%s shaderTexture[%d];\n\
+  Texture2D%s shaderTexture[4];\n\
   SamplerState normalSampler : register(s0);\n\
   SamplerState borderSampler : register(s1);\n\
   \n\
@@ -294,7 +294,7 @@ static ID3DBlob* CompileShader(vlc_object_t *obj, const d3d_shader_compiler_t *c
 
 static HRESULT CompilePixelShaderBlob(vlc_object_t *o, const d3d_shader_compiler_t *compiler,
                                    D3D_FEATURE_LEVEL feature_level,
-                                   bool texture_array, size_t texture_count,
+                                   bool texture_array,
                                    const char *psz_sampler,
                                    const char *psz_src_to_linear,
                                    const char *psz_primaries_transform,
@@ -305,7 +305,6 @@ static HRESULT CompilePixelShaderBlob(vlc_object_t *o, const d3d_shader_compiler
 {
     char *shader;
     int allocated = asprintf(&shader, globPixelShaderDefault, texture_array ? "Array" : "",
-                             texture_count * DXGI_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);
@@ -337,7 +336,7 @@ static HRESULT CompilePixelShaderBlob(vlc_object_t *o, const d3d_shader_compiler
 
 HRESULT (D3D_CompilePixelShader)(vlc_object_t *o, const d3d_shader_compiler_t *compiler,
                                  D3D_FEATURE_LEVEL feature_level,
-                                 bool texture_array, size_t texture_count,
+                                 bool texture_array,
                                  const display_info_t *display,
                                  video_transfer_func_t transfer,
                                  video_color_primaries_t primaries, bool src_full_range,
@@ -368,6 +367,7 @@ HRESULT (D3D_CompilePixelShader)(vlc_object_t *o, const d3d_shader_compiler_t *c
                     "sample.z = 0.0;\n"
                     "sample.a = 1;";
             psz_sampler[1] =
+                    // TODO should be shaderTexture[0] ?
                     "sample.xy  = shaderTexture[1].Sample(samplerState, coords).xy;\n"
                     "sample.z = 0.0;\n"
                     "sample.a = 1;";
@@ -688,8 +688,8 @@ HRESULT (D3D_CompilePixelShader)(vlc_object_t *o, const d3d_shader_compiler_t *c
     }
 
     HRESULT hr;
-    hr = CompilePixelShaderBlob(o, compiler, feature_level, texture_array, texture_count,
-                                   psz_sampler[0],
+    hr = CompilePixelShaderBlob(o, compiler, feature_level, texture_array,
+                                psz_sampler[0],
                                    psz_src_to_linear,
                                    psz_primaries_transform,
                                    psz_linear_to_display,
@@ -697,7 +697,7 @@ HRESULT (D3D_CompilePixelShader)(vlc_object_t *o, const d3d_shader_compiler_t *c
                                    psz_adjust_range, psz_move_planes[0], &pPSBlob[0]);
     if (SUCCEEDED(hr) && psz_sampler[1])
     {
-        hr = CompilePixelShaderBlob(o, compiler, feature_level, texture_array, texture_count,
+        hr = CompilePixelShaderBlob(o, compiler, feature_level, texture_array,
                                     psz_sampler[1],
                                     psz_src_to_linear,
                                     psz_primaries_transform,
diff --git a/modules/video_output/win32/d3d_shaders.h b/modules/video_output/win32/d3d_shaders.h
index bc27e98317..99cf19704c 100644
--- a/modules/video_output/win32/d3d_shaders.h
+++ b/modules/video_output/win32/d3d_shaders.h
@@ -107,7 +107,7 @@ typedef struct
 
 HRESULT D3D_CompilePixelShader(vlc_object_t *, const d3d_shader_compiler_t *,
                                D3D_FEATURE_LEVEL,
-                               bool texture_array, size_t texture_count,
+                               bool texture_array,
                                const display_info_t *,
                                video_transfer_func_t,
                                video_color_primaries_t, bool src_full_range,
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 0418e49e62..f41fd23f6d 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -1035,7 +1035,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, 1,
+    hr = D3D11_CompilePixelShader(vd, &sys->shaders, sys->d3d_dev, !sys->legacy_shader,
                                   &sys->display, false, fmt->transfer, fmt->primaries,
                                   fmt->color_range == COLOR_RANGE_FULL,
                                   &sys->picQuad);
@@ -1176,7 +1176,7 @@ static int Direct3D11CreateGenericResources(vout_display_t *vd)
 
     if (sys->regionQuad.generic.textureFormat != NULL)
     {
-        hr = D3D11_CompilePixelShader(vd, &sys->shaders, sys->d3d_dev, !sys->legacy_shader, 1,
+        hr = D3D11_CompilePixelShader(vd, &sys->shaders, sys->d3d_dev, !sys->legacy_shader,
                                       &sys->display, true, TRANSFER_FUNC_SRGB, COLOR_PRIMARIES_SRGB, true,
                                       &sys->regionQuad);
         if (FAILED(hr))



More information about the vlc-commits mailing list