forked from mirrors/gecko-dev
Bug 1659015 - P2. Add YUV identity support (rgb) to Advanced Layers. r=bas
It's destined to go, but for now it's required. Depends on D87167 Differential Revision: https://phabricator.services.mozilla.com/D87168
This commit is contained in:
parent
98c585cfb8
commit
4aac6e0243
6 changed files with 53 additions and 4 deletions
|
|
@ -830,8 +830,10 @@ bool MLGDeviceD3D11::Initialize() {
|
|||
LAZY_PS(ComponentAlphaQuadPS, ComponentAlphaQuad);
|
||||
LAZY_PS(ComponentAlphaVertexPS, ComponentAlphaVertex);
|
||||
LAZY_PS(TexturedVertexIMC4, TexturedVertexIMC4);
|
||||
LAZY_PS(TexturedVertexIdentityIMC4, TexturedVertexIdentityIMC4);
|
||||
LAZY_PS(TexturedVertexNV12, TexturedVertexNV12);
|
||||
LAZY_PS(TexturedQuadIMC4, TexturedQuadIMC4);
|
||||
LAZY_PS(TexturedQuadIdentityIMC4, TexturedQuadIdentityIMC4);
|
||||
LAZY_PS(TexturedQuadNV12, TexturedQuadNV12);
|
||||
LAZY_PS(BlendMultiplyPS, BlendMultiply);
|
||||
LAZY_PS(BlendScreenPS, BlendScreen);
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
- TexturedVertexNV12
|
||||
- TexturedQuadIMC4
|
||||
- TexturedQuadNV12
|
||||
- TexturedVertexIdentityIMC4
|
||||
- TexturedQuadIdentityIMC4
|
||||
|
||||
- type: vs_4_0
|
||||
file: color-vs.hlsl
|
||||
|
|
|
|||
|
|
@ -93,3 +93,26 @@ float4 TexturedVertexNV12(const VS_SAMPLEOUTPUT aInput) : SV_Target
|
|||
float alpha = ReadMask(aInput.vMaskCoords);
|
||||
return CalculateNV12Color(aInput.vTexCoords) * alpha;
|
||||
}
|
||||
|
||||
float4 TexturedQuadIdentityIMC4(const VS_SAMPLEOUTPUT_CLIPPED aInput) : SV_Target
|
||||
{
|
||||
float3 rgb = float3(
|
||||
tCr.Sample(sSampler, aInput.vTexCoords).r,
|
||||
tY.Sample(sSampler, aInput.vTexCoords).r,
|
||||
tCb.Sample(sSampler, aInput.vTexCoords).r);
|
||||
return float4(rgb * vCoefficient, 1.0) * sOpacity;
|
||||
}
|
||||
|
||||
float4 TexturedVertexIdentityIMC4(const VS_SAMPLEOUTPUT aInput) : SV_Target
|
||||
{
|
||||
if (!RectContainsPoint(aInput.vClipRect, aInput.vPosition.xy)) {
|
||||
return float4(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
float alpha = ReadMask(aInput.vMaskCoords);
|
||||
float3 rgb = float3(
|
||||
tCr.Sample(sSampler, aInput.vTexCoords).r,
|
||||
tY.Sample(sSampler, aInput.vTexCoords).r,
|
||||
tCb.Sample(sSampler, aInput.vTexCoords).r);
|
||||
return float4(rgb * vCoefficient, 1.0) * alpha;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,8 +188,10 @@ enum class PixelShaderID {
|
|||
TexturedVertexRGB,
|
||||
TexturedVertexRGBA,
|
||||
TexturedQuadIMC4,
|
||||
TexturedQuadIdentityIMC4,
|
||||
TexturedQuadNV12,
|
||||
TexturedVertexIMC4,
|
||||
TexturedVertexIdentityIMC4,
|
||||
TexturedVertexNV12,
|
||||
ComponentAlphaQuad,
|
||||
ComponentAlphaVertex,
|
||||
|
|
|
|||
|
|
@ -738,10 +738,17 @@ void VideoRenderPass::SetupPipeline() {
|
|||
|
||||
switch (mHost->GetReadFormat()) {
|
||||
case SurfaceFormat::YUV: {
|
||||
if (mGeometry == GeometryMode::UnitQuad)
|
||||
mDevice->SetPixelShader(PixelShaderID::TexturedQuadIMC4);
|
||||
else
|
||||
mDevice->SetPixelShader(PixelShaderID::TexturedVertexIMC4);
|
||||
if (colorSpace == YUVColorSpace::Identity) {
|
||||
if (mGeometry == GeometryMode::UnitQuad)
|
||||
mDevice->SetPixelShader(PixelShaderID::TexturedQuadIdentityIMC4);
|
||||
else
|
||||
mDevice->SetPixelShader(PixelShaderID::TexturedVertexIdentityIMC4);
|
||||
} else {
|
||||
if (mGeometry == GeometryMode::UnitQuad)
|
||||
mDevice->SetPixelShader(PixelShaderID::TexturedQuadIMC4);
|
||||
else
|
||||
mDevice->SetPixelShader(PixelShaderID::TexturedVertexIMC4);
|
||||
}
|
||||
mDevice->SetPSTexturesYUV(0, mTexture);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1103,6 +1103,10 @@ const float kBT2020NarrowYCbCrToRGB_RowMajor[16] = {
|
|||
1.16438f, 0.00000f, 1.67867f, -0.91569f, 1.16438f, -0.18733f,
|
||||
-0.65042f, 0.34746f, 1.16438f, 2.14177f, 0.00000f, -1.14815f,
|
||||
0.00000f, 0.00000f, 0.00000f, 1.00000f};
|
||||
const float kIdentityNarrowYCbCrToRGB_RowMajor[16] = {
|
||||
0.00000f, 0.00000f, 1.00000f, 0.00000f, 1.00000f, 0.00000f,
|
||||
0.00000f, 0.00000f, 0.00000f, 1.00000f, 0.00000f, 0.00000f,
|
||||
0.00000f, 0.00000f, 0.00000f, 1.00000f};
|
||||
|
||||
/* static */ const float* gfxUtils::YuvToRgbMatrix4x3RowMajor(
|
||||
gfx::YUVColorSpace aYUVColorSpace) {
|
||||
|
|
@ -1112,6 +1116,7 @@ const float kBT2020NarrowYCbCrToRGB_RowMajor[16] = {
|
|||
static const float rec601[12] = X(kBT601NarrowYCbCrToRGB_RowMajor);
|
||||
static const float rec709[12] = X(kBT709NarrowYCbCrToRGB_RowMajor);
|
||||
static const float rec2020[12] = X(kBT2020NarrowYCbCrToRGB_RowMajor);
|
||||
static const float identity[12] = X(kIdentityNarrowYCbCrToRGB_RowMajor);
|
||||
|
||||
#undef X
|
||||
|
||||
|
|
@ -1122,6 +1127,8 @@ const float kBT2020NarrowYCbCrToRGB_RowMajor[16] = {
|
|||
return rec709;
|
||||
case gfx::YUVColorSpace::BT2020:
|
||||
return rec2020;
|
||||
case gfx::YUVColorSpace::Identity:
|
||||
return identity;
|
||||
default: // YUVColorSpace::UNKNOWN
|
||||
MOZ_ASSERT(false, "unknown aYUVColorSpace");
|
||||
return rec601;
|
||||
|
|
@ -1136,6 +1143,7 @@ const float kBT2020NarrowYCbCrToRGB_RowMajor[16] = {
|
|||
static const float rec601[9] = X(kBT601NarrowYCbCrToRGB_RowMajor);
|
||||
static const float rec709[9] = X(kBT709NarrowYCbCrToRGB_RowMajor);
|
||||
static const float rec2020[9] = X(kBT2020NarrowYCbCrToRGB_RowMajor);
|
||||
static const float identity[9] = X(kIdentityNarrowYCbCrToRGB_RowMajor);
|
||||
|
||||
#undef X
|
||||
|
||||
|
|
@ -1146,6 +1154,8 @@ const float kBT2020NarrowYCbCrToRGB_RowMajor[16] = {
|
|||
return rec709;
|
||||
case YUVColorSpace::BT2020:
|
||||
return rec2020;
|
||||
case YUVColorSpace::Identity:
|
||||
return identity;
|
||||
default: // YUVColorSpace::UNKNOWN
|
||||
MOZ_ASSERT(false, "unknown aYUVColorSpace");
|
||||
return rec601;
|
||||
|
|
@ -1163,6 +1173,7 @@ const float kBT2020NarrowYCbCrToRGB_RowMajor[16] = {
|
|||
static const float rec601[16] = X(kBT601NarrowYCbCrToRGB_RowMajor);
|
||||
static const float rec709[16] = X(kBT709NarrowYCbCrToRGB_RowMajor);
|
||||
static const float rec2020[16] = X(kBT2020NarrowYCbCrToRGB_RowMajor);
|
||||
static const float identity[16] = X(kIdentityNarrowYCbCrToRGB_RowMajor);
|
||||
|
||||
#undef X
|
||||
|
||||
|
|
@ -1173,6 +1184,8 @@ const float kBT2020NarrowYCbCrToRGB_RowMajor[16] = {
|
|||
return rec709;
|
||||
case YUVColorSpace::BT2020:
|
||||
return rec2020;
|
||||
case YUVColorSpace::Identity:
|
||||
return identity;
|
||||
default: // YUVColorSpace::UNKNOWN
|
||||
MOZ_ASSERT(false, "unknown aYUVColorSpace");
|
||||
return rec601;
|
||||
|
|
|
|||
Loading…
Reference in a new issue