Handle chroma co-siting in the D3D11 shaders

This commit is contained in:
Cameron Gutman 2025-11-01 22:42:51 -05:00
commit f67272b153
15 changed files with 129 additions and 132 deletions

View file

@ -1,8 +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_genyuv_pixel.fxc d3d11_genyuv_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
fxc /T ps_4_0_level_9_3 /Fo d3d11_yuv420_pixel.fxc d3d11_yuv420_pixel.hlsl
fxc /T ps_4_0_level_9_3 /Fo d3d11_ayuv_pixel.fxc d3d11_ayuv_pixel.hlsl
fxc /T ps_4_0_level_9_3 /Fo d3d11_y410_pixel.fxc d3d11_y410_pixel.hlsl

Binary file not shown.

View file

@ -1,15 +0,0 @@
#include "d3d11_video_pixel_start.hlsli"
static const min16float3x3 cscMatrix =
{
1.1678, 1.1678, 1.1678,
0.0, -0.1879, 2.1481,
1.6836, -0.6524, 0.0,
};
static const min16float3 offsets =
{
64.0 / 1023.0, 512.0 / 1023.0, 512.0 / 1023.0
};
#include "d3d11_video_pixel_end.hlsli"

Binary file not shown.

View file

@ -1,15 +0,0 @@
#include "d3d11_video_pixel_start.hlsli"
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
};
#include "d3d11_video_pixel_end.hlsli"

Binary file not shown.

View file

@ -2,7 +2,7 @@ min16float4 main(ShaderInput input) : SV_TARGET
{
// Clamp the chrominance texcoords to avoid sampling the row of texels adjacent to the alignment padding
min16float3 yuv = min16float3(luminancePlane.Sample(theSampler, input.tex),
chrominancePlane.Sample(theSampler, min(input.tex, chromaTexMax.rg)));
chrominancePlane.Sample(theSampler, min(input.tex + chromaOffset, chromaTexMax.rg)));
// Subtract the YUV offset for limited vs full range
yuv -= offsets;

Binary file not shown.

Binary file not shown.

View file

@ -4,6 +4,7 @@ cbuffer CSC_CONST_BUF : register(b1)
{
min16float3x3 cscMatrix;
min16float3 offsets;
min16float2 chromaOffset;
};
#include "d3d11_video_pixel_end.hlsli"

View file

@ -16,4 +16,5 @@ cbuffer CSC_CONST_BUF : register(b1)
{
min16float3x3 cscMatrix;
min16float3 offsets;
min16float2 chromaOffset; // Unused for 4:4:4
};