Commit 4aac6e02 authored by Jean-Yves Avenard's avatar Jean-Yves Avenard
Browse files

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
parent 98c585cf
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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);
+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@
   - TexturedVertexNV12
   - TexturedQuadIMC4
   - TexturedQuadNV12
   - TexturedVertexIdentityIMC4
   - TexturedQuadIdentityIMC4

- type: vs_4_0
  file: color-vs.hlsl
+23 −0
Original line number Diff line number Diff line
@@ -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;
}
+2 −0
Original line number Diff line number Diff line
@@ -188,8 +188,10 @@ enum class PixelShaderID {
  TexturedVertexRGB,
  TexturedVertexRGBA,
  TexturedQuadIMC4,
  TexturedQuadIdentityIMC4,
  TexturedQuadNV12,
  TexturedVertexIMC4,
  TexturedVertexIdentityIMC4,
  TexturedVertexNV12,
  ComponentAlphaQuad,
  ComponentAlphaVertex,
+11 −4
Original line number Diff line number Diff line
@@ -738,10 +738,17 @@ void VideoRenderPass::SetupPipeline() {

  switch (mHost->GetReadFormat()) {
    case SurfaceFormat::YUV: {
      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;
    }
Loading