Use FP16 in the D3D11 shaders

This commit is contained in:
Cameron Gutman 2022-02-08 21:43:25 -06:00
parent b96cb1abaf
commit b21131a466
6 changed files with 18 additions and 19 deletions

Binary file not shown.

View File

@ -1,13 +1,13 @@
Texture2D theTexture : register(t0);
Texture2D<min16float4> theTexture : register(t0);
SamplerState theSampler : register(s0);
struct ShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
min16float4 pos : SV_POSITION;
min16float2 tex : TEXCOORD0;
};
float4 main(ShaderInput input) : SV_TARGET
min16float4 main(ShaderInput input) : SV_TARGET
{
return theTexture.Sample(theSampler, input.tex);
}

Binary file not shown.

View File

@ -1,19 +1,19 @@
struct ShaderInput
{
float2 pos : POSITION;
float2 tex : TEXCOORD0;
min16float2 pos : POSITION;
min16float2 tex : TEXCOORD0;
};
struct ShaderOutput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
min16float4 pos : SV_POSITION;
min16float2 tex : TEXCOORD0;
};
ShaderOutput main(ShaderInput input)
{
ShaderOutput output;
output.pos = float4(input.pos, 0.0f, 1.0f);
output.pos = min16float4(input.pos, 0.0, 1.0);
output.tex = input.tex;
return output;
}

Binary file not shown.

View File

@ -1,24 +1,23 @@
Texture2D luminancePlane : register(t0);
Texture2D chrominancePlane : register(t1);
Texture2D<min16float> luminancePlane : register(t0);
Texture2D<min16float2> chrominancePlane : register(t1);
SamplerState theSampler : register(s0);
cbuffer CSC_CONST_BUF : register(b0)
{
float3x3 cscMatrix;
float3 offsets;
min16float3x3 cscMatrix;
min16float3 offsets;
};
struct ShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
min16float4 pos : SV_POSITION;
min16float2 tex : TEXCOORD0;
};
min16float4 main(ShaderInput input) : SV_TARGET
{
float y = luminancePlane.Sample(theSampler, input.tex);
float2 uv = chrominancePlane.Sample(theSampler, input.tex);
float3 yuv = float3(y, uv);
min16float3 yuv = min16float3(luminancePlane.Sample(theSampler, input.tex),
chrominancePlane.Sample(theSampler, input.tex));
// Subtract the YUV offset for limited vs full range
yuv -= offsets;
@ -26,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.0f);
return min16float4(saturate(yuv), 1.0);
}