mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
d3d12: Update shader to be Shader Model 5.0 compatible
And use fxc HLSL compiler Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6434>
This commit is contained in:
parent
0faff6fb5e
commit
43da9b4249
7 changed files with 42 additions and 72 deletions
|
@ -478,17 +478,17 @@ ConverterRootSignature::ConverterRootSignature (D3D_ROOT_SIGNATURE_VERSION
|
|||
|
||||
/* VS root const, maybe updated */
|
||||
vs_root_const_ = (UINT) param_list_v1_1.size ();
|
||||
param.InitAsConstants (16, 0, 1, D3D12_SHADER_VISIBILITY_VERTEX);
|
||||
param.InitAsConstants (16, 0, 0, D3D12_SHADER_VISIBILITY_VERTEX);
|
||||
param_list_v1_1.push_back (param);
|
||||
|
||||
/* PS alpha constant value, maybe updated */
|
||||
ps_root_const_ = (UINT) param_list_v1_1.size ();
|
||||
param.InitAsConstants (1, 0, 0, D3D12_SHADER_VISIBILITY_PIXEL);
|
||||
param.InitAsConstants (1, 1, 0, D3D12_SHADER_VISIBILITY_PIXEL);
|
||||
param_list_v1_1.push_back (param);
|
||||
|
||||
/* PS CBV, this is static */
|
||||
ps_cbv_ = (UINT) param_list_v1_1.size ();
|
||||
param.InitAsConstantBufferView (1, 0,
|
||||
param.InitAsConstantBufferView (2, 0,
|
||||
D3D12_ROOT_DESCRIPTOR_FLAG_DATA_STATIC_WHILE_SET_AT_EXECUTE,
|
||||
D3D12_SHADER_VISIBILITY_PIXEL);
|
||||
param_list_v1_1.push_back (param);
|
||||
|
@ -522,12 +522,12 @@ ConverterRootSignature::ConverterRootSignature (D3D_ROOT_SIGNATURE_VERSION
|
|||
|
||||
/* PS alpha constant value, maybe updated */
|
||||
ps_root_const_ = (UINT) param_list_v1_0.size ();
|
||||
param.InitAsConstants (1, 0, 0, D3D12_SHADER_VISIBILITY_PIXEL);
|
||||
param.InitAsConstants (1, 1, 0, D3D12_SHADER_VISIBILITY_PIXEL);
|
||||
param_list_v1_0.push_back (param);
|
||||
|
||||
/* PS CBV, this is static */
|
||||
ps_cbv_ = (UINT) param_list_v1_0.size ();
|
||||
param.InitAsConstantBufferView (1, 0, D3D12_SHADER_VISIBILITY_PIXEL);
|
||||
param.InitAsConstantBufferView (2, 0, D3D12_SHADER_VISIBILITY_PIXEL);
|
||||
param_list_v1_0.push_back (param);
|
||||
|
||||
CD3DX12_VERSIONED_ROOT_SIGNATURE_DESC::Init_1_0 (desc,
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
cbuffer PsAlphaFactor : register(b0, space0)
|
||||
cbuffer PsAlphaFactor : register(b1)
|
||||
{
|
||||
float alphaFactor;
|
||||
};
|
||||
|
@ -33,39 +33,22 @@ struct PSColorSpace
|
|||
float padding;
|
||||
};
|
||||
|
||||
cbuffer PsConstBuffer : register(b1, space0)
|
||||
cbuffer PsConstBuffer : register(b2)
|
||||
{
|
||||
PSColorSpace preCoeff;
|
||||
PSColorSpace postCoeff;
|
||||
PSColorSpace primariesCoeff;
|
||||
};
|
||||
|
||||
#ifdef NUM_SRV_1
|
||||
Texture2D shaderTexture_0 : register(t0, space0);
|
||||
#endif
|
||||
#ifdef NUM_SRV_2
|
||||
Texture2D shaderTexture_0 : register(t0, space0);
|
||||
Texture2D shaderTexture_1 : register(t1, space0);
|
||||
#endif
|
||||
#ifdef NUM_SRV_3
|
||||
Texture2D shaderTexture_0 : register(t0, space0);
|
||||
Texture2D shaderTexture_1 : register(t1, space0);
|
||||
Texture2D shaderTexture_2 : register(t2, space0);
|
||||
#endif
|
||||
#ifdef NUM_SRV_4
|
||||
Texture2D shaderTexture_0 : register(t0, space0);
|
||||
Texture2D shaderTexture_1 : register(t1, space0);
|
||||
Texture2D shaderTexture_2 : register(t2, space0);
|
||||
Texture2D shaderTexture_3 : register(t3, space0);
|
||||
#endif
|
||||
Texture2D shaderTexture_0 : register(t0);
|
||||
Texture2D shaderTexture_1 : register(t1);
|
||||
Texture2D shaderTexture_2 : register(t2);
|
||||
Texture2D shaderTexture_3 : register(t3);
|
||||
Texture1D<float> gammaDecLUT : register(t4);
|
||||
Texture1D<float> gammaEncLUT : register(t5);
|
||||
|
||||
SamplerState samplerState : register(s0, space0);
|
||||
|
||||
#ifdef BUILD_LUT
|
||||
Texture1D<float> gammaDecLUT : register(t4, space0);
|
||||
Texture1D<float> gammaEncLUT : register(t5, space0);
|
||||
SamplerState lutSamplerState : register(s1, space0);
|
||||
#endif
|
||||
SamplerState samplerState : register(s0);
|
||||
SamplerState lutSamplerState : register(s1);
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
|
@ -133,7 +116,6 @@ interface ISampler
|
|||
float4 Execute (float2 uv);
|
||||
};
|
||||
|
||||
#ifdef NUM_SRV_1
|
||||
class SamplerRGBA : ISampler
|
||||
{
|
||||
float4 Execute (float2 uv)
|
||||
|
@ -258,9 +240,7 @@ class SamplerGRAY : ISampler
|
|||
return sample;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef NUM_SRV_2
|
||||
class SamplerNV12 : ISampler
|
||||
{
|
||||
float4 Execute (float2 uv)
|
||||
|
@ -284,9 +264,7 @@ class SamplerNV21 : ISampler
|
|||
return sample;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef NUM_SRV_3
|
||||
class SamplerI420 : ISampler
|
||||
{
|
||||
float4 Execute (float2 uv)
|
||||
|
@ -399,9 +377,7 @@ class SamplerBGRP : ISampler
|
|||
return sample;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef NUM_SRV_4
|
||||
class SamplerGBRA : ISampler
|
||||
{
|
||||
float4 Execute (float2 uv)
|
||||
|
@ -440,7 +416,6 @@ class SamplerGBRA_12 : ISampler
|
|||
return saturate (sample * 16.0);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
interface IConverter
|
||||
{
|
||||
|
@ -481,7 +456,6 @@ class ConverterSimple : IConverter
|
|||
}
|
||||
};
|
||||
|
||||
#ifdef BUILD_LUT
|
||||
class ConverterGamma : IConverter
|
||||
{
|
||||
float4 Execute (float4 sample)
|
||||
|
@ -540,7 +514,6 @@ class ConverterPrimary : IConverter
|
|||
return float4 (clamp (out_space, postCoeff.Min, postCoeff.Max), sample.a);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
float UnormTo10bit (float sample)
|
||||
{
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
Texture2D shaderTexture : register(t0, space0);
|
||||
SamplerState samplerState : register(s0, space0);
|
||||
Texture2D shaderTexture : register(t0);
|
||||
SamplerState samplerState : register(s0);
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
Texture2D shaderTexture : register(t0, space0);
|
||||
SamplerState samplerState : register(s0, space0);
|
||||
Texture2D shaderTexture : register(t0);
|
||||
SamplerState samplerState : register(s0);
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
cbuffer VsConstBuffer : register(b0, space1)
|
||||
cbuffer VsConstBuffer : register(b0)
|
||||
{
|
||||
matrix Transform;
|
||||
};
|
||||
|
|
|
@ -90,16 +90,15 @@ foreach input_format : hlsl_conv_ps_input_formats
|
|||
compiled_shader = custom_target(header,
|
||||
input : hlsl_conv_ps_source,
|
||||
output : header,
|
||||
command : [dxc, '/Fh', '@OUTPUT@',
|
||||
command : [fxc, '/Fh', '@OUTPUT@',
|
||||
'/E', entry_point,
|
||||
'/T', 'ps_6_0',
|
||||
'/T', 'ps_5_0',
|
||||
'/D', 'OUTPUT_TYPE=@0@'.format(output_type),
|
||||
'/D', 'ENTRY_POINT=@0@'.format(entry_point),
|
||||
'/D', 'SAMPLER=Sampler@0@'.format(in_format),
|
||||
'/D', 'CONVERTER=Converter@0@'.format(conv),
|
||||
'/D', 'OUTPUT_BUILDER=Output@0@'.format(output_builder),
|
||||
'/D', 'NUM_SRV_@0@=1'.format(num_srv),
|
||||
'/all-resources-bound',
|
||||
'/nologo',
|
||||
'@INPUT@'])
|
||||
hlsl_precompiled += [compiled_shader]
|
||||
endforeach
|
||||
|
@ -110,17 +109,15 @@ foreach input_format : hlsl_conv_ps_input_formats
|
|||
compiled_shader = custom_target(header,
|
||||
input : hlsl_conv_ps_source,
|
||||
output : header,
|
||||
command : [dxc, '/Fh', '@OUTPUT@',
|
||||
command : [fxc, '/Fh', '@OUTPUT@',
|
||||
'/E', entry_point,
|
||||
'/T', 'ps_6_0',
|
||||
'/T', 'ps_5_0',
|
||||
'/D', 'OUTPUT_TYPE=@0@'.format(output_type),
|
||||
'/D', 'ENTRY_POINT=@0@'.format(entry_point),
|
||||
'/D', 'SAMPLER=Sampler@0@'.format(in_format),
|
||||
'/D', 'CONVERTER=Converter@0@'.format(conv),
|
||||
'/D', 'OUTPUT_BUILDER=Output@0@'.format(output_builder),
|
||||
'/D', 'NUM_SRV_@0@=1'.format(num_srv),
|
||||
'/D', 'BUILD_LUT=1',
|
||||
'/all-resources-bound',
|
||||
'/nologo',
|
||||
'@INPUT@'])
|
||||
hlsl_precompiled += [compiled_shader]
|
||||
endforeach
|
||||
|
@ -140,18 +137,18 @@ generated_collection = custom_target(header_collection,
|
|||
hlsl_precompiled += generated_collection
|
||||
|
||||
hlsl_sources = [
|
||||
['VSMain_converter', 'vs_6_0'],
|
||||
['PSMain_sample', 'ps_6_0'],
|
||||
['PSMain_sample_premul', 'ps_6_0'],
|
||||
['VSMain_coord', 'vs_6_0'],
|
||||
['PSMain_color', 'ps_6_0'],
|
||||
['VSMain_color', 'vs_6_0'],
|
||||
['PSMain_snow', 'ps_6_0'],
|
||||
['PSMain_checker', 'ps_6_0'],
|
||||
['PSMain_checker_luma', 'ps_6_0'],
|
||||
['PSMain_checker_rgb', 'ps_6_0'],
|
||||
['PSMain_checker_vuya', 'ps_6_0'],
|
||||
['VSMain_pos', 'vs_6_0'],
|
||||
['VSMain_converter', 'vs_5_0'],
|
||||
['PSMain_sample', 'ps_5_0'],
|
||||
['PSMain_sample_premul', 'ps_5_0'],
|
||||
['VSMain_coord', 'vs_5_0'],
|
||||
['PSMain_color', 'ps_5_0'],
|
||||
['VSMain_color', 'vs_5_0'],
|
||||
['PSMain_snow', 'ps_5_0'],
|
||||
['PSMain_checker', 'ps_5_0'],
|
||||
['PSMain_checker_luma', 'ps_5_0'],
|
||||
['PSMain_checker_rgb', 'ps_5_0'],
|
||||
['PSMain_checker_vuya', 'ps_5_0'],
|
||||
['VSMain_pos', 'vs_5_0'],
|
||||
]
|
||||
|
||||
foreach shader : hlsl_sources
|
||||
|
@ -161,10 +158,10 @@ foreach shader : hlsl_sources
|
|||
compiled_shader = custom_target(header,
|
||||
input : source,
|
||||
output : header,
|
||||
command : [dxc, '/Fh', '@OUTPUT@',
|
||||
command : [fxc, '/Fh', '@OUTPUT@',
|
||||
'/E', entry_point,
|
||||
'/T', shader.get(1),
|
||||
'/all-resources-bound',
|
||||
'/nologo',
|
||||
'@INPUT@'])
|
||||
hlsl_precompiled += [compiled_shader]
|
||||
endforeach
|
||||
|
|
|
@ -75,10 +75,10 @@ dx_headers_dep = dependency('DirectX-Headers',
|
|||
version: '>= 1.611',
|
||||
allow_fallback: true,
|
||||
required: d3d12_option)
|
||||
dxc = find_program('dxc', required : d3d12_option)
|
||||
fxc = find_program('fxc', required : d3d12_option)
|
||||
|
||||
if not gstdxva_dep.found() or not d3d12_lib.found() or not dxgi_lib.found() \
|
||||
or not dx_headers_dep.found() or not dxc.found() or not d2d_dep.found() \
|
||||
or not dx_headers_dep.found() or not fxc.found() or not d2d_dep.found() \
|
||||
or not dwmapi_lib.found()
|
||||
if d3d12_option.enabled()
|
||||
error('The d3d12 was enabled explicitly, but required dependencies were not found.')
|
||||
|
|
Loading…
Reference in a new issue