mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 21:47:47 +00:00
Revert "Add External Texture Gamma/Gamut Correction"
This reverts commit 857175e59b.
Reason for revert: Suspected change for Dawn -> Chromium roll failures:
* https://chromium-review.googlesource.com/c/chromium/src/+/3607875/
* https://ci.chromium.org/ui/p/chromium/builders/try/mac-rel/982037/overview
* https://chrome-public-gold.skia.org/search?issue=3607875&crs=gerrit&patchsets=3&corpus=chrome-gpu
Original change's description:
> Add External Texture Gamma/Gamut Correction
>
> Adds configurable gamma and gamut correction in Tint's external texture
> transform. Adds constants in Dawn to perform correct conversion from
> BT.709 to sRGB.
>
> Bug: dawn:1082
> Change-Id: Id5eecc37f0224541bf36e2f9757e7e2047e4b66b
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87666
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
TBR=cwallez@chromium.org,enga@chromium.org,brandon1.jones@intel.com,bclayton@google.com,noreply+kokoro@google.com,dawn-scoped@luci-project-accounts.iam.gserviceaccount.com
Change-Id: Id3880e506172a18ff1258462c8c4cedb5c51c235
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: dawn:1082
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88001
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
d93d0c994b
commit
1d882f55b7
@@ -152,28 +152,12 @@ namespace dawn::native {
|
||||
|
||||
switch (descriptor->colorSpace) {
|
||||
case wgpu::PredefinedColorSpace::Srgb:
|
||||
// TODO(dawn:1082): Make these fields configurable from outside of Dawn.
|
||||
|
||||
// Conversion matrix for BT.709 limited range. Columns 1, 2 and 3 are copied
|
||||
// directly from the corresponding matrix in SkYUVMath.cpp. Column 4 is the range
|
||||
// bias (for RGB) found in column 5 of the same SkYUVMath.cpp matrix.
|
||||
params.yuvToRgbConversionMatrix = {1.164384f, 0.0f, 1.792741f, -0.972945f,
|
||||
1.164384f, -0.213249f, -0.532909f, 0.301483f,
|
||||
1.164384f, 2.112402f, 0.0f, -1.133402f};
|
||||
|
||||
// These are the inverted parameters as specified by Rec. ITU-R BT.1886 for BT.709
|
||||
params.gammaDecodingParams = {2.2, 1.0 / 1.099, 0.099 / 1.099, 1 / 4.5, 0.081,
|
||||
0.0, 0.0};
|
||||
|
||||
// Constants for sRGB transfer function pulled from
|
||||
// https://en.wikipedia.org/wiki/SRGB
|
||||
params.gammaEncodingParams = {
|
||||
1 / 2.4, 1.137119 /*1.055^2.4*/, 0.0, 12.92, 0.0031308, -0.055, 0.0};
|
||||
|
||||
// Use an identity matrix when converting BT.709 to sRGB because they shared the
|
||||
// same primaries.
|
||||
params.gamutConversionMatrix = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
|
||||
0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f};
|
||||
params.yuvToRgbConversion = {1.164384f, 0.0f, 1.792741f, -0.972945f,
|
||||
1.164384f, -0.213249f, -0.532909f, 0.301483f,
|
||||
1.164384f, 2.112402f, 0.0f, -1.133402f};
|
||||
break;
|
||||
case wgpu::PredefinedColorSpace::Undefined:
|
||||
break;
|
||||
|
||||
@@ -26,24 +26,10 @@ namespace dawn::native {
|
||||
|
||||
class TextureViewBase;
|
||||
|
||||
struct GammaTransferParams {
|
||||
float G = 0.0;
|
||||
float A = 0.0;
|
||||
float B = 0.0;
|
||||
float C = 0.0;
|
||||
float D = 0.0;
|
||||
float E = 0.0;
|
||||
float F = 0.0;
|
||||
uint32_t padding = 0;
|
||||
};
|
||||
|
||||
struct ExternalTextureParams {
|
||||
uint32_t numPlanes;
|
||||
std::array<uint32_t, 3> padding;
|
||||
std::array<float, 12> yuvToRgbConversionMatrix;
|
||||
GammaTransferParams gammaDecodingParams = {};
|
||||
GammaTransferParams gammaEncodingParams = {};
|
||||
std::array<float, 12> gamutConversionMatrix = {};
|
||||
std::array<float, 12> yuvToRgbConversion;
|
||||
};
|
||||
|
||||
MaybeError ValidateExternalTextureDescriptor(const DeviceBase* device,
|
||||
|
||||
@@ -191,15 +191,10 @@ TEST_P(ExternalTextureTests, SampleMultiplanarExternalTexture) {
|
||||
RGBA8 rgba;
|
||||
};
|
||||
|
||||
// Conversion expectations for BT.709 YUV source and sRGB destination.
|
||||
std::array<ConversionExpectation, 7> expectations = {
|
||||
{{0.0, .5, .5, RGBA8::kBlack},
|
||||
{0.2126, 0.4172, 1.0, RGBA8::kRed},
|
||||
{0.7152, 0.1402, 0.0175, RGBA8::kGreen},
|
||||
{0.0722, 1.0, 0.4937, RGBA8::kBlue},
|
||||
{0.6382, 0.3232, 0.6644, {246, 169, 90, 255}},
|
||||
{0.5423, 0.5323, 0.4222, {120, 162, 169, 255}},
|
||||
{0.2345, 0.4383, 0.6342, {126, 53, 33, 255}}}};
|
||||
std::array<ConversionExpectation, 4> expectations = {{{0.0, .5, .5, RGBA8::kBlack},
|
||||
{0.2126, 0.4172, 1.0, RGBA8::kRed},
|
||||
{0.7152, 0.1402, 0.0175, RGBA8::kGreen},
|
||||
{0.0722, 1.0, 0.4937, RGBA8::kBlue}}};
|
||||
|
||||
for (ConversionExpectation expectation : expectations) {
|
||||
// Initialize the texture planes with YUV data
|
||||
|
||||
@@ -51,9 +51,6 @@ struct MultiplanarExternalTexture::State {
|
||||
/// as input into the transform.
|
||||
const NewBindingPoints* new_binding_points;
|
||||
|
||||
/// Symbol for the GammaTransferParams
|
||||
Symbol gamma_transfer_struct_sym;
|
||||
|
||||
/// Symbol for the ExternalTextureParams struct
|
||||
Symbol params_struct_sym;
|
||||
|
||||
@@ -63,9 +60,6 @@ struct MultiplanarExternalTexture::State {
|
||||
/// Symbol for the textureSampleExternal function
|
||||
Symbol texture_sample_external_sym;
|
||||
|
||||
/// Symbol for the gammaCorrection function
|
||||
Symbol gamma_correction_sym;
|
||||
|
||||
/// Storage for new bindings that have been created corresponding to an
|
||||
/// original texture_external binding.
|
||||
std::unordered_map<const sem::Variable*, NewBindingSymbols>
|
||||
@@ -102,7 +96,7 @@ struct MultiplanarExternalTexture::State {
|
||||
// If we find a texture_external binding, we know we must emit the
|
||||
// ExternalTextureParams struct.
|
||||
if (!params_struct_sym.IsValid()) {
|
||||
createExtTexParamsStructs();
|
||||
createExtTexParamsStruct();
|
||||
}
|
||||
|
||||
// The binding points for the newly introduced bindings must have been
|
||||
@@ -164,7 +158,7 @@ struct MultiplanarExternalTexture::State {
|
||||
// If we find a texture_external, we must ensure the
|
||||
// ExternalTextureParams struct exists.
|
||||
if (!params_struct_sym.IsValid()) {
|
||||
createExtTexParamsStructs();
|
||||
createExtTexParamsStruct();
|
||||
}
|
||||
// When a texture_external is found, we insert all components
|
||||
// the texture_external into the parameter list. We must also place
|
||||
@@ -242,69 +236,15 @@ struct MultiplanarExternalTexture::State {
|
||||
});
|
||||
}
|
||||
|
||||
/// Creates the parameter structs associated with the transform.
|
||||
void createExtTexParamsStructs() {
|
||||
// Create GammaTransferParams struct.
|
||||
ast::StructMemberList gamma_transfer_member_list = {
|
||||
b.Member("G", b.ty.f32()), b.Member("A", b.ty.f32()),
|
||||
b.Member("B", b.ty.f32()), b.Member("C", b.ty.f32()),
|
||||
b.Member("D", b.ty.f32()), b.Member("E", b.ty.f32()),
|
||||
b.Member("F", b.ty.f32()), b.Member("padding", b.ty.u32())};
|
||||
|
||||
gamma_transfer_struct_sym = b.Symbols().New("GammaTransferParams");
|
||||
|
||||
b.Structure(gamma_transfer_struct_sym, gamma_transfer_member_list);
|
||||
|
||||
// Create ExternalTextureParams struct.
|
||||
ast::StructMemberList ext_tex_params_member_list = {
|
||||
/// Creates the ExternalTextureParams struct.
|
||||
void createExtTexParamsStruct() {
|
||||
ast::StructMemberList member_list = {
|
||||
b.Member("numPlanes", b.ty.u32()),
|
||||
b.Member("yuvToRgbConversionMatrix", b.ty.mat3x4(b.ty.f32())),
|
||||
b.Member("gammaDecodeParams", b.ty.type_name("GammaTransferParams")),
|
||||
b.Member("gammaEncodeParams", b.ty.type_name("GammaTransferParams")),
|
||||
b.Member("gamutConversionMatrix", b.ty.mat3x3(b.ty.f32()))};
|
||||
b.Member("yuvToRgbConversionMatrix", b.ty.mat3x4(b.ty.f32()))};
|
||||
|
||||
params_struct_sym = b.Symbols().New("ExternalTextureParams");
|
||||
|
||||
b.Structure(params_struct_sym, ext_tex_params_member_list);
|
||||
}
|
||||
|
||||
/// Creates the gammaCorrection function if needed and returns a call
|
||||
/// expression to it.
|
||||
void createGammaCorrectionFn() {
|
||||
using f32 = ProgramBuilder::f32;
|
||||
ast::VariableList varList = {
|
||||
b.Param("v", b.ty.vec3<f32>()),
|
||||
b.Param("params", b.ty.type_name(gamma_transfer_struct_sym))};
|
||||
|
||||
ast::StatementList statementList = {
|
||||
// let cond = abs(v) < vec3(params.D);
|
||||
b.Decl(
|
||||
b.Const("cond", nullptr,
|
||||
b.LessThan(b.Call("abs", "v"),
|
||||
b.vec3<f32>(b.MemberAccessor("params", "D"))))),
|
||||
// let t = sign(v) * ((params.C * abs(v)) + params.F);
|
||||
b.Decl(b.Const("t", nullptr,
|
||||
b.Mul(b.Call("sign", "v"),
|
||||
b.Add(b.Mul(b.MemberAccessor("params", "C"),
|
||||
b.Call("abs", "v")),
|
||||
b.MemberAccessor("params", "F"))))),
|
||||
// let f = (sign(v) * pow(((params.A * abs(v)) + params.B),
|
||||
// vec3(params.G))) + params.E;
|
||||
b.Decl(b.Const(
|
||||
"f", nullptr,
|
||||
b.Mul(b.Call("sign", "v"),
|
||||
b.Add(b.Call("pow",
|
||||
b.Add(b.Mul(b.MemberAccessor("params", "A"),
|
||||
b.Call("abs", "v")),
|
||||
b.MemberAccessor("params", "B")),
|
||||
b.vec3<f32>(b.MemberAccessor("params", "G"))),
|
||||
b.MemberAccessor("params", "E"))))),
|
||||
// return select(f, t, cond);
|
||||
b.Return(b.Call("select", "f", "t", "cond"))};
|
||||
|
||||
gamma_correction_sym = b.Symbols().New("gammaCorrection");
|
||||
|
||||
b.Func(gamma_correction_sym, varList, b.ty.vec3<f32>(), statementList, {});
|
||||
b.Structure(params_struct_sym, member_list);
|
||||
}
|
||||
|
||||
/// Constructs a StatementList containing all the statements making up the
|
||||
@@ -357,18 +297,6 @@ struct MultiplanarExternalTexture::State {
|
||||
b.MemberAccessor(plane_1_call, "rg"), 1.0f),
|
||||
b.MemberAccessor(
|
||||
"params", "yuvToRgbConversionMatrix")))))),
|
||||
// color = gammaConversion(color, gammaDecodeParams);
|
||||
b.Assign("color",
|
||||
b.Call("gammaCorrection", "color",
|
||||
b.MemberAccessor("params", "gammaDecodeParams"))),
|
||||
// color = (params.gamutConversionMatrix * color);
|
||||
b.Assign("color",
|
||||
b.Mul(b.MemberAccessor("params", "gamutConversionMatrix"),
|
||||
"color")),
|
||||
// color = gammaConversion(color, gammaEncodeParams);
|
||||
b.Assign("color",
|
||||
b.Call("gammaCorrection", "color",
|
||||
b.MemberAccessor("params", "gammaEncodeParams"))),
|
||||
// return vec4<f32>(color, 1.0f);
|
||||
b.Return(b.vec4<f32>("color", 1.0f))};
|
||||
}
|
||||
@@ -390,12 +318,6 @@ struct MultiplanarExternalTexture::State {
|
||||
<< expr->args.size() << " parameters";
|
||||
}
|
||||
|
||||
// TextureSampleExternal calls the gammaCorrection function, so ensure it
|
||||
// exists.
|
||||
if (!gamma_correction_sym.IsValid()) {
|
||||
createGammaCorrectionFn();
|
||||
}
|
||||
|
||||
if (!texture_sample_external_sym.IsValid()) {
|
||||
texture_sample_external_sym = b.Symbols().New("textureSampleExternal");
|
||||
|
||||
@@ -440,12 +362,6 @@ struct MultiplanarExternalTexture::State {
|
||||
<< expr->args.size() << " parameters";
|
||||
}
|
||||
|
||||
// TextureLoadExternal calls the gammaCorrection function, so ensure it
|
||||
// exists.
|
||||
if (!gamma_correction_sym.IsValid()) {
|
||||
createGammaCorrectionFn();
|
||||
}
|
||||
|
||||
if (!texture_load_external_sym.IsValid()) {
|
||||
texture_load_external_sym = b.Symbols().New("textureLoadExternal");
|
||||
|
||||
|
||||
@@ -106,23 +106,9 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct GammaTransferParams {
|
||||
G : f32,
|
||||
A : f32,
|
||||
B : f32,
|
||||
C : f32,
|
||||
D : f32,
|
||||
E : f32,
|
||||
F : f32,
|
||||
padding : u32,
|
||||
}
|
||||
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -160,23 +146,9 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct GammaTransferParams {
|
||||
G : f32,
|
||||
A : f32,
|
||||
B : f32,
|
||||
C : f32,
|
||||
D : f32,
|
||||
E : f32,
|
||||
F : f32,
|
||||
padding : u32,
|
||||
}
|
||||
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -213,23 +185,9 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct GammaTransferParams {
|
||||
G : f32,
|
||||
A : f32,
|
||||
B : f32,
|
||||
C : f32,
|
||||
D : f32,
|
||||
E : f32,
|
||||
F : f32,
|
||||
padding : u32,
|
||||
}
|
||||
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -240,13 +198,6 @@ struct ExternalTextureParams {
|
||||
|
||||
@group(0) @binding(1) var ext_tex : texture_2d<f32>;
|
||||
|
||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
let cond = (abs(v) < vec3<f32>(params.D));
|
||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
||||
return select(f, t, cond);
|
||||
}
|
||||
|
||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
@@ -254,9 +205,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@@ -286,36 +234,15 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct GammaTransferParams {
|
||||
G : f32,
|
||||
A : f32,
|
||||
B : f32,
|
||||
C : f32,
|
||||
D : f32,
|
||||
E : f32,
|
||||
F : f32,
|
||||
padding : u32,
|
||||
}
|
||||
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
|
||||
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
|
||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
let cond = (abs(v) < vec3<f32>(params.D));
|
||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
||||
return select(f, t, cond);
|
||||
}
|
||||
|
||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
@@ -323,9 +250,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@@ -358,23 +282,9 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct GammaTransferParams {
|
||||
G : f32,
|
||||
A : f32,
|
||||
B : f32,
|
||||
C : f32,
|
||||
D : f32,
|
||||
E : f32,
|
||||
F : f32,
|
||||
padding : u32,
|
||||
}
|
||||
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -383,13 +293,6 @@ struct ExternalTextureParams {
|
||||
|
||||
@group(0) @binding(0) var ext_tex : texture_2d<f32>;
|
||||
|
||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
let cond = (abs(v) < vec3<f32>(params.D));
|
||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
||||
return select(f, t, cond);
|
||||
}
|
||||
|
||||
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
@@ -397,9 +300,6 @@ fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@@ -428,36 +328,15 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct GammaTransferParams {
|
||||
G : f32,
|
||||
A : f32,
|
||||
B : f32,
|
||||
C : f32,
|
||||
D : f32,
|
||||
E : f32,
|
||||
F : f32,
|
||||
padding : u32,
|
||||
}
|
||||
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
|
||||
@group(0) @binding(2) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
|
||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
let cond = (abs(v) < vec3<f32>(params.D));
|
||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
||||
return select(f, t, cond);
|
||||
}
|
||||
|
||||
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
@@ -465,9 +344,6 @@ fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@@ -500,23 +376,9 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct GammaTransferParams {
|
||||
G : f32,
|
||||
A : f32,
|
||||
B : f32,
|
||||
C : f32,
|
||||
D : f32,
|
||||
E : f32,
|
||||
F : f32,
|
||||
padding : u32,
|
||||
}
|
||||
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -527,13 +389,6 @@ struct ExternalTextureParams {
|
||||
|
||||
@group(0) @binding(1) var ext_tex : texture_2d<f32>;
|
||||
|
||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
let cond = (abs(v) < vec3<f32>(params.D));
|
||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
||||
return select(f, t, cond);
|
||||
}
|
||||
|
||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
@@ -541,9 +396,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@@ -554,9 +406,6 @@ fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@@ -587,36 +436,15 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct GammaTransferParams {
|
||||
G : f32,
|
||||
A : f32,
|
||||
B : f32,
|
||||
C : f32,
|
||||
D : f32,
|
||||
E : f32,
|
||||
F : f32,
|
||||
padding : u32,
|
||||
}
|
||||
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
|
||||
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
|
||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
let cond = (abs(v) < vec3<f32>(params.D));
|
||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
||||
return select(f, t, cond);
|
||||
}
|
||||
|
||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
@@ -624,9 +452,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@@ -637,9 +462,6 @@ fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@@ -676,23 +498,9 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct GammaTransferParams {
|
||||
G : f32,
|
||||
A : f32,
|
||||
B : f32,
|
||||
C : f32,
|
||||
D : f32,
|
||||
E : f32,
|
||||
F : f32,
|
||||
padding : u32,
|
||||
}
|
||||
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(4) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -721,13 +529,6 @@ struct ExternalTextureParams {
|
||||
|
||||
@group(1) @binding(0) var ext_tex_3 : texture_2d<f32>;
|
||||
|
||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
let cond = (abs(v) < vec3<f32>(params.D));
|
||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
||||
return select(f, t, cond);
|
||||
}
|
||||
|
||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
@@ -735,9 +536,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@@ -777,36 +575,15 @@ fn main() {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct GammaTransferParams {
|
||||
G : f32,
|
||||
A : f32,
|
||||
B : f32,
|
||||
C : f32,
|
||||
D : f32,
|
||||
E : f32,
|
||||
F : f32,
|
||||
padding : u32,
|
||||
}
|
||||
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
|
||||
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
|
||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
let cond = (abs(v) < vec3<f32>(params.D));
|
||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
||||
return select(f, t, cond);
|
||||
}
|
||||
|
||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
@@ -814,9 +591,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@@ -861,23 +635,9 @@ fn f(t : texture_external, s : sampler) {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct GammaTransferParams {
|
||||
G : f32,
|
||||
A : f32,
|
||||
B : f32,
|
||||
C : f32,
|
||||
D : f32,
|
||||
E : f32,
|
||||
F : f32,
|
||||
padding : u32,
|
||||
}
|
||||
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -889,13 +649,6 @@ fn main() {
|
||||
f(ext_tex, ext_tex_plane_1, ext_tex_params, smp);
|
||||
}
|
||||
|
||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
let cond = (abs(v) < vec3<f32>(params.D));
|
||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
||||
return select(f, t, cond);
|
||||
}
|
||||
|
||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
@@ -903,9 +656,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@@ -944,36 +694,15 @@ fn main() {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct GammaTransferParams {
|
||||
G : f32,
|
||||
A : f32,
|
||||
B : f32,
|
||||
C : f32,
|
||||
D : f32,
|
||||
E : f32,
|
||||
F : f32,
|
||||
padding : u32,
|
||||
}
|
||||
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
|
||||
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
|
||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
let cond = (abs(v) < vec3<f32>(params.D));
|
||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
||||
return select(f, t, cond);
|
||||
}
|
||||
|
||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
@@ -981,9 +710,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@@ -1029,23 +755,9 @@ fn main() {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct GammaTransferParams {
|
||||
G : f32,
|
||||
A : f32,
|
||||
B : f32,
|
||||
C : f32,
|
||||
D : f32,
|
||||
E : f32,
|
||||
F : f32,
|
||||
padding : u32,
|
||||
}
|
||||
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(3) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1056,13 +768,6 @@ struct ExternalTextureParams {
|
||||
|
||||
@group(0) @binding(6) var<uniform> ext_tex_params_1 : ExternalTextureParams;
|
||||
|
||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
let cond = (abs(v) < vec3<f32>(params.D));
|
||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
||||
return select(f, t, cond);
|
||||
}
|
||||
|
||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
@@ -1070,9 +775,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@@ -1124,23 +826,9 @@ fn f(t : texture_external, s : sampler, t2 : texture_external) {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct GammaTransferParams {
|
||||
G : f32,
|
||||
A : f32,
|
||||
B : f32,
|
||||
C : f32,
|
||||
D : f32,
|
||||
E : f32,
|
||||
F : f32,
|
||||
padding : u32,
|
||||
}
|
||||
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(3) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1156,13 +844,6 @@ fn main() {
|
||||
f(ext_tex, ext_tex_plane_1, ext_tex_params, smp, ext_tex2, ext_tex_plane_1_1, ext_tex_params_1);
|
||||
}
|
||||
|
||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
let cond = (abs(v) < vec3<f32>(params.D));
|
||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
||||
return select(f, t, cond);
|
||||
}
|
||||
|
||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
@@ -1170,9 +851,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@@ -1219,36 +897,15 @@ fn main() {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct GammaTransferParams {
|
||||
G : f32,
|
||||
A : f32,
|
||||
B : f32,
|
||||
C : f32,
|
||||
D : f32,
|
||||
E : f32,
|
||||
F : f32,
|
||||
padding : u32,
|
||||
}
|
||||
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
|
||||
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
|
||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
let cond = (abs(v) < vec3<f32>(params.D));
|
||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
||||
return select(f, t, cond);
|
||||
}
|
||||
|
||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
@@ -1256,9 +913,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@@ -1311,36 +965,15 @@ fn main() {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct GammaTransferParams {
|
||||
G : f32,
|
||||
A : f32,
|
||||
B : f32,
|
||||
C : f32,
|
||||
D : f32,
|
||||
E : f32,
|
||||
F : f32,
|
||||
padding : u32,
|
||||
}
|
||||
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
|
||||
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
|
||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
let cond = (abs(v) < vec3<f32>(params.D));
|
||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
||||
return select(f, t, cond);
|
||||
}
|
||||
|
||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
@@ -1348,9 +981,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@@ -1391,23 +1021,9 @@ fn f(ext_tex : texture_external) -> vec2<i32> {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct GammaTransferParams {
|
||||
G : f32,
|
||||
A : f32,
|
||||
B : f32,
|
||||
C : f32,
|
||||
D : f32,
|
||||
E : f32,
|
||||
F : f32,
|
||||
padding : u32,
|
||||
}
|
||||
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
}
|
||||
|
||||
fn f(ext_tex : texture_2d<f32>, ext_tex_plane_1 : texture_2d<f32>, ext_tex_params : ExternalTextureParams) -> vec2<i32> {
|
||||
@@ -1441,23 +1057,9 @@ fn main() {
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct GammaTransferParams {
|
||||
G : f32,
|
||||
A : f32,
|
||||
B : f32,
|
||||
C : f32,
|
||||
D : f32,
|
||||
E : f32,
|
||||
F : f32,
|
||||
padding : u32,
|
||||
}
|
||||
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1466,13 +1068,6 @@ struct ExternalTextureParams {
|
||||
|
||||
type ET = texture_external;
|
||||
|
||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
let cond = (abs(v) < vec3<f32>(params.D));
|
||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
||||
return select(f, t, cond);
|
||||
}
|
||||
|
||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
@@ -1480,9 +1075,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@@ -1527,23 +1119,9 @@ type ET = texture_external;
|
||||
)";
|
||||
|
||||
auto* expect = R"(
|
||||
struct GammaTransferParams {
|
||||
G : f32,
|
||||
A : f32,
|
||||
B : f32,
|
||||
C : f32,
|
||||
D : f32,
|
||||
E : f32,
|
||||
F : f32,
|
||||
padding : u32,
|
||||
}
|
||||
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
gammaDecodeParams : GammaTransferParams,
|
||||
gammaEncodeParams : GammaTransferParams,
|
||||
gamutConversionMatrix : mat3x3<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1555,13 +1133,6 @@ fn main() {
|
||||
f(ext_tex, ext_tex_plane_1, ext_tex_params, smp);
|
||||
}
|
||||
|
||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
||||
let cond = (abs(v) < vec3<f32>(params.D));
|
||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
||||
return select(f, t, cond);
|
||||
}
|
||||
|
||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||
var color : vec3<f32>;
|
||||
if ((params.numPlanes == 1u)) {
|
||||
@@ -1569,9 +1140,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
||||
color = (params.gamutConversionMatrix * color);
|
||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user