Use optimized pixel shaders for the normal SDR and HDR colorspaces

This commit is contained in:
Cameron Gutman
2022-02-09 20:46:02 -06:00
parent be2af1d17a
commit 9a64c026ea
10 changed files with 193 additions and 73 deletions
+3 -1
View File
@@ -1,4 +1,6 @@
fxc /T vs_4_0_level_9_3 /Fo d3d11_vertex.fxc d3d11_vertex.hlsl
fxc /T ps_4_0_level_9_3 /Fo d3d11_overlay_pixel.fxc d3d11_overlay_pixel.hlsl
fxc /T ps_4_0_level_9_3 /Fo d3d11_video_pixel.fxc d3d11_video_pixel.hlsl
fxc /T ps_4_0_level_9_3 /Fo d3d11_video_pixel.fxc d3d11_video_pixel.hlsl
fxc /T ps_4_0_level_9_3 /Fo d3d11_bt601lim_pixel.fxc d3d11_bt601lim_pixel.hlsl
fxc /T ps_4_0_level_9_3 /Fo d3d11_bt2020lim_pixel.fxc d3d11_bt2020lim_pixel.hlsl
Binary file not shown.
+35
View File
@@ -0,0 +1,35 @@
Texture2D<min16float> luminancePlane : register(t0);
Texture2D<min16float2> chrominancePlane : register(t1);
SamplerState theSampler : register(s0);
static const min16float3x3 cscMatrix =
{
1.1644, 1.1644, 1.1644,
0.0, -0.1874, 2.1418,
1.6781, -0.6505, 0.0,
};
static const min16float3 offsets =
{
16.0 / 255.0, 128.0 / 255.0, 128.0 / 255.0
};
struct ShaderInput
{
min16float4 pos : SV_POSITION;
min16float2 tex : TEXCOORD0;
};
min16float4 main(ShaderInput input) : SV_TARGET
{
min16float3 yuv = min16float3(luminancePlane.Sample(theSampler, input.tex),
chrominancePlane.Sample(theSampler, input.tex));
// Subtract the YUV offset for limited vs full range
yuv -= offsets;
// Multiply by the conversion matrix for this colorspace
yuv = mul(yuv, cscMatrix);
return min16float4(yuv, 1.0);
}
Binary file not shown.
+35
View File
@@ -0,0 +1,35 @@
Texture2D<min16float> luminancePlane : register(t0);
Texture2D<min16float2> chrominancePlane : register(t1);
SamplerState theSampler : register(s0);
static const min16float3x3 cscMatrix =
{
1.1644, 1.1644, 1.1644,
0.0, -0.3917, 2.0172,
1.5960, -0.8129, 0.0,
};
static const min16float3 offsets =
{
16.0 / 255.0, 128.0 / 255.0, 128.0 / 255.0
};
struct ShaderInput
{
min16float4 pos : SV_POSITION;
min16float2 tex : TEXCOORD0;
};
min16float4 main(ShaderInput input) : SV_TARGET
{
min16float3 yuv = min16float3(luminancePlane.Sample(theSampler, input.tex),
chrominancePlane.Sample(theSampler, input.tex));
// Subtract the YUV offset for limited vs full range
yuv -= offsets;
// Multiply by the conversion matrix for this colorspace
yuv = mul(yuv, cscMatrix);
return min16float4(yuv, 1.0);
}
Binary file not shown.
+1 -1
View File
@@ -25,5 +25,5 @@ min16float4 main(ShaderInput input) : SV_TARGET
// Multiply by the conversion matrix for this colorspace
yuv = mul(yuv, cscMatrix);
return min16float4(saturate(yuv), 1.0);
return min16float4(yuv, 1.0);
}