Bug 1729076 - Remove unused mlgshaders. r=aosmond

Differential Revision: https://phabricator.services.mozilla.com/D124504
This commit is contained in:
Jeff Muizelaar 2021-09-03 23:20:48 +00:00
Родитель 2942d2a222
Коммит b79cfd62d3
27 изменённых файлов: 0 добавлений и 1557 удалений

Просмотреть файл

@ -1,15 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "common-vs.hlsl"
struct VS_BLEND_OUTPUT
{
float4 vPosition : SV_Position;
float2 vTexCoords : TEXCOORD0;
float2 vBackdropCoords : TEXCOORD1;
float2 vLocalPos : TEXCOORD2;
float3 vMaskCoords : TEXCOORD3;
nointerpolation float4 vClipRect : TEXCOORD4;
};

Просмотреть файл

@ -1,540 +0,0 @@
float4 BlendMultiplyPS(const VS_BLEND_OUTPUT aInput) : SV_Target
{
if (!RectContainsPoint(aInput.vClipRect, aInput.vPosition.xy)) {
discard;
}
float4 backdrop = tBackdrop.Sample(sSampler, aInput.vBackdropCoords);
float4 source = simpleTex.Sample(sSampler, aInput.vTexCoords);
source *= ReadMask(aInput.vMaskCoords);
// Shortcut when the backdrop or source alpha is 0, otherwise we may leak
// infinity into the blend function and return incorrect results.
if (backdrop.a == 0.0) {
return source;
}
if (source.a == 0.0) {
return float4(0, 0, 0, 0);
}
// The spec assumes there is no premultiplied alpha. The backdrop and
// source are both render targets and always premultiplied, so we undo
// that here.
backdrop.rgb /= backdrop.a;
source.rgb /= source.a;
float4 result;
result.rgb = BlendMultiply(backdrop.rgb, source.rgb);
result.a = source.a;
// Factor backdrop alpha, then premultiply for the final OP_OVER.
result.rgb = (1.0 - backdrop.a) * source.rgb + backdrop.a * result.rgb;
result.rgb *= result.a;
return result;
}
float4 BlendScreenPS(const VS_BLEND_OUTPUT aInput) : SV_Target
{
if (!RectContainsPoint(aInput.vClipRect, aInput.vPosition.xy)) {
discard;
}
float4 backdrop = tBackdrop.Sample(sSampler, aInput.vBackdropCoords);
float4 source = simpleTex.Sample(sSampler, aInput.vTexCoords);
source *= ReadMask(aInput.vMaskCoords);
// Shortcut when the backdrop or source alpha is 0, otherwise we may leak
// infinity into the blend function and return incorrect results.
if (backdrop.a == 0.0) {
return source;
}
if (source.a == 0.0) {
return float4(0, 0, 0, 0);
}
// The spec assumes there is no premultiplied alpha. The backdrop and
// source are both render targets and always premultiplied, so we undo
// that here.
backdrop.rgb /= backdrop.a;
source.rgb /= source.a;
float4 result;
result.rgb = BlendScreen(backdrop.rgb, source.rgb);
result.a = source.a;
// Factor backdrop alpha, then premultiply for the final OP_OVER.
result.rgb = (1.0 - backdrop.a) * source.rgb + backdrop.a * result.rgb;
result.rgb *= result.a;
return result;
}
float4 BlendOverlayPS(const VS_BLEND_OUTPUT aInput) : SV_Target
{
if (!RectContainsPoint(aInput.vClipRect, aInput.vPosition.xy)) {
discard;
}
float4 backdrop = tBackdrop.Sample(sSampler, aInput.vBackdropCoords);
float4 source = simpleTex.Sample(sSampler, aInput.vTexCoords);
source *= ReadMask(aInput.vMaskCoords);
// Shortcut when the backdrop or source alpha is 0, otherwise we may leak
// infinity into the blend function and return incorrect results.
if (backdrop.a == 0.0) {
return source;
}
if (source.a == 0.0) {
return float4(0, 0, 0, 0);
}
// The spec assumes there is no premultiplied alpha. The backdrop and
// source are both render targets and always premultiplied, so we undo
// that here.
backdrop.rgb /= backdrop.a;
source.rgb /= source.a;
float4 result;
result.rgb = BlendOverlay(backdrop.rgb, source.rgb);
result.a = source.a;
// Factor backdrop alpha, then premultiply for the final OP_OVER.
result.rgb = (1.0 - backdrop.a) * source.rgb + backdrop.a * result.rgb;
result.rgb *= result.a;
return result;
}
float4 BlendDarkenPS(const VS_BLEND_OUTPUT aInput) : SV_Target
{
if (!RectContainsPoint(aInput.vClipRect, aInput.vPosition.xy)) {
discard;
}
float4 backdrop = tBackdrop.Sample(sSampler, aInput.vBackdropCoords);
float4 source = simpleTex.Sample(sSampler, aInput.vTexCoords);
source *= ReadMask(aInput.vMaskCoords);
// Shortcut when the backdrop or source alpha is 0, otherwise we may leak
// infinity into the blend function and return incorrect results.
if (backdrop.a == 0.0) {
return source;
}
if (source.a == 0.0) {
return float4(0, 0, 0, 0);
}
// The spec assumes there is no premultiplied alpha. The backdrop and
// source are both render targets and always premultiplied, so we undo
// that here.
backdrop.rgb /= backdrop.a;
source.rgb /= source.a;
float4 result;
result.rgb = BlendDarken(backdrop.rgb, source.rgb);
result.a = source.a;
// Factor backdrop alpha, then premultiply for the final OP_OVER.
result.rgb = (1.0 - backdrop.a) * source.rgb + backdrop.a * result.rgb;
result.rgb *= result.a;
return result;
}
float4 BlendLightenPS(const VS_BLEND_OUTPUT aInput) : SV_Target
{
if (!RectContainsPoint(aInput.vClipRect, aInput.vPosition.xy)) {
discard;
}
float4 backdrop = tBackdrop.Sample(sSampler, aInput.vBackdropCoords);
float4 source = simpleTex.Sample(sSampler, aInput.vTexCoords);
source *= ReadMask(aInput.vMaskCoords);
// Shortcut when the backdrop or source alpha is 0, otherwise we may leak
// infinity into the blend function and return incorrect results.
if (backdrop.a == 0.0) {
return source;
}
if (source.a == 0.0) {
return float4(0, 0, 0, 0);
}
// The spec assumes there is no premultiplied alpha. The backdrop and
// source are both render targets and always premultiplied, so we undo
// that here.
backdrop.rgb /= backdrop.a;
source.rgb /= source.a;
float4 result;
result.rgb = BlendLighten(backdrop.rgb, source.rgb);
result.a = source.a;
// Factor backdrop alpha, then premultiply for the final OP_OVER.
result.rgb = (1.0 - backdrop.a) * source.rgb + backdrop.a * result.rgb;
result.rgb *= result.a;
return result;
}
float4 BlendColorDodgePS(const VS_BLEND_OUTPUT aInput) : SV_Target
{
if (!RectContainsPoint(aInput.vClipRect, aInput.vPosition.xy)) {
discard;
}
float4 backdrop = tBackdrop.Sample(sSampler, aInput.vBackdropCoords);
float4 source = simpleTex.Sample(sSampler, aInput.vTexCoords);
source *= ReadMask(aInput.vMaskCoords);
// Shortcut when the backdrop or source alpha is 0, otherwise we may leak
// infinity into the blend function and return incorrect results.
if (backdrop.a == 0.0) {
return source;
}
if (source.a == 0.0) {
return float4(0, 0, 0, 0);
}
// The spec assumes there is no premultiplied alpha. The backdrop and
// source are both render targets and always premultiplied, so we undo
// that here.
backdrop.rgb /= backdrop.a;
source.rgb /= source.a;
float4 result;
result.rgb = BlendColorDodge(backdrop.rgb, source.rgb);
result.a = source.a;
// Factor backdrop alpha, then premultiply for the final OP_OVER.
result.rgb = (1.0 - backdrop.a) * source.rgb + backdrop.a * result.rgb;
result.rgb *= result.a;
return result;
}
float4 BlendColorBurnPS(const VS_BLEND_OUTPUT aInput) : SV_Target
{
if (!RectContainsPoint(aInput.vClipRect, aInput.vPosition.xy)) {
discard;
}
float4 backdrop = tBackdrop.Sample(sSampler, aInput.vBackdropCoords);
float4 source = simpleTex.Sample(sSampler, aInput.vTexCoords);
source *= ReadMask(aInput.vMaskCoords);
// Shortcut when the backdrop or source alpha is 0, otherwise we may leak
// infinity into the blend function and return incorrect results.
if (backdrop.a == 0.0) {
return source;
}
if (source.a == 0.0) {
return float4(0, 0, 0, 0);
}
// The spec assumes there is no premultiplied alpha. The backdrop and
// source are both render targets and always premultiplied, so we undo
// that here.
backdrop.rgb /= backdrop.a;
source.rgb /= source.a;
float4 result;
result.rgb = BlendColorBurn(backdrop.rgb, source.rgb);
result.a = source.a;
// Factor backdrop alpha, then premultiply for the final OP_OVER.
result.rgb = (1.0 - backdrop.a) * source.rgb + backdrop.a * result.rgb;
result.rgb *= result.a;
return result;
}
float4 BlendHardLightPS(const VS_BLEND_OUTPUT aInput) : SV_Target
{
if (!RectContainsPoint(aInput.vClipRect, aInput.vPosition.xy)) {
discard;
}
float4 backdrop = tBackdrop.Sample(sSampler, aInput.vBackdropCoords);
float4 source = simpleTex.Sample(sSampler, aInput.vTexCoords);
source *= sOpacity;
// Shortcut when the backdrop or source alpha is 0, otherwise we may leak
// infinity into the blend function and return incorrect results.
if (backdrop.a == 0.0) {
return source;
}
if (source.a == 0.0) {
return float4(0, 0, 0, 0);
}
// The spec assumes there is no premultiplied alpha. The backdrop and
// source are both render targets and always premultiplied, so we undo
// that here.
backdrop.rgb /= backdrop.a;
source.rgb /= source.a;
float4 result;
result.rgb = BlendHardLight(backdrop.rgb, source.rgb);
result.a = source.a;
// Factor backdrop alpha, then premultiply for the final OP_OVER.
result.rgb = (1.0 - backdrop.a) * source.rgb + backdrop.a * result.rgb;
result.rgb *= result.a;
return result;
}
float4 BlendSoftLightPS(const VS_BLEND_OUTPUT aInput) : SV_Target
{
if (!RectContainsPoint(aInput.vClipRect, aInput.vPosition.xy)) {
discard;
}
float4 backdrop = tBackdrop.Sample(sSampler, aInput.vBackdropCoords);
float4 source = simpleTex.Sample(sSampler, aInput.vTexCoords);
source *= ReadMask(aInput.vMaskCoords);
// Shortcut when the backdrop or source alpha is 0, otherwise we may leak
// infinity into the blend function and return incorrect results.
if (backdrop.a == 0.0) {
return source;
}
if (source.a == 0.0) {
return float4(0, 0, 0, 0);
}
// The spec assumes there is no premultiplied alpha. The backdrop and
// source are both render targets and always premultiplied, so we undo
// that here.
backdrop.rgb /= backdrop.a;
source.rgb /= source.a;
float4 result;
result.rgb = BlendSoftLight(backdrop.rgb, source.rgb);
result.a = source.a;
// Factor backdrop alpha, then premultiply for the final OP_OVER.
result.rgb = (1.0 - backdrop.a) * source.rgb + backdrop.a * result.rgb;
result.rgb *= result.a;
return result;
}
float4 BlendDifferencePS(const VS_BLEND_OUTPUT aInput) : SV_Target
{
if (!RectContainsPoint(aInput.vClipRect, aInput.vPosition.xy)) {
discard;
}
float4 backdrop = tBackdrop.Sample(sSampler, aInput.vBackdropCoords);
float4 source = simpleTex.Sample(sSampler, aInput.vTexCoords);
source *= ReadMask(aInput.vMaskCoords);
// Shortcut when the backdrop or source alpha is 0, otherwise we may leak
// infinity into the blend function and return incorrect results.
if (backdrop.a == 0.0) {
return source;
}
if (source.a == 0.0) {
return float4(0, 0, 0, 0);
}
// The spec assumes there is no premultiplied alpha. The backdrop and
// source are both render targets and always premultiplied, so we undo
// that here.
backdrop.rgb /= backdrop.a;
source.rgb /= source.a;
float4 result;
result.rgb = BlendDifference(backdrop.rgb, source.rgb);
result.a = source.a;
// Factor backdrop alpha, then premultiply for the final OP_OVER.
result.rgb = (1.0 - backdrop.a) * source.rgb + backdrop.a * result.rgb;
result.rgb *= result.a;
return result;
}
float4 BlendExclusionPS(const VS_BLEND_OUTPUT aInput) : SV_Target
{
if (!RectContainsPoint(aInput.vClipRect, aInput.vPosition.xy)) {
discard;
}
float4 backdrop = tBackdrop.Sample(sSampler, aInput.vBackdropCoords);
float4 source = simpleTex.Sample(sSampler, aInput.vTexCoords);
source *= ReadMask(aInput.vMaskCoords);
// Shortcut when the backdrop or source alpha is 0, otherwise we may leak
// infinity into the blend function and return incorrect results.
if (backdrop.a == 0.0) {
return source;
}
if (source.a == 0.0) {
return float4(0, 0, 0, 0);
}
// The spec assumes there is no premultiplied alpha. The backdrop and
// source are both render targets and always premultiplied, so we undo
// that here.
backdrop.rgb /= backdrop.a;
source.rgb /= source.a;
float4 result;
result.rgb = BlendExclusion(backdrop.rgb, source.rgb);
result.a = source.a;
// Factor backdrop alpha, then premultiply for the final OP_OVER.
result.rgb = (1.0 - backdrop.a) * source.rgb + backdrop.a * result.rgb;
result.rgb *= result.a;
return result;
}
float4 BlendHuePS(const VS_BLEND_OUTPUT aInput) : SV_Target
{
if (!RectContainsPoint(aInput.vClipRect, aInput.vPosition.xy)) {
discard;
}
float4 backdrop = tBackdrop.Sample(sSampler, aInput.vBackdropCoords);
float4 source = simpleTex.Sample(sSampler, aInput.vTexCoords);
source *= ReadMask(aInput.vMaskCoords);
// Shortcut when the backdrop or source alpha is 0, otherwise we may leak
// infinity into the blend function and return incorrect results.
if (backdrop.a == 0.0) {
return source;
}
if (source.a == 0.0) {
return float4(0, 0, 0, 0);
}
// The spec assumes there is no premultiplied alpha. The backdrop and
// source are both render targets and always premultiplied, so we undo
// that here.
backdrop.rgb /= backdrop.a;
source.rgb /= source.a;
float4 result;
result.rgb = BlendHue(backdrop.rgb, source.rgb);
result.a = source.a;
// Factor backdrop alpha, then premultiply for the final OP_OVER.
result.rgb = (1.0 - backdrop.a) * source.rgb + backdrop.a * result.rgb;
result.rgb *= result.a;
return result;
}
float4 BlendSaturationPS(const VS_BLEND_OUTPUT aInput) : SV_Target
{
if (!RectContainsPoint(aInput.vClipRect, aInput.vPosition.xy)) {
discard;
}
float4 backdrop = tBackdrop.Sample(sSampler, aInput.vBackdropCoords);
float4 source = simpleTex.Sample(sSampler, aInput.vTexCoords);
source *= ReadMask(aInput.vMaskCoords);
// Shortcut when the backdrop or source alpha is 0, otherwise we may leak
// infinity into the blend function and return incorrect results.
if (backdrop.a == 0.0) {
return source;
}
if (source.a == 0.0) {
return float4(0, 0, 0, 0);
}
// The spec assumes there is no premultiplied alpha. The backdrop and
// source are both render targets and always premultiplied, so we undo
// that here.
backdrop.rgb /= backdrop.a;
source.rgb /= source.a;
float4 result;
result.rgb = BlendSaturation(backdrop.rgb, source.rgb);
result.a = source.a;
// Factor backdrop alpha, then premultiply for the final OP_OVER.
result.rgb = (1.0 - backdrop.a) * source.rgb + backdrop.a * result.rgb;
result.rgb *= result.a;
return result;
}
float4 BlendColorPS(const VS_BLEND_OUTPUT aInput) : SV_Target
{
if (!RectContainsPoint(aInput.vClipRect, aInput.vPosition.xy)) {
discard;
}
float4 backdrop = tBackdrop.Sample(sSampler, aInput.vBackdropCoords);
float4 source = simpleTex.Sample(sSampler, aInput.vTexCoords);
source *= ReadMask(aInput.vMaskCoords);
// Shortcut when the backdrop or source alpha is 0, otherwise we may leak
// infinity into the blend function and return incorrect results.
if (backdrop.a == 0.0) {
return source;
}
if (source.a == 0.0) {
return float4(0, 0, 0, 0);
}
// The spec assumes there is no premultiplied alpha. The backdrop and
// source are both render targets and always premultiplied, so we undo
// that here.
backdrop.rgb /= backdrop.a;
source.rgb /= source.a;
float4 result;
result.rgb = BlendColor(backdrop.rgb, source.rgb);
result.a = source.a;
// Factor backdrop alpha, then premultiply for the final OP_OVER.
result.rgb = (1.0 - backdrop.a) * source.rgb + backdrop.a * result.rgb;
result.rgb *= result.a;
return result;
}
float4 BlendLuminosityPS(const VS_BLEND_OUTPUT aInput) : SV_Target
{
if (!RectContainsPoint(aInput.vClipRect, aInput.vPosition.xy)) {
discard;
}
float4 backdrop = tBackdrop.Sample(sSampler, aInput.vBackdropCoords);
float4 source = simpleTex.Sample(sSampler, aInput.vTexCoords);
source *= ReadMask(aInput.vMaskCoords);
// Shortcut when the backdrop or source alpha is 0, otherwise we may leak
// infinity into the blend function and return incorrect results.
if (backdrop.a == 0.0) {
return source;
}
if (source.a == 0.0) {
return float4(0, 0, 0, 0);
}
// The spec assumes there is no premultiplied alpha. The backdrop and
// source are both render targets and always premultiplied, so we undo
// that here.
backdrop.rgb /= backdrop.a;
source.rgb /= source.a;
float4 result;
result.rgb = BlendLuminosity(backdrop.rgb, source.rgb);
result.a = source.a;
// Factor backdrop alpha, then premultiply for the final OP_OVER.
result.rgb = (1.0 - backdrop.a) * source.rgb + backdrop.a * result.rgb;
result.rgb *= result.a;
return result;
}

Просмотреть файл

@ -1,36 +0,0 @@
float4 Blend{BLEND_FUNC}PS(const VS_BLEND_OUTPUT aInput) : SV_Target
{
if (!RectContainsPoint(aInput.vClipRect, aInput.vPosition.xy)) {
discard;
}
float4 backdrop = tBackdrop.Sample(sSampler, aInput.vBackdropCoords);
float4 source = simpleTex.Sample(sSampler, aInput.vTexCoords);
// Apply masks to the source texture, not the result.
source *= ReadMask(aInput.vMaskCoords);
// Shortcut when the backdrop or source alpha is 0, otherwise we may leak
// infinity into the blend function and return incorrect results.
if (backdrop.a == 0.0) {
return source;
}
if (source.a == 0.0) {
return float4(0, 0, 0, 0);
}
// The spec assumes there is no premultiplied alpha. The backdrop and
// source are both render targets and always premultiplied, so we undo
// that here.
backdrop.rgb /= backdrop.a;
source.rgb /= source.a;
float4 result;
result.rgb = Blend{BLEND_FUNC}(backdrop.rgb, source.rgb);
result.a = source.a;
// Factor backdrop alpha, then premultiply for the final OP_OVER.
result.rgb = (1.0 - backdrop.a) * source.rgb + backdrop.a * result.rgb;
result.rgb *= result.a;
return result;
}

Просмотреть файл

@ -1,13 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "common.hlsl"
#include "common-ps.hlsl"
#include "blend-common.hlsl"
#include "../BlendingHelpers.hlslh"
Texture2D simpleTex : register(ps, t0);
Texture2D tBackdrop : register(ps, t1);
#include "blend-ps-generated.hlslh"

Просмотреть файл

@ -1,52 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "common-vs.hlsl"
#include "blend-common.hlsl"
#include "textured-common.hlsl"
cbuffer BlendConstants : register(b4)
{
float4x4 mBackdropTransform;
}
float2 BackdropPosition(float4 aPosition)
{
// Move the position from clip space (-1,1) into 0..1 space.
float2 pos;
pos.x = (aPosition.x + 1.0) / 2.0;
pos.y = 1.0 - (aPosition.y + 1.0) / 2.0;
return mul(mBackdropTransform, float4(pos.xy, 0, 1.0)).xy;
}
VS_BLEND_OUTPUT BlendImpl(const VertexInfo aInfo, float2 aTexCoord)
{
VS_BLEND_OUTPUT output;
output.vPosition = aInfo.worldPos;
output.vTexCoords = aTexCoord;
output.vBackdropCoords = BackdropPosition(output.vPosition);
output.vLocalPos = aInfo.screenPos;
output.vClipRect = aInfo.clipRect;
output.vMaskCoords = aInfo.maskCoords;
return output;
}
VS_BLEND_OUTPUT BlendVertexVS(const VS_TEXTUREDVERTEX aVertex)
{
float2 layerPos = UnitTriangleToPos(
aVertex.vUnitPos,
aVertex.vPos1,
aVertex.vPos2,
aVertex.vPos3);
float2 texCoord = UnitTriangleToPos(
aVertex.vUnitPos,
aVertex.vTexCoord1,
aVertex.vTexCoord2,
aVertex.vTexCoord3);
VertexInfo info = ComputePosition(layerPos, aVertex.vLayerId, aVertex.vDepth);
return BlendImpl(info, texCoord);
}

Просмотреть файл

@ -1,9 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
struct VS_CLEAR_OUT
{
float4 vPosition : SV_Position;
};

Просмотреть файл

@ -1,12 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "common-ps.hlsl"
#include "clear-common.hlsl"
float4 ClearPS(const VS_CLEAR_OUT aVS) : SV_Target
{
return float4(0.0, 0.0, 0.0, 0.0);
}

Просмотреть файл

@ -1,30 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "common-vs.hlsl"
#include "clear-common.hlsl"
struct VS_CLEAR_IN
{
float2 vPos : POSITION;
int4 vRect : TEXCOORD0;
};
// Note: we use slot 2 so we don't have to rebind the layer slot (1) to run
// this shader.
cbuffer ClearConstants : register(b2) {
int sDepth : packoffset(c0.x);
};
VS_CLEAR_OUT ClearVS(const VS_CLEAR_IN aInput)
{
float4 rect = float4(aInput.vRect.x, aInput.vRect.y, aInput.vRect.z, aInput.vRect.w);
float4 screenPos = float4(UnitQuadToRect(aInput.vPos, rect), 0, 1);
float4 worldPos = mul(WorldTransform, screenPos);
worldPos.z = ComputeDepth(worldPos, sDepth);
VS_CLEAR_OUT output;
output.vPosition = worldPos;
return output;
}

Просмотреть файл

@ -1,19 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
struct VS_COLOROUTPUT
{
nointerpolation float4 vColor : COLOR0;
nointerpolation float4 vClipRect : TEXCOORD0;
float4 vPosition : SV_Position;
float2 vLocalPos : TEXCOORD1;
float3 vMaskCoords : TEXCOORD2;
};
struct VS_COLOROUTPUT_CLIPPED
{
float4 vPosition : SV_Position;
nointerpolation float4 vColor : COLOR0;
};

Просмотреть файл

@ -1,20 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "common-ps.hlsl"
#include "color-common.hlsl"
float4 ColoredQuadPS(const VS_COLOROUTPUT_CLIPPED aVS) : SV_Target
{
// Opacity is always 1.0, we premultiply it on the CPU.
return aVS.vColor;
}
float4 ColoredVertexPS(const VS_COLOROUTPUT aVS) : SV_Target
{
if (!RectContainsPoint(aVS.vClipRect, aVS.vPosition.xy)) {
return float4(0, 0, 0, 0);
}
return aVS.vColor * ReadMaskWithOpacity(aVS.vMaskCoords, 1.0);
}

Просмотреть файл

@ -1,58 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "common-vs.hlsl"
#include "color-common.hlsl"
struct VS_COLORQUAD
{
float2 vPos : POSITION;
float4 vRect : TEXCOORD0;
uint vLayerId : TEXCOORD1;
int vDepth : TEXCOORD2;
float4 vColor : TEXCOORD3;
};
struct VS_COLORVERTEX
{
float3 vUnitPos : POSITION0;
float2 vPos1 : POSITION1;
float2 vPos2 : POSITION2;
float2 vPos3 : POSITION3;
uint vLayerId : TEXCOORD0;
int vDepth : TEXCOORD1;
float4 vColor : TEXCOORD2;
};
VS_COLOROUTPUT ColorImpl(float4 aColor, const VertexInfo aInfo)
{
VS_COLOROUTPUT output;
output.vPosition = aInfo.worldPos;
output.vLocalPos = aInfo.screenPos;
output.vColor = aColor;
output.vClipRect = aInfo.clipRect;
output.vMaskCoords = aInfo.maskCoords;
return output;
}
VS_COLOROUTPUT_CLIPPED ColoredQuadVS(const VS_COLORQUAD aInput)
{
float4 worldPos = ComputeClippedPosition(
aInput.vPos,
aInput.vRect,
aInput.vLayerId,
aInput.vDepth);
VS_COLOROUTPUT_CLIPPED output;
output.vPosition = worldPos;
output.vColor = aInput.vColor;
return output;
}
VS_COLOROUTPUT ColoredVertexVS(const VS_COLORVERTEX aInput)
{
float2 layerPos = UnitTriangleToPos(aInput.vUnitPos, aInput.vPos1, aInput.vPos2, aInput.vPos3);
VertexInfo info = ComputePosition(layerPos, aInput.vLayerId, aInput.vDepth);
return ColorImpl(aInput.vColor, info);
}

Просмотреть файл

@ -1,37 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "common.hlsl"
sampler sSampler : register(ps, s0);
sampler sMaskSampler : register(ps, s1);
Texture2D tMaskTexture : register(ps, t4);
cbuffer MaskInformation : register(b0)
{
float sOpacity : packoffset(c0.x);
uint sHasMask : packoffset(c0.y);
};
float2 MaskCoordsToUV(float3 aMaskCoords)
{
return aMaskCoords.xy / aMaskCoords.z;
}
float ReadMaskWithOpacity(float3 aMaskCoords, float aOpacity)
{
if (!sHasMask) {
return aOpacity;
}
float2 uv = MaskCoordsToUV(aMaskCoords);
float r = tMaskTexture.Sample(sMaskSampler, uv).r;
return min(aOpacity, r);
}
float ReadMask(float3 aMaskCoords)
{
return ReadMaskWithOpacity(aMaskCoords, sOpacity);
}

Просмотреть файл

@ -1,167 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_gfx_layers_d3d11_mlgshaders_common_vs_hlsl
#define mozilla_gfx_layers_d3d11_mlgshaders_common_vs_hlsl
#include "common.hlsl"
cbuffer VSBufSimple : register(b0)
{
float4x4 WorldTransform;
float2 RenderTargetOffset;
int SortIndexOffset;
uint DebugFrameNumber;
};
struct Layer {
float4x4 transform;
float4 clipRect;
uint4 info;
};
cbuffer Layers : register(b1)
{
Layer sLayers[682];
};
cbuffer MaskRects : register(b3)
{
float4 sMaskRects[4096];
};
struct VertexInfo {
float4 worldPos;
float2 screenPos;
float3 maskCoords;
float4 clipRect;
};
float3 ComputeMaskCoords(float4 aPosition, Layer aLayer)
{
if (aLayer.info.x == 0) {
return float3(0.0, 0.0, 0.0);
}
float4 maskRect = sMaskRects[aLayer.info.x - 1];
// See the perspective comment in CompositorD3D11.hlsl.
float4x4 transform = float4x4(
1.0/maskRect.z, 0.0, 0.0, -maskRect.x/maskRect.z,
0.0, 1.0/maskRect.w, 0.0, -maskRect.y/maskRect.w,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0);
return float3(mul(transform, aPosition / aPosition.w).xy, 1.0) * aPosition.w;
}
float2 UnitTriangleToPos(const float3 aVertex,
const float2 aPos1,
const float2 aPos2,
const float2 aPos3)
{
return aVertex.x * aPos1 +
aVertex.y * aPos2 +
aVertex.z * aPos3;
}
float2 UnitQuadToRect(const float2 aVertex, const float4 aRect)
{
return float2(aRect.x + aVertex.x * aRect.z, aRect.y + aVertex.y * aRect.w);
}
float ComputeDepth(float4 aPosition, float aSortIndex)
{
// Note: this value should match ShaderDefinitionsMLGPU.h.
return ((aSortIndex + SortIndexOffset) / 1000000.0f) * aPosition.w;
}
// Compute the world-space, screen-space, layer-space clip, and mask
// uv-coordinates given a layer-space vertex, id, and z-index.
VertexInfo ComputePosition(float2 aVertex, uint aLayerId, float aSortIndex)
{
Layer layer = sLayers[aLayerId];
// Translate from unit vertex to layer quad vertex.
float4 clipRect = layer.clipRect;
// Transform to screen coordinates.
float4x4 transform = layer.transform;
float4 layerPos = mul(transform, float4(aVertex, 0, 1));
float4 position = layerPos;
position.xyz /= position.w;
position.xy -= RenderTargetOffset.xy;
position.xyz *= position.w;
float4 worldPos = mul(WorldTransform, position);
// Depth must be computed after the world transform, since we don't want
// 3d transforms clobbering the z-value. We assume a viewport culling
// everything outside of [0, 1). Note that when depth-testing, we do not
// use sorting indices < 1.
//
// Note that we have to normalize this value to w=1, since the GPU will
// divide all values by w internally.
worldPos.z = ComputeDepth(worldPos, aSortIndex);
VertexInfo info;
info.screenPos = position.xy;
info.worldPos = worldPos;
info.maskCoords = ComputeMaskCoords(layerPos, layer);
info.clipRect = clipRect;
return info;
}
// This function takes a unit quad position and a layer rectangle, and computes
// a clipped draw rect. It is only valid to use this function for layers with
// rectilinear transforms that do not have masks.
float4 ComputeClippedPosition(const float2 aVertex,
const float4 aRect,
uint aLayerId,
float aDepth)
{
Layer layer = sLayers[aLayerId];
float4 position = float4(UnitQuadToRect(aVertex, aRect), 0, 1);
float4x4 transform = layer.transform;
float4 clipRect = layer.clipRect;
// Transform to screen coordinates.
//
// We clamp the draw rect to the clip. This lets us use faster shaders.
// For opaque shapes, it is necessary to do this anyway since we might
// otherwrite write transparent pixels in the pixel which would also be
// written to the depth buffer. We cannot use discard in the pixel shader
// as this would break early-z tests.
//
// Note that for some shaders, like textured shaders, it is not valid to
// change the draw rect like this without also clamping the texture
// coordinates. We take care to adjust for this in our batching code.
//
// We do not need to do this for 3D transforms since we always treat those
// as transparent (they are not written to the depth buffer). 3D items
// will always use the full clip+masking shader.
position = mul(transform, position);
position.xyz /= position.w;
position.xy -= RenderTargetOffset.xy;
position.xy = clamp(position.xy, clipRect.xy, clipRect.xy + clipRect.zw);
position.xyz *= position.w;
float4 worldPos = mul(WorldTransform, position);
// Depth must be computed after the world transform, since we don't want
// 3d transforms clobbering the z-value. We assume a viewport culling
// everything outside of [0, 1). Note that when depth-testing, we do not
// use sorting indices < 1.
//
// Note that we have to normalize this value to w=1, since the GPU will
// divide all values by w internally.
worldPos.z = ComputeDepth(worldPos, aDepth);
return worldPos;
}
#endif // mozilla_gfx_layers_d3d11_mlgshaders_common_vs_hlsl

Просмотреть файл

@ -1,17 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_gfx_layers_d3d11_mlgshaders_common_hlsl
#define mozilla_gfx_layers_d3d11_mlgshaders_common_hlsl
bool RectContainsPoint(float4 aRect, float2 aPoint)
{
return aPoint.x >= aRect.x &&
aPoint.y >= aRect.y &&
aPoint.x <= (aRect.x + aRect.z) &&
aPoint.y <= (aRect.y + aRect.w);
}
#endif // mozilla_gfx_layers_d3d11_mlgshaders_common_hlsl

Просмотреть файл

@ -1,45 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "common.hlsl"
#include "common-ps.hlsl"
#include "textured-common.hlsl"
Texture2D texOnBlack : register(ps, t0);
Texture2D texOnWhite : register(ps, t1);
struct PS_OUTPUT {
float4 vSrc;
float4 vAlpha;
};
PS_OUTPUT ComponentAlphaQuadPS(const VS_SAMPLEOUTPUT_CLIPPED aInput) : SV_Target
{
PS_OUTPUT result;
result.vSrc = texOnBlack.Sample(sSampler, aInput.vTexCoords);
result.vAlpha = 1.0 - texOnWhite.Sample(sSampler, aInput.vTexCoords) + result.vSrc;
result.vSrc.a = result.vAlpha.g;
result.vSrc *= sOpacity;
result.vAlpha *= sOpacity;
return result;
}
PS_OUTPUT ComponentAlphaVertexPS(const VS_SAMPLEOUTPUT aInput) : SV_Target
{
PS_OUTPUT result;
if (!RectContainsPoint(aInput.vClipRect, aInput.vPosition.xy)) {
result.vSrc = float4(0, 0, 0, 0);
result.vAlpha = float4(0, 0, 0, 0);
return result;
}
float alpha = ReadMask(aInput.vMaskCoords);
result.vSrc = texOnBlack.Sample(sSampler, aInput.vTexCoords);
result.vAlpha = 1.0 - texOnWhite.Sample(sSampler, aInput.vTexCoords) + result.vSrc;
result.vSrc.a = result.vAlpha.g;
result.vSrc *= alpha;
result.vAlpha *= alpha;
return result;
}

Просмотреть файл

@ -1,10 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
struct VS_DIAGOUTPUT
{
float4 vPosition : SV_Position;
float2 vTexCoord : TEXCOORD0;
};

Просмотреть файл

@ -1,13 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "common-ps.hlsl"
#include "diagnostics-common.hlsl"
Texture2D sTexture: register(ps, t0);
float4 DiagnosticTextPS(const VS_DIAGOUTPUT aInput) : SV_Target
{
return sTexture.Sample(sSampler, aInput.vTexCoord);
}

Просмотреть файл

@ -1,25 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "common-vs.hlsl"
#include "textured-common.hlsl"
#include "diagnostics-common.hlsl"
struct VS_DIAGINPUT
{
float2 vPos : POSITION;
float4 vRect : TEXCOORD0;
float4 vTexCoords : TEXCOORD1;
};
VS_DIAGOUTPUT DiagnosticTextVS(const VS_DIAGINPUT aInput)
{
float2 pos = UnitQuadToRect(aInput.vPos, aInput.vRect);
float2 texCoord = UnitQuadToRect(aInput.vPos, aInput.vTexCoords);
VS_DIAGOUTPUT output;
output.vPosition = mul(WorldTransform, float4(pos, 0, 1));
output.vTexCoord = texCoord;
return output;
}

Просмотреть файл

@ -1,10 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
struct VS_MASKOUTPUT
{
float4 vPosition : SV_Position;
float2 vTexCoords : TEXCOORD0;
};

Просмотреть файл

@ -1,16 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "common.hlsl"
#include "mask-combiner-common.hlsl"
sampler sSampler;
Texture2D tMaskTexture : register(ps, t0);
float4 MaskCombinerPS(VS_MASKOUTPUT aInput) : SV_Target
{
float4 value = tMaskTexture.Sample(sSampler, aInput.vTexCoords);
return float4(value.r, 0, 0, value.r);
}

Просмотреть файл

@ -1,26 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "common-vs.hlsl"
#include "mask-combiner-common.hlsl"
struct VS_MASKINPUT
{
// Note, the input is
float2 vPos : POSITION;
float4 vTexCoords : POSITION1;
};
VS_MASKOUTPUT MaskCombinerVS(VS_MASKINPUT aInput)
{
float4 position = float4(
aInput.vPos.x * 2.0f - 1.0f,
1.0f - (aInput.vPos.y * 2.0f),
0, 1);
VS_MASKOUTPUT output;
output.vPosition = position;
output.vTexCoords = UnitQuadToRect(aInput.vPos, aInput.vTexCoords);
return output;
}

Просмотреть файл

@ -1,100 +0,0 @@
- type: vs_4_0
file: textured-vs.hlsl
shaders:
- TexturedQuadVS
- TexturedVertexVS
- type: ps_4_0
file: textured-ps.hlsl
shaders:
- TexturedVertexRGB
- TexturedVertexRGBA
- TexturedQuadRGB
- TexturedQuadRGBA
- type: ps_4_0
file: ycbcr-ps.hlsl
shaders:
- TexturedVertexIMC4
- TexturedVertexNV12
- TexturedQuadIMC4
- TexturedQuadNV12
- TexturedVertexIdentityIMC4
- TexturedQuadIdentityIMC4
- type: vs_4_0
file: color-vs.hlsl
shaders:
- ColoredQuadVS
- ColoredVertexVS
- type: ps_4_0
file: color-ps.hlsl
shaders:
- ColoredQuadPS
- ColoredVertexPS
- type: ps_4_0
file: component-alpha-ps.hlsl
shaders:
- ComponentAlphaQuadPS
- ComponentAlphaVertexPS
- type: vs_4_0
file: blend-vs.hlsl
shaders:
- BlendVertexVS
- type: ps_4_0
file: blend-ps.hlsl
shaders:
- BlendMultiplyPS
- BlendScreenPS
- BlendOverlayPS
- BlendDarkenPS
- BlendLightenPS
- BlendColorDodgePS
- BlendColorBurnPS
- BlendHardLightPS
- BlendSoftLightPS
- BlendDifferencePS
- BlendExclusionPS
- BlendHuePS
- BlendSaturationPS
- BlendColorPS
- BlendLuminosityPS
- type: vs_4_0
file: clear-vs.hlsl
shaders:
- ClearVS
- type: ps_4_0
file: clear-ps.hlsl
shaders:
- ClearPS
- type: vs_4_0
file: mask-combiner-vs.hlsl
shaders:
- MaskCombinerVS
- type: ps_4_0
file: mask-combiner-ps.hlsl
shaders:
- MaskCombinerPS
- type: vs_4_0
file: diagnostics-vs.hlsl
shaders:
- DiagnosticTextVS
- type: ps_4_0
file: diagnostics-ps.hlsl
shaders:
- DiagnosticTextPS
- type: vs_4_0
file: test-features-vs.hlsl
shaders:
- TestConstantBuffersVS

Просмотреть файл

@ -1,32 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "common-vs.hlsl"
#include "color-common.hlsl"
struct VS_INPUT {
float2 vPos : POSITION;
};
cbuffer Buffer0 : register(b0) {
float4 aValue0;
};
cbuffer Buffer1 : register(b1) {
float4 aValue1;
};
cbuffer Buffer2 : register(b2) {
float4 aValue2;
};
VS_COLOROUTPUT_CLIPPED TestConstantBuffersVS(VS_INPUT aInput)
{
// Draw to the entire viewport.
float2 pos = UnitQuadToRect(aInput.vPos, float4(-1, -1, 2, 2));
VS_COLOROUTPUT_CLIPPED output;
output.vPosition = float4(pos, 0, 1);
output.vColor = float4(aValue0.r, aValue1.g, aValue2.b, 1.0);
return output;
}

Просмотреть файл

@ -1,43 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Instanced version.
struct VS_TEXTUREDINPUT
{
float2 vPos : POSITION;
float4 vRect : TEXCOORD0;
uint vLayerId : TEXCOORD1;
int vDepth : TEXCOORD2;
float4 vTexRect : TEXCOORD3;
};
// Non-instanced version.
struct VS_TEXTUREDVERTEX
{
float3 vUnitPos : POSITION0;
float2 vPos1: POSITION1;
float2 vPos2: POSITION2;
float2 vPos3: POSITION3;
uint vLayerId : TEXCOORD0;
int vDepth : TEXCOORD1;
float2 vTexCoord1 : TEXCOORD2;
float2 vTexCoord2 : TEXCOORD3;
float2 vTexCoord3 : TEXCOORD4;
};
struct VS_SAMPLEOUTPUT
{
float4 vPosition : SV_Position;
float2 vTexCoords : TEXCOORD0;
float2 vLocalPos : TEXCOORD1;
float3 vMaskCoords : TEXCOORD2;
nointerpolation float4 vClipRect : TEXCOORD3;
};
struct VS_SAMPLEOUTPUT_CLIPPED
{
float4 vPosition : SV_Position;
float2 vTexCoords : TEXCOORD0;
};

Просмотреть файл

@ -1,45 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "common.hlsl"
#include "common-ps.hlsl"
#include "textured-common.hlsl"
Texture2D simpleTex : register(ps, t0);
float4 FixRGBOpacity(float4 color, float alpha) {
return float4(color.rgb * alpha, alpha);
}
// Fast cases that don't require complex clipping.
float4 TexturedQuadRGBA(const VS_SAMPLEOUTPUT_CLIPPED aInput) : SV_Target
{
return simpleTex.Sample(sSampler, aInput.vTexCoords) * sOpacity;
}
float4 TexturedQuadRGB(const VS_SAMPLEOUTPUT_CLIPPED aInput) : SV_Target
{
return FixRGBOpacity(simpleTex.Sample(sSampler, aInput.vTexCoords), sOpacity);
}
// PaintedLayer common case.
float4 TexturedVertexRGBA(const VS_SAMPLEOUTPUT aInput) : SV_Target
{
if (!RectContainsPoint(aInput.vClipRect, aInput.vPosition.xy)) {
return float4(0, 0, 0, 0);
}
float alpha = ReadMask(aInput.vMaskCoords);
return simpleTex.Sample(sSampler, aInput.vTexCoords) * alpha;
}
// ImageLayers.
float4 TexturedVertexRGB(const VS_SAMPLEOUTPUT aInput) : SV_Target
{
if (!RectContainsPoint(aInput.vClipRect, aInput.vPosition.xy)) {
return float4(0, 0, 0, 0);
}
float alpha = ReadMask(aInput.vMaskCoords);
return FixRGBOpacity(simpleTex.Sample(sSampler, aInput.vTexCoords), alpha);
}

Просмотреть файл

@ -1,49 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "common-vs.hlsl"
#include "textured-common.hlsl"
VS_SAMPLEOUTPUT TexturedQuadImpl(const VertexInfo aInfo, const float2 aTexCoord)
{
VS_SAMPLEOUTPUT output;
output.vPosition = aInfo.worldPos;
output.vTexCoords = aTexCoord;
output.vLocalPos = aInfo.screenPos;
output.vClipRect = aInfo.clipRect;
output.vMaskCoords = aInfo.maskCoords;
return output;
}
VS_SAMPLEOUTPUT_CLIPPED TexturedQuadVS(const VS_TEXTUREDINPUT aVertex)
{
float4 worldPos = ComputeClippedPosition(
aVertex.vPos,
aVertex.vRect,
aVertex.vLayerId,
aVertex.vDepth);
VS_SAMPLEOUTPUT_CLIPPED output;
output.vPosition = worldPos;
output.vTexCoords = UnitQuadToRect(aVertex.vPos, aVertex.vTexRect);
return output;
}
VS_SAMPLEOUTPUT TexturedVertexVS(const VS_TEXTUREDVERTEX aVertex)
{
float2 layerPos = UnitTriangleToPos(
aVertex.vUnitPos,
aVertex.vPos1,
aVertex.vPos2,
aVertex.vPos3);
float2 texCoord = UnitTriangleToPos(
aVertex.vUnitPos,
aVertex.vTexCoord1,
aVertex.vTexCoord2,
aVertex.vTexCoord3);
VertexInfo info = ComputePosition(layerPos, aVertex.vLayerId, aVertex.vDepth);
return TexturedQuadImpl(info, texCoord);
}

Просмотреть файл

@ -1,118 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "common-ps.hlsl"
#include "textured-common.hlsl"
Texture2D tY : register(ps, t0);
Texture2D tCb : register(ps, t1);
Texture2D tCr : register(ps, t2);
cbuffer YCbCrBuffer : register(b1) {
row_major float3x3 YuvColorMatrix;
};
cbuffer vCoefficientBuffer : register(b2) {
float vCoefficient;
}
/* From Rec601:
[R] [1.1643835616438356, 0.0, 1.5960267857142858] [ Y - 16]
[G] = [1.1643835616438358, -0.3917622900949137, -0.8129676472377708] x [Cb - 128]
[B] [1.1643835616438356, 2.017232142857143, 8.862867620416422e-17] [Cr - 128]
For [0,1] instead of [0,255], and to 5 places:
[R] [1.16438, 0.00000, 1.59603] [ Y - 0.06275]
[G] = [1.16438, -0.39176, -0.81297] x [Cb - 0.50196]
[B] [1.16438, 2.01723, 0.00000] [Cr - 0.50196]
From Rec709:
[R] [1.1643835616438356, 4.2781193979771426e-17, 1.7927410714285714] [ Y - 16]
[G] = [1.1643835616438358, -0.21324861427372963, -0.532909328559444] x [Cb - 128]
[B] [1.1643835616438356, 2.1124017857142854, 0.0] [Cr - 128]
For [0,1] instead of [0,255], and to 5 places:
[R] [1.16438, 0.00000, 1.79274] [ Y - 0.06275]
[G] = [1.16438, -0.21325, -0.53291] x [Cb - 0.50196]
[B] [1.16438, 2.11240, 0.00000] [Cr - 0.50196]
*/
float4 CalculateYCbCrColor(float3 rgb)
{
return float4(
mul(YuvColorMatrix,
float3(
rgb.r - 0.06275,
rgb.g - 0.50196,
rgb.b - 0.50196)),
1.0);
}
float4 CalculateIMC4Color(const float2 aTexCoords)
{
float3 yuv = float3(
tY.Sample(sSampler, aTexCoords).r,
tCb.Sample(sSampler, aTexCoords).r,
tCr.Sample(sSampler, aTexCoords).r);
return CalculateYCbCrColor(yuv * vCoefficient);
}
float4 CalculateNV12Color(const float2 aTexCoords)
{
float y = tY.Sample(sSampler, aTexCoords).r;
float2 cbcr = tCb.Sample(sSampler, aTexCoords).rg;
return CalculateYCbCrColor(float3(y, cbcr) * vCoefficient);
}
float4 TexturedQuadIMC4(const VS_SAMPLEOUTPUT_CLIPPED aInput) : SV_Target
{
return CalculateIMC4Color(aInput.vTexCoords) * sOpacity;
}
float4 TexturedQuadNV12(const VS_SAMPLEOUTPUT_CLIPPED aInput) : SV_Target
{
return CalculateNV12Color(aInput.vTexCoords) * sOpacity;
}
float4 TexturedVertexIMC4(const VS_SAMPLEOUTPUT aInput) : SV_Target
{
if (!RectContainsPoint(aInput.vClipRect, aInput.vPosition.xy)) {
return float4(0, 0, 0, 0);
}
float alpha = ReadMask(aInput.vMaskCoords);
return CalculateIMC4Color(aInput.vTexCoords) * alpha;
}
float4 TexturedVertexNV12(const VS_SAMPLEOUTPUT aInput) : SV_Target
{
if (!RectContainsPoint(aInput.vClipRect, aInput.vPosition.xy)) {
return float4(0, 0, 0, 0);
}
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;
}