Issue #2101 - Part 7: Add color range support on GPUs

This commit is contained in:
u3shit 2023-02-25 00:29:56 +01:00 committed by roytam1
commit 687733f9d1
18 changed files with 106 additions and 74 deletions

View file

@ -413,7 +413,8 @@ CompositorD3D9::DrawQuad(const gfx::Rect &aRect,
}
const float* yuvToRgb = gfxUtils::Get4x3YuvColorMatrix(ycbcrEffect->mYUVColorSpace);
const float* yuvToRgb = gfxUtils::YuvToRgbMatrix4x4XRowMajor(
ycbcrEffect->mYUVColorSpace, ycbcrEffect->mColorRange);
d3d9Device->SetPixelShaderConstantF(CBmYuvColorMatrix, yuvToRgb, 3);
TextureSourceD3D9* sourceY = source->GetSubSource(Y)->AsSourceD3D9();

View file

@ -18,7 +18,7 @@ sampler s2DMask;
float fLayerOpacity;
float4 fLayerColor;
row_major float3x3 mYuvColorMatrix : register(ps, c1);
row_major float4x4 mYuvColorMatrix : register(ps, c1);
struct VS_INPUT {
float4 vPosition : POSITION;
@ -162,17 +162,14 @@ For [0,1] instead of [0,255], and to 5 places:
*/
float4 YCbCrShader(const VS_OUTPUT aVertex) : COLOR
{
float3 yuv;
float4 color;
float4 yuv;
yuv.x = tex2D(s2DY, aVertex.vTexCoords).a - 0.06275;
yuv.y = tex2D(s2DCb, aVertex.vTexCoords).a - 0.50196;
yuv.z = tex2D(s2DCr, aVertex.vTexCoords).a - 0.50196;
yuv.x = tY.Sample(sSampler, aTexCoords).r;
yuv.y = tCb.Sample(sSampler, aTexCoords).r;
yuv.z = tCr.Sample(sSampler, aTexCoords).r;
yuv.w = 1.0;
color.rgb = mul(mYuvColorMatrix, yuv);
color.a = 1.0f;
return color * fLayerOpacity;
return mul(mYuvColorMatrix, yuv);
}
float4 SolidColorShader(const VS_OUTPUT aVertex) : COLOR

View file

@ -368,6 +368,7 @@ public:
// Bug 1305906 fixes YUVColorSpace handling
virtual YUVColorSpace GetYUVColorSpace() const override { return YUVColorSpace::BT601; }
virtual ColorRange GetColorRange() const override { return ColorRange::LIMITED; }
virtual bool Lock() override;
virtual void Unlock() override;