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).
This commit is contained in:
Steve Lhomme 2020-10-23 08:53:34 +02:00
parent bd746b8f0d
commit c2ca19baf8
3 changed files with 12 additions and 10 deletions

View File

@ -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,

View File

@ -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 *);

View File

@ -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))