mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 21:47:47 +00:00
Change External Texture YUV-to-RGB Conversion to Use Matrix
Changes Dawn and Tint to use a 3x3 matrix for external texture YUV-to-RGB conversions. This will allow us to use standard matrices as they exist in SkYuvMath. Bugs: dawn::1082 Change-Id: I8e0c7c3dc1c085d8f336da956aea9496913b70fa Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86847 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
931a4ddb1c
commit
6cb57a9847
@@ -144,26 +144,20 @@ namespace dawn::native {
|
||||
|
||||
DAWN_TRY_ASSIGN(mParamsBuffer, device->CreateBuffer(&bufferDesc));
|
||||
|
||||
// Dawn & Tint's YUV to RGB conversion implementation was inspired by the conversions found
|
||||
// in libYUV. If this implementation needs expanded to support more colorspaces, this file
|
||||
// is an excellent reference: chromium/src/third_party/libyuv/source/row_common.cc.
|
||||
//
|
||||
// The conversion from YUV to RGB looks like this:
|
||||
// r = Y * 1.164 + V * vr
|
||||
// g = Y * 1.164 - U * ug - V * vg
|
||||
// b = Y * 1.164 + U * ub
|
||||
//
|
||||
// By changing the values of vr, vg, ub, and ug we can change the destination color space.
|
||||
// Dawn & Tint's YUV-to-RGB conversion implementation is a simple 3x4 matrix multiplication
|
||||
// using a standard conversion matrix. These matrices can be found in
|
||||
// chromium/src/third_party/skia/src/core/SkYUVMath.cpp
|
||||
ExternalTextureParams params;
|
||||
params.numPlanes = descriptor->plane1 == nullptr ? 1 : 2;
|
||||
|
||||
switch (descriptor->colorSpace) {
|
||||
case wgpu::PredefinedColorSpace::Srgb:
|
||||
// Numbers derived from ITU-R recommendation for limited range BT.709
|
||||
params.vr = 1.793;
|
||||
params.vg = 0.392;
|
||||
params.ub = 0.813;
|
||||
params.ug = 2.017;
|
||||
// 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.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;
|
||||
|
||||
@@ -28,10 +28,8 @@ namespace dawn::native {
|
||||
|
||||
struct ExternalTextureParams {
|
||||
uint32_t numPlanes;
|
||||
float vr;
|
||||
float vg;
|
||||
float ub;
|
||||
float ug;
|
||||
std::array<uint32_t, 3> padding;
|
||||
std::array<float, 12> yuvToRgbConversion;
|
||||
};
|
||||
|
||||
MaybeError ValidateExternalTextureDescriptor(const DeviceBase* device,
|
||||
|
||||
@@ -191,10 +191,10 @@ TEST_P(ExternalTextureTests, SampleMultiplanarExternalTexture) {
|
||||
RGBA8 rgba;
|
||||
};
|
||||
|
||||
std::array<ConversionExpectation, 4> expectations = {{{0.0f, 0.5f, 0.5f, RGBA8::kBlack},
|
||||
{0.298f, 0.329f, 1.0f, RGBA8::kRed},
|
||||
{0.584f, -0.168f, -0.823f, RGBA8::kGreen},
|
||||
{0.113f, 1.0f, 0.419f, RGBA8::kBlue}}};
|
||||
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
|
||||
|
||||
@@ -239,9 +239,8 @@ struct MultiplanarExternalTexture::State {
|
||||
/// Creates the ExternalTextureParams struct.
|
||||
void createExtTexParamsStruct() {
|
||||
ast::StructMemberList member_list = {
|
||||
b.Member("numPlanes", b.ty.u32()), b.Member("vr", b.ty.f32()),
|
||||
b.Member("ug", b.ty.f32()), b.Member("vg", b.ty.f32()),
|
||||
b.Member("ub", b.ty.f32())};
|
||||
b.Member("numPlanes", b.ty.u32()),
|
||||
b.Member("yuvToRgbConversionMatrix", b.ty.mat3x4(b.ty.f32()))};
|
||||
|
||||
params_struct_sym = b.Symbols().New("ExternalTextureParams");
|
||||
|
||||
@@ -280,40 +279,26 @@ struct MultiplanarExternalTexture::State {
|
||||
}
|
||||
|
||||
return {
|
||||
// if (params.numPlanes == 1u) {
|
||||
// return singlePlaneCall
|
||||
// }
|
||||
// var color: vec3<f32>;
|
||||
b.Decl(b.Var("color", b.ty.vec3(b.ty.f32()))),
|
||||
// if ((params.numPlanes == 1u))
|
||||
b.If(b.create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kEqual, b.MemberAccessor("params", "numPlanes"),
|
||||
b.Expr(1u)),
|
||||
b.Block(b.Return(single_plane_call))),
|
||||
// let y = plane0Call.r - 0.0625;
|
||||
b.Decl(b.Const("y", nullptr,
|
||||
b.Sub(b.MemberAccessor(plane_0_call, "r"), 0.0625f))),
|
||||
// let uv = plane1Call.rg - 0.5;
|
||||
b.Decl(b.Const("uv", nullptr,
|
||||
b.Sub(b.MemberAccessor(plane_1_call, "rg"), 0.5f))),
|
||||
// let u = uv.x;
|
||||
b.Decl(b.Const("u", nullptr, b.MemberAccessor("uv", "x"))),
|
||||
// let v = uv.y;
|
||||
b.Decl(b.Const("v", nullptr, b.MemberAccessor("uv", "y"))),
|
||||
// let r = 1.164 * y + params.vr * v;
|
||||
b.Decl(b.Const("r", nullptr,
|
||||
b.Add(b.Mul(1.164f, "y"),
|
||||
b.Mul(b.MemberAccessor("params", "vr"), "v")))),
|
||||
// let g = 1.164 * y - params.ug * u - params.vg * v;
|
||||
b.Decl(
|
||||
b.Const("g", nullptr,
|
||||
b.Sub(b.Sub(b.Mul(1.164f, "y"),
|
||||
b.Mul(b.MemberAccessor("params", "ug"), "u")),
|
||||
b.Mul(b.MemberAccessor("params", "vg"), "v")))),
|
||||
// let b = 1.164 * y + params.ub * u;
|
||||
b.Decl(b.Const("b", nullptr,
|
||||
b.Add(b.Mul(1.164f, "y"),
|
||||
b.Mul(b.MemberAccessor("params", "ub"), "u")))),
|
||||
// return vec4<f32>(r, g, b, 1.0);
|
||||
b.Return(b.vec4<f32>("r", "g", "b", 1.0f)),
|
||||
};
|
||||
b.Block(
|
||||
// color = textureLoad(plane0, coord, 0).rgb;
|
||||
b.Assign("color", b.MemberAccessor(single_plane_call, "rgb"))),
|
||||
b.Else(b.Block(
|
||||
// color = vec4<f32>(plane_0_call.r, plane_1_call.rg, 1.0) *
|
||||
// params.yuvToRgbConversionMatrix;
|
||||
b.Assign("color",
|
||||
b.Mul(b.vec4<f32>(
|
||||
b.MemberAccessor(plane_0_call, "r"),
|
||||
b.MemberAccessor(plane_1_call, "rg"), 1.0f),
|
||||
b.MemberAccessor(
|
||||
"params", "yuvToRgbConversionMatrix")))))),
|
||||
// return vec4<f32>(color, 1.0f);
|
||||
b.Return(b.vec4<f32>("color", 1.0f))};
|
||||
}
|
||||
|
||||
/// Creates the textureSampleExternal function if needed and returns a call
|
||||
|
||||
@@ -108,10 +108,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
auto* expect = R"(
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
vr : f32,
|
||||
ug : f32,
|
||||
vg : f32,
|
||||
ub : f32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -151,10 +148,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
auto* expect = R"(
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
vr : f32,
|
||||
ug : f32,
|
||||
vg : f32,
|
||||
ub : f32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -193,10 +187,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
auto* expect = R"(
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
vr : f32,
|
||||
ug : f32,
|
||||
vg : f32,
|
||||
ub : f32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -208,17 +199,13 @@ struct ExternalTextureParams {
|
||||
@group(0) @binding(1) var ext_tex : texture_2d<f32>;
|
||||
|
||||
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)) {
|
||||
return textureSampleLevel(plane0, smp, coord, 0.0);
|
||||
color = textureSampleLevel(plane0, smp, coord, 0.0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
let y = (textureSampleLevel(plane0, smp, coord, 0.0).r - 0.0625);
|
||||
let uv = (textureSampleLevel(plane1, smp, coord, 0.0).rg - 0.5);
|
||||
let u = uv.x;
|
||||
let v = uv.y;
|
||||
let r = ((1.164000034 * y) + (params.vr * v));
|
||||
let g = (((1.164000034 * y) - (params.ug * u)) - (params.vg * v));
|
||||
let b = ((1.164000034 * y) + (params.ub * u));
|
||||
return vec4<f32>(r, g, b, 1.0);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@stage(fragment)
|
||||
@@ -249,10 +236,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
auto* expect = R"(
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
vr : f32,
|
||||
ug : f32,
|
||||
vg : f32,
|
||||
ub : f32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -260,17 +244,13 @@ struct ExternalTextureParams {
|
||||
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
|
||||
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)) {
|
||||
return textureSampleLevel(plane0, smp, coord, 0.0);
|
||||
color = textureSampleLevel(plane0, smp, coord, 0.0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
let y = (textureSampleLevel(plane0, smp, coord, 0.0).r - 0.0625);
|
||||
let uv = (textureSampleLevel(plane1, smp, coord, 0.0).rg - 0.5);
|
||||
let u = uv.x;
|
||||
let v = uv.y;
|
||||
let r = ((1.164000034 * y) + (params.vr * v));
|
||||
let g = (((1.164000034 * y) - (params.ug * u)) - (params.vg * v));
|
||||
let b = ((1.164000034 * y) + (params.ub * u));
|
||||
return vec4<f32>(r, g, b, 1.0);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@stage(fragment)
|
||||
@@ -304,10 +284,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
auto* expect = R"(
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
vr : f32,
|
||||
ug : f32,
|
||||
vg : f32,
|
||||
ub : f32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -317,17 +294,13 @@ struct ExternalTextureParams {
|
||||
@group(0) @binding(0) var ext_tex : texture_2d<f32>;
|
||||
|
||||
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)) {
|
||||
return textureLoad(plane0, coord, 0);
|
||||
color = textureLoad(plane0, coord, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
let y = (textureLoad(plane0, coord, 0).r - 0.0625);
|
||||
let uv = (textureLoad(plane1, coord, 0).rg - 0.5);
|
||||
let u = uv.x;
|
||||
let v = uv.y;
|
||||
let r = ((1.164000034 * y) + (params.vr * v));
|
||||
let g = (((1.164000034 * y) - (params.ug * u)) - (params.vg * v));
|
||||
let b = ((1.164000034 * y) + (params.ub * u));
|
||||
return vec4<f32>(r, g, b, 1.0);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@stage(fragment)
|
||||
@@ -357,10 +330,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
auto* expect = R"(
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
vr : f32,
|
||||
ug : f32,
|
||||
vg : f32,
|
||||
ub : f32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -368,17 +338,13 @@ struct ExternalTextureParams {
|
||||
@group(0) @binding(2) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
|
||||
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)) {
|
||||
return textureLoad(plane0, coord, 0);
|
||||
color = textureLoad(plane0, coord, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
let y = (textureLoad(plane0, coord, 0).r - 0.0625);
|
||||
let uv = (textureLoad(plane1, coord, 0).rg - 0.5);
|
||||
let u = uv.x;
|
||||
let v = uv.y;
|
||||
let r = ((1.164000034 * y) + (params.vr * v));
|
||||
let g = (((1.164000034 * y) - (params.ug * u)) - (params.vg * v));
|
||||
let b = ((1.164000034 * y) + (params.ub * u));
|
||||
return vec4<f32>(r, g, b, 1.0);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@stage(fragment)
|
||||
@@ -412,10 +378,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
auto* expect = R"(
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
vr : f32,
|
||||
ug : f32,
|
||||
vg : f32,
|
||||
ub : f32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -427,31 +390,23 @@ struct ExternalTextureParams {
|
||||
@group(0) @binding(1) var ext_tex : texture_2d<f32>;
|
||||
|
||||
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)) {
|
||||
return textureSampleLevel(plane0, smp, coord, 0.0);
|
||||
color = textureSampleLevel(plane0, smp, coord, 0.0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
let y = (textureSampleLevel(plane0, smp, coord, 0.0).r - 0.0625);
|
||||
let uv = (textureSampleLevel(plane1, smp, coord, 0.0).rg - 0.5);
|
||||
let u = uv.x;
|
||||
let v = uv.y;
|
||||
let r = ((1.164000034 * y) + (params.vr * v));
|
||||
let g = (((1.164000034 * y) - (params.ug * u)) - (params.vg * v));
|
||||
let b = ((1.164000034 * y) + (params.ub * u));
|
||||
return vec4<f32>(r, g, b, 1.0);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
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)) {
|
||||
return textureLoad(plane0, coord, 0);
|
||||
color = textureLoad(plane0, coord, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
let y = (textureLoad(plane0, coord, 0).r - 0.0625);
|
||||
let uv = (textureLoad(plane1, coord, 0).rg - 0.5);
|
||||
let u = uv.x;
|
||||
let v = uv.y;
|
||||
let r = ((1.164000034 * y) + (params.vr * v));
|
||||
let g = (((1.164000034 * y) - (params.ug * u)) - (params.vg * v));
|
||||
let b = ((1.164000034 * y) + (params.ub * u));
|
||||
return vec4<f32>(r, g, b, 1.0);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@stage(fragment)
|
||||
@@ -483,10 +438,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
auto* expect = R"(
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
vr : f32,
|
||||
ug : f32,
|
||||
vg : f32,
|
||||
ub : f32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -494,31 +446,23 @@ struct ExternalTextureParams {
|
||||
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
|
||||
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)) {
|
||||
return textureSampleLevel(plane0, smp, coord, 0.0);
|
||||
color = textureSampleLevel(plane0, smp, coord, 0.0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
let y = (textureSampleLevel(plane0, smp, coord, 0.0).r - 0.0625);
|
||||
let uv = (textureSampleLevel(plane1, smp, coord, 0.0).rg - 0.5);
|
||||
let u = uv.x;
|
||||
let v = uv.y;
|
||||
let r = ((1.164000034 * y) + (params.vr * v));
|
||||
let g = (((1.164000034 * y) - (params.ug * u)) - (params.vg * v));
|
||||
let b = ((1.164000034 * y) + (params.ub * u));
|
||||
return vec4<f32>(r, g, b, 1.0);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
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)) {
|
||||
return textureLoad(plane0, coord, 0);
|
||||
color = textureLoad(plane0, coord, 0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
let y = (textureLoad(plane0, coord, 0).r - 0.0625);
|
||||
let uv = (textureLoad(plane1, coord, 0).rg - 0.5);
|
||||
let u = uv.x;
|
||||
let v = uv.y;
|
||||
let r = ((1.164000034 * y) + (params.vr * v));
|
||||
let g = (((1.164000034 * y) - (params.ug * u)) - (params.vg * v));
|
||||
let b = ((1.164000034 * y) + (params.ub * u));
|
||||
return vec4<f32>(r, g, b, 1.0);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@stage(fragment)
|
||||
@@ -556,10 +500,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
auto* expect = R"(
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
vr : f32,
|
||||
ug : f32,
|
||||
vg : f32,
|
||||
ub : f32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(4) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -589,17 +530,13 @@ struct ExternalTextureParams {
|
||||
@group(1) @binding(0) var ext_tex_3 : texture_2d<f32>;
|
||||
|
||||
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)) {
|
||||
return textureSampleLevel(plane0, smp, coord, 0.0);
|
||||
color = textureSampleLevel(plane0, smp, coord, 0.0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
let y = (textureSampleLevel(plane0, smp, coord, 0.0).r - 0.0625);
|
||||
let uv = (textureSampleLevel(plane1, smp, coord, 0.0).rg - 0.5);
|
||||
let u = uv.x;
|
||||
let v = uv.y;
|
||||
let r = ((1.164000034 * y) + (params.vr * v));
|
||||
let g = (((1.164000034 * y) - (params.ug * u)) - (params.vg * v));
|
||||
let b = ((1.164000034 * y) + (params.ub * u));
|
||||
return vec4<f32>(r, g, b, 1.0);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
@stage(fragment)
|
||||
@@ -640,10 +577,7 @@ fn main() {
|
||||
auto* expect = R"(
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
vr : f32,
|
||||
ug : f32,
|
||||
vg : f32,
|
||||
ub : f32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -651,17 +585,13 @@ struct ExternalTextureParams {
|
||||
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
|
||||
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)) {
|
||||
return textureSampleLevel(plane0, smp, coord, 0.0);
|
||||
color = textureSampleLevel(plane0, smp, coord, 0.0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
let y = (textureSampleLevel(plane0, smp, coord, 0.0).r - 0.0625);
|
||||
let uv = (textureSampleLevel(plane1, smp, coord, 0.0).rg - 0.5);
|
||||
let u = uv.x;
|
||||
let v = uv.y;
|
||||
let r = ((1.164000034 * y) + (params.vr * v));
|
||||
let g = (((1.164000034 * y) - (params.ug * u)) - (params.vg * v));
|
||||
let b = ((1.164000034 * y) + (params.ub * u));
|
||||
return vec4<f32>(r, g, b, 1.0);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
fn f(t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1 : ExternalTextureParams, s : sampler) {
|
||||
@@ -707,10 +637,7 @@ fn f(t : texture_external, s : sampler) {
|
||||
auto* expect = R"(
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
vr : f32,
|
||||
ug : f32,
|
||||
vg : f32,
|
||||
ub : f32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -723,17 +650,13 @@ fn main() {
|
||||
}
|
||||
|
||||
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)) {
|
||||
return textureSampleLevel(plane0, smp, coord, 0.0);
|
||||
color = textureSampleLevel(plane0, smp, coord, 0.0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
let y = (textureSampleLevel(plane0, smp, coord, 0.0).r - 0.0625);
|
||||
let uv = (textureSampleLevel(plane1, smp, coord, 0.0).rg - 0.5);
|
||||
let u = uv.x;
|
||||
let v = uv.y;
|
||||
let r = ((1.164000034 * y) + (params.vr * v));
|
||||
let g = (((1.164000034 * y) - (params.ug * u)) - (params.vg * v));
|
||||
let b = ((1.164000034 * y) + (params.ub * u));
|
||||
return vec4<f32>(r, g, b, 1.0);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
fn f(t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1 : ExternalTextureParams, s : sampler) {
|
||||
@@ -773,10 +696,7 @@ fn main() {
|
||||
auto* expect = R"(
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
vr : f32,
|
||||
ug : f32,
|
||||
vg : f32,
|
||||
ub : f32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -784,17 +704,13 @@ struct ExternalTextureParams {
|
||||
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
|
||||
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)) {
|
||||
return textureSampleLevel(plane0, smp, coord, 0.0);
|
||||
color = textureSampleLevel(plane0, smp, coord, 0.0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
let y = (textureSampleLevel(plane0, smp, coord, 0.0).r - 0.0625);
|
||||
let uv = (textureSampleLevel(plane1, smp, coord, 0.0).rg - 0.5);
|
||||
let u = uv.x;
|
||||
let v = uv.y;
|
||||
let r = ((1.164000034 * y) + (params.vr * v));
|
||||
let g = (((1.164000034 * y) - (params.ug * u)) - (params.vg * v));
|
||||
let b = ((1.164000034 * y) + (params.ub * u));
|
||||
return vec4<f32>(r, g, b, 1.0);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
fn f(s : sampler, t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1 : ExternalTextureParams) {
|
||||
@@ -841,10 +757,7 @@ fn main() {
|
||||
auto* expect = R"(
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
vr : f32,
|
||||
ug : f32,
|
||||
vg : f32,
|
||||
ub : f32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(3) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -856,17 +769,13 @@ struct ExternalTextureParams {
|
||||
@group(0) @binding(6) var<uniform> ext_tex_params_1 : ExternalTextureParams;
|
||||
|
||||
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)) {
|
||||
return textureSampleLevel(plane0, smp, coord, 0.0);
|
||||
color = textureSampleLevel(plane0, smp, coord, 0.0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
let y = (textureSampleLevel(plane0, smp, coord, 0.0).r - 0.0625);
|
||||
let uv = (textureSampleLevel(plane1, smp, coord, 0.0).rg - 0.5);
|
||||
let u = uv.x;
|
||||
let v = uv.y;
|
||||
let r = ((1.164000034 * y) + (params.vr * v));
|
||||
let g = (((1.164000034 * y) - (params.ug * u)) - (params.vg * v));
|
||||
let b = ((1.164000034 * y) + (params.ub * u));
|
||||
return vec4<f32>(r, g, b, 1.0);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
fn f(t : texture_2d<f32>, ext_tex_plane_1_2 : texture_2d<f32>, ext_tex_params_2 : ExternalTextureParams, s : sampler, t2 : texture_2d<f32>, ext_tex_plane_1_3 : texture_2d<f32>, ext_tex_params_3 : ExternalTextureParams) {
|
||||
@@ -919,10 +828,7 @@ fn f(t : texture_external, s : sampler, t2 : texture_external) {
|
||||
auto* expect = R"(
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
vr : f32,
|
||||
ug : f32,
|
||||
vg : f32,
|
||||
ub : f32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(3) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -939,17 +845,13 @@ fn main() {
|
||||
}
|
||||
|
||||
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)) {
|
||||
return textureSampleLevel(plane0, smp, coord, 0.0);
|
||||
color = textureSampleLevel(plane0, smp, coord, 0.0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
let y = (textureSampleLevel(plane0, smp, coord, 0.0).r - 0.0625);
|
||||
let uv = (textureSampleLevel(plane1, smp, coord, 0.0).rg - 0.5);
|
||||
let u = uv.x;
|
||||
let v = uv.y;
|
||||
let r = ((1.164000034 * y) + (params.vr * v));
|
||||
let g = (((1.164000034 * y) - (params.ug * u)) - (params.vg * v));
|
||||
let b = ((1.164000034 * y) + (params.ub * u));
|
||||
return vec4<f32>(r, g, b, 1.0);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
fn f(t : texture_2d<f32>, ext_tex_plane_1_2 : texture_2d<f32>, ext_tex_params_2 : ExternalTextureParams, s : sampler, t2 : texture_2d<f32>, ext_tex_plane_1_3 : texture_2d<f32>, ext_tex_params_3 : ExternalTextureParams) {
|
||||
@@ -997,10 +899,7 @@ fn main() {
|
||||
auto* expect = R"(
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
vr : f32,
|
||||
ug : f32,
|
||||
vg : f32,
|
||||
ub : f32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1008,17 +907,13 @@ struct ExternalTextureParams {
|
||||
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
|
||||
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)) {
|
||||
return textureSampleLevel(plane0, smp, coord, 0.0);
|
||||
color = textureSampleLevel(plane0, smp, coord, 0.0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
let y = (textureSampleLevel(plane0, smp, coord, 0.0).r - 0.0625);
|
||||
let uv = (textureSampleLevel(plane1, smp, coord, 0.0).rg - 0.5);
|
||||
let u = uv.x;
|
||||
let v = uv.y;
|
||||
let r = ((1.164000034 * y) + (params.vr * v));
|
||||
let g = (((1.164000034 * y) - (params.ug * u)) - (params.vg * v));
|
||||
let b = ((1.164000034 * y) + (params.ub * u));
|
||||
return vec4<f32>(r, g, b, 1.0);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
fn nested(t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1 : ExternalTextureParams, s : sampler) {
|
||||
@@ -1072,10 +967,7 @@ fn main() {
|
||||
auto* expect = R"(
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
vr : f32,
|
||||
ug : f32,
|
||||
vg : f32,
|
||||
ub : f32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1083,17 +975,13 @@ struct ExternalTextureParams {
|
||||
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||
|
||||
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)) {
|
||||
return textureSampleLevel(plane0, smp, coord, 0.0);
|
||||
color = textureSampleLevel(plane0, smp, coord, 0.0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
let y = (textureSampleLevel(plane0, smp, coord, 0.0).r - 0.0625);
|
||||
let uv = (textureSampleLevel(plane1, smp, coord, 0.0).rg - 0.5);
|
||||
let u = uv.x;
|
||||
let v = uv.y;
|
||||
let r = ((1.164000034 * y) + (params.vr * v));
|
||||
let g = (((1.164000034 * y) - (params.ug * u)) - (params.vg * v));
|
||||
let b = ((1.164000034 * y) + (params.ub * u));
|
||||
return vec4<f32>(r, g, b, 1.0);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
fn nested(t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1 : ExternalTextureParams, s : sampler) {
|
||||
@@ -1135,10 +1023,7 @@ fn f(ext_tex : texture_external) -> vec2<i32> {
|
||||
auto* expect = R"(
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
vr : f32,
|
||||
ug : f32,
|
||||
vg : f32,
|
||||
ub : f32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
}
|
||||
|
||||
fn f(ext_tex : texture_2d<f32>, ext_tex_plane_1 : texture_2d<f32>, ext_tex_params : ExternalTextureParams) -> vec2<i32> {
|
||||
@@ -1174,10 +1059,7 @@ fn main() {
|
||||
auto* expect = R"(
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
vr : f32,
|
||||
ug : f32,
|
||||
vg : f32,
|
||||
ub : f32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1187,17 +1069,13 @@ struct ExternalTextureParams {
|
||||
type ET = texture_external;
|
||||
|
||||
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)) {
|
||||
return textureSampleLevel(plane0, smp, coord, 0.0);
|
||||
color = textureSampleLevel(plane0, smp, coord, 0.0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
let y = (textureSampleLevel(plane0, smp, coord, 0.0).r - 0.0625);
|
||||
let uv = (textureSampleLevel(plane1, smp, coord, 0.0).rg - 0.5);
|
||||
let u = uv.x;
|
||||
let v = uv.y;
|
||||
let r = ((1.164000034 * y) + (params.vr * v));
|
||||
let g = (((1.164000034 * y) - (params.ug * u)) - (params.vg * v));
|
||||
let b = ((1.164000034 * y) + (params.ub * u));
|
||||
return vec4<f32>(r, g, b, 1.0);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
fn f(t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1 : ExternalTextureParams, s : sampler) {
|
||||
@@ -1243,10 +1121,7 @@ type ET = texture_external;
|
||||
auto* expect = R"(
|
||||
struct ExternalTextureParams {
|
||||
numPlanes : u32,
|
||||
vr : f32,
|
||||
ug : f32,
|
||||
vg : f32,
|
||||
ub : f32,
|
||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||
}
|
||||
|
||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||
@@ -1259,17 +1134,13 @@ fn main() {
|
||||
}
|
||||
|
||||
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)) {
|
||||
return textureSampleLevel(plane0, smp, coord, 0.0);
|
||||
color = textureSampleLevel(plane0, smp, coord, 0.0).rgb;
|
||||
} else {
|
||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||
}
|
||||
let y = (textureSampleLevel(plane0, smp, coord, 0.0).r - 0.0625);
|
||||
let uv = (textureSampleLevel(plane1, smp, coord, 0.0).rg - 0.5);
|
||||
let u = uv.x;
|
||||
let v = uv.y;
|
||||
let r = ((1.164000034 * y) + (params.vr * v));
|
||||
let g = (((1.164000034 * y) - (params.ug * u)) - (params.vg * v));
|
||||
let b = ((1.164000034 * y) + (params.ub * u));
|
||||
return vec4<f32>(r, g, b, 1.0);
|
||||
return vec4<f32>(color, 1.0);
|
||||
}
|
||||
|
||||
fn f(t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1 : ExternalTextureParams, s : sampler) {
|
||||
|
||||
Reference in New Issue
Block a user