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:
parent
931a4ddb1c
commit
6cb57a9847
|
@ -144,26 +144,20 @@ namespace dawn::native {
|
||||||
|
|
||||||
DAWN_TRY_ASSIGN(mParamsBuffer, device->CreateBuffer(&bufferDesc));
|
DAWN_TRY_ASSIGN(mParamsBuffer, device->CreateBuffer(&bufferDesc));
|
||||||
|
|
||||||
// Dawn & Tint's YUV to RGB conversion implementation was inspired by the conversions found
|
// Dawn & Tint's YUV-to-RGB conversion implementation is a simple 3x4 matrix multiplication
|
||||||
// in libYUV. If this implementation needs expanded to support more colorspaces, this file
|
// using a standard conversion matrix. These matrices can be found in
|
||||||
// is an excellent reference: chromium/src/third_party/libyuv/source/row_common.cc.
|
// chromium/src/third_party/skia/src/core/SkYUVMath.cpp
|
||||||
//
|
|
||||||
// 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.
|
|
||||||
ExternalTextureParams params;
|
ExternalTextureParams params;
|
||||||
params.numPlanes = descriptor->plane1 == nullptr ? 1 : 2;
|
params.numPlanes = descriptor->plane1 == nullptr ? 1 : 2;
|
||||||
|
|
||||||
switch (descriptor->colorSpace) {
|
switch (descriptor->colorSpace) {
|
||||||
case wgpu::PredefinedColorSpace::Srgb:
|
case wgpu::PredefinedColorSpace::Srgb:
|
||||||
// Numbers derived from ITU-R recommendation for limited range BT.709
|
// Conversion matrix for BT.709 limited range. Columns 1, 2 and 3 are copied
|
||||||
params.vr = 1.793;
|
// directly from the corresponding matrix in SkYUVMath.cpp. Column 4 is the range
|
||||||
params.vg = 0.392;
|
// bias (for RGB) found in column 5 of the same SkYUVMath.cpp matrix.
|
||||||
params.ub = 0.813;
|
params.yuvToRgbConversion = {1.164384f, 0.0f, 1.792741f, -0.972945f,
|
||||||
params.ug = 2.017;
|
1.164384f, -0.213249f, -0.532909f, 0.301483f,
|
||||||
|
1.164384f, 2.112402f, 0.0f, -1.133402f};
|
||||||
break;
|
break;
|
||||||
case wgpu::PredefinedColorSpace::Undefined:
|
case wgpu::PredefinedColorSpace::Undefined:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -28,10 +28,8 @@ namespace dawn::native {
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
uint32_t numPlanes;
|
uint32_t numPlanes;
|
||||||
float vr;
|
std::array<uint32_t, 3> padding;
|
||||||
float vg;
|
std::array<float, 12> yuvToRgbConversion;
|
||||||
float ub;
|
|
||||||
float ug;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
MaybeError ValidateExternalTextureDescriptor(const DeviceBase* device,
|
MaybeError ValidateExternalTextureDescriptor(const DeviceBase* device,
|
||||||
|
|
|
@ -191,10 +191,10 @@ TEST_P(ExternalTextureTests, SampleMultiplanarExternalTexture) {
|
||||||
RGBA8 rgba;
|
RGBA8 rgba;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::array<ConversionExpectation, 4> expectations = {{{0.0f, 0.5f, 0.5f, RGBA8::kBlack},
|
std::array<ConversionExpectation, 4> expectations = {{{0.0, .5, .5, RGBA8::kBlack},
|
||||||
{0.298f, 0.329f, 1.0f, RGBA8::kRed},
|
{0.2126, 0.4172, 1.0, RGBA8::kRed},
|
||||||
{0.584f, -0.168f, -0.823f, RGBA8::kGreen},
|
{0.7152, 0.1402, 0.0175, RGBA8::kGreen},
|
||||||
{0.113f, 1.0f, 0.419f, RGBA8::kBlue}}};
|
{0.0722, 1.0, 0.4937, RGBA8::kBlue}}};
|
||||||
|
|
||||||
for (ConversionExpectation expectation : expectations) {
|
for (ConversionExpectation expectation : expectations) {
|
||||||
// Initialize the texture planes with YUV data
|
// Initialize the texture planes with YUV data
|
||||||
|
|
|
@ -239,9 +239,8 @@ struct MultiplanarExternalTexture::State {
|
||||||
/// Creates the ExternalTextureParams struct.
|
/// Creates the ExternalTextureParams struct.
|
||||||
void createExtTexParamsStruct() {
|
void createExtTexParamsStruct() {
|
||||||
ast::StructMemberList member_list = {
|
ast::StructMemberList member_list = {
|
||||||
b.Member("numPlanes", b.ty.u32()), b.Member("vr", b.ty.f32()),
|
b.Member("numPlanes", b.ty.u32()),
|
||||||
b.Member("ug", b.ty.f32()), b.Member("vg", b.ty.f32()),
|
b.Member("yuvToRgbConversionMatrix", b.ty.mat3x4(b.ty.f32()))};
|
||||||
b.Member("ub", b.ty.f32())};
|
|
||||||
|
|
||||||
params_struct_sym = b.Symbols().New("ExternalTextureParams");
|
params_struct_sym = b.Symbols().New("ExternalTextureParams");
|
||||||
|
|
||||||
|
@ -280,40 +279,26 @@ struct MultiplanarExternalTexture::State {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// if (params.numPlanes == 1u) {
|
// var color: vec3<f32>;
|
||||||
// return singlePlaneCall
|
b.Decl(b.Var("color", b.ty.vec3(b.ty.f32()))),
|
||||||
// }
|
// if ((params.numPlanes == 1u))
|
||||||
b.If(b.create<ast::BinaryExpression>(
|
b.If(b.create<ast::BinaryExpression>(
|
||||||
ast::BinaryOp::kEqual, b.MemberAccessor("params", "numPlanes"),
|
ast::BinaryOp::kEqual, b.MemberAccessor("params", "numPlanes"),
|
||||||
b.Expr(1u)),
|
b.Expr(1u)),
|
||||||
b.Block(b.Return(single_plane_call))),
|
b.Block(
|
||||||
// let y = plane0Call.r - 0.0625;
|
// color = textureLoad(plane0, coord, 0).rgb;
|
||||||
b.Decl(b.Const("y", nullptr,
|
b.Assign("color", b.MemberAccessor(single_plane_call, "rgb"))),
|
||||||
b.Sub(b.MemberAccessor(plane_0_call, "r"), 0.0625f))),
|
b.Else(b.Block(
|
||||||
// let uv = plane1Call.rg - 0.5;
|
// color = vec4<f32>(plane_0_call.r, plane_1_call.rg, 1.0) *
|
||||||
b.Decl(b.Const("uv", nullptr,
|
// params.yuvToRgbConversionMatrix;
|
||||||
b.Sub(b.MemberAccessor(plane_1_call, "rg"), 0.5f))),
|
b.Assign("color",
|
||||||
// let u = uv.x;
|
b.Mul(b.vec4<f32>(
|
||||||
b.Decl(b.Const("u", nullptr, b.MemberAccessor("uv", "x"))),
|
b.MemberAccessor(plane_0_call, "r"),
|
||||||
// let v = uv.y;
|
b.MemberAccessor(plane_1_call, "rg"), 1.0f),
|
||||||
b.Decl(b.Const("v", nullptr, b.MemberAccessor("uv", "y"))),
|
b.MemberAccessor(
|
||||||
// let r = 1.164 * y + params.vr * v;
|
"params", "yuvToRgbConversionMatrix")))))),
|
||||||
b.Decl(b.Const("r", nullptr,
|
// return vec4<f32>(color, 1.0f);
|
||||||
b.Add(b.Mul(1.164f, "y"),
|
b.Return(b.vec4<f32>("color", 1.0f))};
|
||||||
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)),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates the textureSampleExternal function if needed and returns a call
|
/// 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"(
|
auto* expect = R"(
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
vr : f32,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
ug : f32,
|
|
||||||
vg : f32,
|
|
||||||
ub : f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<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"(
|
auto* expect = R"(
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
vr : f32,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
ug : f32,
|
|
||||||
vg : f32,
|
|
||||||
ub : f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<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"(
|
auto* expect = R"(
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
vr : f32,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
ug : f32,
|
|
||||||
vg : f32,
|
|
||||||
ub : f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<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>;
|
@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> {
|
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)) {
|
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);
|
return vec4<f32>(color, 1.0);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@stage(fragment)
|
@stage(fragment)
|
||||||
|
@ -249,10 +236,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
vr : f32,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
ug : f32,
|
|
||||||
vg : f32,
|
|
||||||
ub : f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<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;
|
@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> {
|
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)) {
|
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);
|
return vec4<f32>(color, 1.0);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@stage(fragment)
|
@stage(fragment)
|
||||||
|
@ -304,10 +284,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
vr : f32,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
ug : f32,
|
|
||||||
vg : f32,
|
|
||||||
ub : f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<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>;
|
@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> {
|
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)) {
|
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);
|
return vec4<f32>(color, 1.0);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@stage(fragment)
|
@stage(fragment)
|
||||||
|
@ -357,10 +330,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
vr : f32,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
ug : f32,
|
|
||||||
vg : f32,
|
|
||||||
ub : f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<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;
|
@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> {
|
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)) {
|
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);
|
return vec4<f32>(color, 1.0);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@stage(fragment)
|
@stage(fragment)
|
||||||
|
@ -412,10 +378,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
vr : f32,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
ug : f32,
|
|
||||||
vg : f32,
|
|
||||||
ub : f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<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>;
|
@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> {
|
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)) {
|
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);
|
return vec4<f32>(color, 1.0);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<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)) {
|
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);
|
return vec4<f32>(color, 1.0);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@stage(fragment)
|
@stage(fragment)
|
||||||
|
@ -483,10 +438,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
vr : f32,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
ug : f32,
|
|
||||||
vg : f32,
|
|
||||||
ub : f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<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;
|
@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> {
|
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)) {
|
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);
|
return vec4<f32>(color, 1.0);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<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)) {
|
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);
|
return vec4<f32>(color, 1.0);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@stage(fragment)
|
@stage(fragment)
|
||||||
|
@ -556,10 +500,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
vr : f32,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
ug : f32,
|
|
||||||
vg : f32,
|
|
||||||
ub : f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(4) var ext_tex_plane_1 : texture_2d<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>;
|
@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> {
|
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)) {
|
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);
|
return vec4<f32>(color, 1.0);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@stage(fragment)
|
@stage(fragment)
|
||||||
|
@ -640,10 +577,7 @@ fn main() {
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
vr : f32,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
ug : f32,
|
|
||||||
vg : f32,
|
|
||||||
ub : f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<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;
|
@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> {
|
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)) {
|
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);
|
return vec4<f32>(color, 1.0);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn f(t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1 : ExternalTextureParams, s : sampler) {
|
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"(
|
auto* expect = R"(
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
vr : f32,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
ug : f32,
|
|
||||||
vg : f32,
|
|
||||||
ub : f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<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> {
|
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)) {
|
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);
|
return vec4<f32>(color, 1.0);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn f(t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1 : ExternalTextureParams, s : sampler) {
|
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"(
|
auto* expect = R"(
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
vr : f32,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
ug : f32,
|
|
||||||
vg : f32,
|
|
||||||
ub : f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<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;
|
@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> {
|
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)) {
|
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);
|
return vec4<f32>(color, 1.0);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn f(s : sampler, t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1 : ExternalTextureParams) {
|
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"(
|
auto* expect = R"(
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
vr : f32,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
ug : f32,
|
|
||||||
vg : f32,
|
|
||||||
ub : f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(3) var ext_tex_plane_1 : texture_2d<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;
|
@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> {
|
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)) {
|
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);
|
return vec4<f32>(color, 1.0);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
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"(
|
auto* expect = R"(
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
vr : f32,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
ug : f32,
|
|
||||||
vg : f32,
|
|
||||||
ub : f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(3) var ext_tex_plane_1 : texture_2d<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> {
|
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)) {
|
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);
|
return vec4<f32>(color, 1.0);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
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"(
|
auto* expect = R"(
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
vr : f32,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
ug : f32,
|
|
||||||
vg : f32,
|
|
||||||
ub : f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<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;
|
@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> {
|
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)) {
|
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);
|
return vec4<f32>(color, 1.0);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn nested(t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1 : ExternalTextureParams, s : sampler) {
|
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"(
|
auto* expect = R"(
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
vr : f32,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
ug : f32,
|
|
||||||
vg : f32,
|
|
||||||
ub : f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<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;
|
@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> {
|
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)) {
|
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);
|
return vec4<f32>(color, 1.0);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn nested(t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1 : ExternalTextureParams, s : sampler) {
|
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"(
|
auto* expect = R"(
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
vr : f32,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
ug : f32,
|
|
||||||
vg : f32,
|
|
||||||
ub : f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn f(ext_tex : texture_2d<f32>, ext_tex_plane_1 : texture_2d<f32>, ext_tex_params : ExternalTextureParams) -> vec2<i32> {
|
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"(
|
auto* expect = R"(
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
vr : f32,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
ug : f32,
|
|
||||||
vg : f32,
|
|
||||||
ub : f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||||
|
@ -1187,17 +1069,13 @@ struct ExternalTextureParams {
|
||||||
type ET = texture_external;
|
type ET = texture_external;
|
||||||
|
|
||||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<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)) {
|
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);
|
return vec4<f32>(color, 1.0);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn f(t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1 : ExternalTextureParams, s : sampler) {
|
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"(
|
auto* expect = R"(
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
vr : f32,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
ug : f32,
|
|
||||||
vg : f32,
|
|
||||||
ub : f32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<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> {
|
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)) {
|
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);
|
return vec4<f32>(color, 1.0);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn f(t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1 : ExternalTextureParams, s : sampler) {
|
fn f(t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1 : ExternalTextureParams, s : sampler) {
|
||||||
|
|
|
@ -2,18 +2,12 @@
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
uint numPlanes;
|
uint numPlanes;
|
||||||
float vr;
|
mat3x4 yuvToRgbConversionMatrix;
|
||||||
float ug;
|
|
||||||
float vg;
|
|
||||||
float ub;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
layout(binding = 2) uniform ExternalTextureParams_1 {
|
layout(binding = 2) uniform ExternalTextureParams_1 {
|
||||||
uint numPlanes;
|
uint numPlanes;
|
||||||
float vr;
|
mat3x4 yuvToRgbConversionMatrix;
|
||||||
float ug;
|
|
||||||
float vg;
|
|
||||||
float ub;
|
|
||||||
} ext_tex_params;
|
} ext_tex_params;
|
||||||
|
|
||||||
uniform highp sampler2D arg_0_1;
|
uniform highp sampler2D arg_0_1;
|
||||||
|
@ -38,18 +32,12 @@ precision mediump float;
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
uint numPlanes;
|
uint numPlanes;
|
||||||
float vr;
|
mat3x4 yuvToRgbConversionMatrix;
|
||||||
float ug;
|
|
||||||
float vg;
|
|
||||||
float ub;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
layout(binding = 2) uniform ExternalTextureParams_1 {
|
layout(binding = 2) uniform ExternalTextureParams_1 {
|
||||||
uint numPlanes;
|
uint numPlanes;
|
||||||
float vr;
|
mat3x4 yuvToRgbConversionMatrix;
|
||||||
float ug;
|
|
||||||
float vg;
|
|
||||||
float ub;
|
|
||||||
} ext_tex_params;
|
} ext_tex_params;
|
||||||
|
|
||||||
uniform highp sampler2D arg_0_1;
|
uniform highp sampler2D arg_0_1;
|
||||||
|
@ -69,18 +57,12 @@ void main() {
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
uint numPlanes;
|
uint numPlanes;
|
||||||
float vr;
|
mat3x4 yuvToRgbConversionMatrix;
|
||||||
float ug;
|
|
||||||
float vg;
|
|
||||||
float ub;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
layout(binding = 2) uniform ExternalTextureParams_1 {
|
layout(binding = 2) uniform ExternalTextureParams_1 {
|
||||||
uint numPlanes;
|
uint numPlanes;
|
||||||
float vr;
|
mat3x4 yuvToRgbConversionMatrix;
|
||||||
float ug;
|
|
||||||
float vg;
|
|
||||||
float ub;
|
|
||||||
} ext_tex_params;
|
} ext_tex_params;
|
||||||
|
|
||||||
uniform highp sampler2D arg_0_1;
|
uniform highp sampler2D arg_0_1;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Texture2D<float4> ext_tex_plane_1 : register(t1, space1);
|
Texture2D<float4> ext_tex_plane_1 : register(t1, space1);
|
||||||
cbuffer cbuffer_ext_tex_params : register(b2, space1) {
|
cbuffer cbuffer_ext_tex_params : register(b2, space1) {
|
||||||
uint4 ext_tex_params[2];
|
uint4 ext_tex_params[4];
|
||||||
};
|
};
|
||||||
Texture2D<float4> arg_0 : register(t0, space1);
|
Texture2D<float4> arg_0 : register(t0, space1);
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,7 @@
|
||||||
using namespace metal;
|
using namespace metal;
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
uint numPlanes;
|
uint numPlanes;
|
||||||
float vr;
|
float3x4 yuvToRgbConversionMatrix;
|
||||||
float ug;
|
|
||||||
float vg;
|
|
||||||
float ub;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void textureDimensions_ba1481(texture2d<float, access::sample> tint_symbol_1) {
|
void textureDimensions_ba1481(texture2d<float, access::sample> tint_symbol_1) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
; SPIR-V
|
; SPIR-V
|
||||||
; Version: 1.3
|
; Version: 1.3
|
||||||
; Generator: Google Tint Compiler; 0
|
; Generator: Google Tint Compiler; 0
|
||||||
; Bound: 43
|
; Bound: 44
|
||||||
; Schema: 0
|
; Schema: 0
|
||||||
OpCapability Shader
|
OpCapability Shader
|
||||||
OpCapability ImageQuery
|
OpCapability ImageQuery
|
||||||
|
@ -16,10 +16,7 @@
|
||||||
OpName %ext_tex_plane_1 "ext_tex_plane_1"
|
OpName %ext_tex_plane_1 "ext_tex_plane_1"
|
||||||
OpName %ExternalTextureParams "ExternalTextureParams"
|
OpName %ExternalTextureParams "ExternalTextureParams"
|
||||||
OpMemberName %ExternalTextureParams 0 "numPlanes"
|
OpMemberName %ExternalTextureParams 0 "numPlanes"
|
||||||
OpMemberName %ExternalTextureParams 1 "vr"
|
OpMemberName %ExternalTextureParams 1 "yuvToRgbConversionMatrix"
|
||||||
OpMemberName %ExternalTextureParams 2 "ug"
|
|
||||||
OpMemberName %ExternalTextureParams 3 "vg"
|
|
||||||
OpMemberName %ExternalTextureParams 4 "ub"
|
|
||||||
OpName %ext_tex_params "ext_tex_params"
|
OpName %ext_tex_params "ext_tex_params"
|
||||||
OpName %arg_0 "arg_0"
|
OpName %arg_0 "arg_0"
|
||||||
OpName %textureDimensions_ba1481 "textureDimensions_ba1481"
|
OpName %textureDimensions_ba1481 "textureDimensions_ba1481"
|
||||||
|
@ -34,10 +31,9 @@
|
||||||
OpDecorate %ext_tex_plane_1 Binding 1
|
OpDecorate %ext_tex_plane_1 Binding 1
|
||||||
OpDecorate %ExternalTextureParams Block
|
OpDecorate %ExternalTextureParams Block
|
||||||
OpMemberDecorate %ExternalTextureParams 0 Offset 0
|
OpMemberDecorate %ExternalTextureParams 0 Offset 0
|
||||||
OpMemberDecorate %ExternalTextureParams 1 Offset 4
|
OpMemberDecorate %ExternalTextureParams 1 Offset 16
|
||||||
OpMemberDecorate %ExternalTextureParams 2 Offset 8
|
OpMemberDecorate %ExternalTextureParams 1 ColMajor
|
||||||
OpMemberDecorate %ExternalTextureParams 3 Offset 12
|
OpMemberDecorate %ExternalTextureParams 1 MatrixStride 16
|
||||||
OpMemberDecorate %ExternalTextureParams 4 Offset 16
|
|
||||||
OpDecorate %ext_tex_params NonWritable
|
OpDecorate %ext_tex_params NonWritable
|
||||||
OpDecorate %ext_tex_params DescriptorSet 1
|
OpDecorate %ext_tex_params DescriptorSet 1
|
||||||
OpDecorate %ext_tex_params Binding 2
|
OpDecorate %ext_tex_params Binding 2
|
||||||
|
@ -55,46 +51,47 @@
|
||||||
%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
|
%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
|
||||||
%ext_tex_plane_1 = OpVariable %_ptr_UniformConstant_11 UniformConstant
|
%ext_tex_plane_1 = OpVariable %_ptr_UniformConstant_11 UniformConstant
|
||||||
%uint = OpTypeInt 32 0
|
%uint = OpTypeInt 32 0
|
||||||
%ExternalTextureParams = OpTypeStruct %uint %float %float %float %float
|
%mat3v4float = OpTypeMatrix %v4float 3
|
||||||
|
%ExternalTextureParams = OpTypeStruct %uint %mat3v4float
|
||||||
%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams
|
%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams
|
||||||
%ext_tex_params = OpVariable %_ptr_Uniform_ExternalTextureParams Uniform
|
%ext_tex_params = OpVariable %_ptr_Uniform_ExternalTextureParams Uniform
|
||||||
%arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant
|
%arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant
|
||||||
%void = OpTypeVoid
|
%void = OpTypeVoid
|
||||||
%17 = OpTypeFunction %void
|
%18 = OpTypeFunction %void
|
||||||
%int = OpTypeInt 32 1
|
%int = OpTypeInt 32 1
|
||||||
%v2int = OpTypeVector %int 2
|
%v2int = OpTypeVector %int 2
|
||||||
%int_0 = OpConstant %int 0
|
%int_0 = OpConstant %int 0
|
||||||
%_ptr_Function_v2int = OpTypePointer Function %v2int
|
%_ptr_Function_v2int = OpTypePointer Function %v2int
|
||||||
%28 = OpConstantNull %v2int
|
%29 = OpConstantNull %v2int
|
||||||
%29 = OpTypeFunction %v4float
|
%30 = OpTypeFunction %v4float
|
||||||
%float_1 = OpConstant %float 1
|
%float_1 = OpConstant %float 1
|
||||||
%textureDimensions_ba1481 = OpFunction %void None %17
|
%textureDimensions_ba1481 = OpFunction %void None %18
|
||||||
%20 = OpLabel
|
%21 = OpLabel
|
||||||
%res = OpVariable %_ptr_Function_v2int Function %28
|
%res = OpVariable %_ptr_Function_v2int Function %29
|
||||||
%24 = OpLoad %11 %arg_0
|
%25 = OpLoad %11 %arg_0
|
||||||
%21 = OpImageQuerySizeLod %v2int %24 %int_0
|
%22 = OpImageQuerySizeLod %v2int %25 %int_0
|
||||||
OpStore %res %21
|
OpStore %res %22
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%vertex_main_inner = OpFunction %v4float None %29
|
%vertex_main_inner = OpFunction %v4float None %30
|
||||||
%31 = OpLabel
|
%32 = OpLabel
|
||||||
%32 = OpFunctionCall %void %textureDimensions_ba1481
|
%33 = OpFunctionCall %void %textureDimensions_ba1481
|
||||||
OpReturnValue %5
|
OpReturnValue %5
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%vertex_main = OpFunction %void None %17
|
%vertex_main = OpFunction %void None %18
|
||||||
%34 = OpLabel
|
%35 = OpLabel
|
||||||
%35 = OpFunctionCall %v4float %vertex_main_inner
|
%36 = OpFunctionCall %v4float %vertex_main_inner
|
||||||
OpStore %value %35
|
OpStore %value %36
|
||||||
OpStore %vertex_point_size %float_1
|
OpStore %vertex_point_size %float_1
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%fragment_main = OpFunction %void None %17
|
%fragment_main = OpFunction %void None %18
|
||||||
%38 = OpLabel
|
%39 = OpLabel
|
||||||
%39 = OpFunctionCall %void %textureDimensions_ba1481
|
%40 = OpFunctionCall %void %textureDimensions_ba1481
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%compute_main = OpFunction %void None %17
|
%compute_main = OpFunction %void None %18
|
||||||
%41 = OpLabel
|
%42 = OpLabel
|
||||||
%42 = OpFunctionCall %void %textureDimensions_ba1481
|
%43 = OpFunctionCall %void %textureDimensions_ba1481
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
|
|
|
@ -1,39 +1,35 @@
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
uint numPlanes;
|
uint numPlanes;
|
||||||
float vr;
|
float3x4 yuvToRgbConversionMatrix;
|
||||||
float ug;
|
|
||||||
float vg;
|
|
||||||
float ub;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Texture2D<float4> ext_tex_plane_1 : register(t1, space1);
|
Texture2D<float4> ext_tex_plane_1 : register(t1, space1);
|
||||||
cbuffer cbuffer_ext_tex_params : register(b2, space1) {
|
cbuffer cbuffer_ext_tex_params : register(b2, space1) {
|
||||||
uint4 ext_tex_params[2];
|
uint4 ext_tex_params[4];
|
||||||
};
|
};
|
||||||
Texture2D<float4> arg_0 : register(t0, space1);
|
Texture2D<float4> arg_0 : register(t0, space1);
|
||||||
|
|
||||||
float4 textureLoadExternal(Texture2D<float4> plane0, Texture2D<float4> plane1, int2 coord, ExternalTextureParams params) {
|
float4 textureLoadExternal(Texture2D<float4> plane0, Texture2D<float4> plane1, int2 coord, ExternalTextureParams params) {
|
||||||
|
float3 color = float3(0.0f, 0.0f, 0.0f);
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
return plane0.Load(int3(coord, 0));
|
color = plane0.Load(int3(coord, 0)).rgb;
|
||||||
|
} else {
|
||||||
|
color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord, 0)).rg, 1.0f));
|
||||||
}
|
}
|
||||||
const float y = (plane0.Load(int3(coord, 0)).r - 0.0625f);
|
return float4(color, 1.0f);
|
||||||
const float2 uv = (plane1.Load(int3(coord, 0)).rg - 0.5f);
|
|
||||||
const float u = uv.x;
|
|
||||||
const float v = uv.y;
|
|
||||||
const float r = ((1.164000034f * y) + (params.vr * v));
|
|
||||||
const float g = (((1.164000034f * y) - (params.ug * u)) - (params.vg * v));
|
|
||||||
const float b = ((1.164000034f * y) + (params.ub * u));
|
|
||||||
return float4(r, g, b, 1.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ExternalTextureParams tint_symbol_1(uint4 buffer[2], uint offset) {
|
float3x4 tint_symbol_3(uint4 buffer[4], uint offset) {
|
||||||
const uint scalar_offset = ((offset + 0u)) / 4;
|
const uint scalar_offset = ((offset + 0u)) / 4;
|
||||||
const uint scalar_offset_1 = ((offset + 4u)) / 4;
|
const uint scalar_offset_1 = ((offset + 16u)) / 4;
|
||||||
const uint scalar_offset_2 = ((offset + 8u)) / 4;
|
const uint scalar_offset_2 = ((offset + 32u)) / 4;
|
||||||
const uint scalar_offset_3 = ((offset + 12u)) / 4;
|
return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
|
||||||
const uint scalar_offset_4 = ((offset + 16u)) / 4;
|
}
|
||||||
const ExternalTextureParams tint_symbol_4 = {buffer[scalar_offset / 4][scalar_offset % 4], asfloat(buffer[scalar_offset_1 / 4][scalar_offset_1 % 4]), asfloat(buffer[scalar_offset_2 / 4][scalar_offset_2 % 4]), asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4])};
|
|
||||||
return tint_symbol_4;
|
ExternalTextureParams tint_symbol_1(uint4 buffer[4], uint offset) {
|
||||||
|
const uint scalar_offset_3 = ((offset + 0u)) / 4;
|
||||||
|
const ExternalTextureParams tint_symbol_5 = {buffer[scalar_offset_3 / 4][scalar_offset_3 % 4], tint_symbol_3(buffer, (offset + 16u))};
|
||||||
|
return tint_symbol_5;
|
||||||
}
|
}
|
||||||
|
|
||||||
void textureLoad_8acf41() {
|
void textureLoad_8acf41() {
|
||||||
|
|
|
@ -3,24 +3,18 @@
|
||||||
using namespace metal;
|
using namespace metal;
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
/* 0x0000 */ uint numPlanes;
|
/* 0x0000 */ uint numPlanes;
|
||||||
/* 0x0004 */ float vr;
|
/* 0x0004 */ int8_t tint_pad[12];
|
||||||
/* 0x0008 */ float ug;
|
/* 0x0010 */ float3x4 yuvToRgbConversionMatrix;
|
||||||
/* 0x000c */ float vg;
|
|
||||||
/* 0x0010 */ float ub;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
float4 textureLoadExternal(texture2d<float, access::sample> plane0, texture2d<float, access::sample> plane1, int2 coord, ExternalTextureParams params) {
|
float4 textureLoadExternal(texture2d<float, access::sample> plane0, texture2d<float, access::sample> plane1, int2 coord, ExternalTextureParams params) {
|
||||||
|
float3 color = 0.0f;
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
return plane0.read(uint2(coord), 0);
|
color = float4(plane0.read(uint2(coord), 0)).rgb;
|
||||||
|
} else {
|
||||||
|
color = (float4(plane0.read(uint2(coord), 0)[0], float4(plane1.read(uint2(coord), 0)).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
float const y = (plane0.read(uint2(coord), 0)[0] - 0.0625f);
|
return float4(color, 1.0f);
|
||||||
float2 const uv = (float4(plane1.read(uint2(coord), 0)).rg - 0.5f);
|
|
||||||
float const u = uv[0];
|
|
||||||
float const v = uv[1];
|
|
||||||
float const r = ((1.164000034f * y) + (params.vr * v));
|
|
||||||
float const g = (((1.164000034f * y) - (params.ug * u)) - (params.vg * v));
|
|
||||||
float const b = ((1.164000034f * y) + (params.ub * u));
|
|
||||||
return float4(r, g, b, 1.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void textureLoad_8acf41(texture2d<float, access::sample> tint_symbol_1, texture2d<float, access::sample> tint_symbol_2, const constant ExternalTextureParams* const tint_symbol_3) {
|
void textureLoad_8acf41(texture2d<float, access::sample> tint_symbol_1, texture2d<float, access::sample> tint_symbol_2, const constant ExternalTextureParams* const tint_symbol_3) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
; SPIR-V
|
; SPIR-V
|
||||||
; Version: 1.3
|
; Version: 1.3
|
||||||
; Generator: Google Tint Compiler; 0
|
; Generator: Google Tint Compiler; 0
|
||||||
; Bound: 91
|
; Bound: 81
|
||||||
; Schema: 0
|
; Schema: 0
|
||||||
OpCapability Shader
|
OpCapability Shader
|
||||||
OpMemoryModel Logical GLSL450
|
OpMemoryModel Logical GLSL450
|
||||||
|
@ -15,10 +15,7 @@
|
||||||
OpName %ext_tex_plane_1 "ext_tex_plane_1"
|
OpName %ext_tex_plane_1 "ext_tex_plane_1"
|
||||||
OpName %ExternalTextureParams "ExternalTextureParams"
|
OpName %ExternalTextureParams "ExternalTextureParams"
|
||||||
OpMemberName %ExternalTextureParams 0 "numPlanes"
|
OpMemberName %ExternalTextureParams 0 "numPlanes"
|
||||||
OpMemberName %ExternalTextureParams 1 "vr"
|
OpMemberName %ExternalTextureParams 1 "yuvToRgbConversionMatrix"
|
||||||
OpMemberName %ExternalTextureParams 2 "ug"
|
|
||||||
OpMemberName %ExternalTextureParams 3 "vg"
|
|
||||||
OpMemberName %ExternalTextureParams 4 "ub"
|
|
||||||
OpName %ext_tex_params "ext_tex_params"
|
OpName %ext_tex_params "ext_tex_params"
|
||||||
OpName %arg_0 "arg_0"
|
OpName %arg_0 "arg_0"
|
||||||
OpName %textureLoadExternal "textureLoadExternal"
|
OpName %textureLoadExternal "textureLoadExternal"
|
||||||
|
@ -26,6 +23,7 @@
|
||||||
OpName %plane1 "plane1"
|
OpName %plane1 "plane1"
|
||||||
OpName %coord "coord"
|
OpName %coord "coord"
|
||||||
OpName %params "params"
|
OpName %params "params"
|
||||||
|
OpName %color "color"
|
||||||
OpName %textureLoad_8acf41 "textureLoad_8acf41"
|
OpName %textureLoad_8acf41 "textureLoad_8acf41"
|
||||||
OpName %res "res"
|
OpName %res "res"
|
||||||
OpName %vertex_main_inner "vertex_main_inner"
|
OpName %vertex_main_inner "vertex_main_inner"
|
||||||
|
@ -38,10 +36,9 @@
|
||||||
OpDecorate %ext_tex_plane_1 Binding 1
|
OpDecorate %ext_tex_plane_1 Binding 1
|
||||||
OpDecorate %ExternalTextureParams Block
|
OpDecorate %ExternalTextureParams Block
|
||||||
OpMemberDecorate %ExternalTextureParams 0 Offset 0
|
OpMemberDecorate %ExternalTextureParams 0 Offset 0
|
||||||
OpMemberDecorate %ExternalTextureParams 1 Offset 4
|
OpMemberDecorate %ExternalTextureParams 1 Offset 16
|
||||||
OpMemberDecorate %ExternalTextureParams 2 Offset 8
|
OpMemberDecorate %ExternalTextureParams 1 ColMajor
|
||||||
OpMemberDecorate %ExternalTextureParams 3 Offset 12
|
OpMemberDecorate %ExternalTextureParams 1 MatrixStride 16
|
||||||
OpMemberDecorate %ExternalTextureParams 4 Offset 16
|
|
||||||
OpDecorate %ext_tex_params NonWritable
|
OpDecorate %ext_tex_params NonWritable
|
||||||
OpDecorate %ext_tex_params DescriptorSet 1
|
OpDecorate %ext_tex_params DescriptorSet 1
|
||||||
OpDecorate %ext_tex_params Binding 2
|
OpDecorate %ext_tex_params Binding 2
|
||||||
|
@ -59,99 +56,92 @@
|
||||||
%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
|
%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
|
||||||
%ext_tex_plane_1 = OpVariable %_ptr_UniformConstant_11 UniformConstant
|
%ext_tex_plane_1 = OpVariable %_ptr_UniformConstant_11 UniformConstant
|
||||||
%uint = OpTypeInt 32 0
|
%uint = OpTypeInt 32 0
|
||||||
%ExternalTextureParams = OpTypeStruct %uint %float %float %float %float
|
%mat3v4float = OpTypeMatrix %v4float 3
|
||||||
|
%ExternalTextureParams = OpTypeStruct %uint %mat3v4float
|
||||||
%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams
|
%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams
|
||||||
%ext_tex_params = OpVariable %_ptr_Uniform_ExternalTextureParams Uniform
|
%ext_tex_params = OpVariable %_ptr_Uniform_ExternalTextureParams Uniform
|
||||||
%arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant
|
%arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant
|
||||||
%int = OpTypeInt 32 1
|
%int = OpTypeInt 32 1
|
||||||
%v2int = OpTypeVector %int 2
|
%v2int = OpTypeVector %int 2
|
||||||
%17 = OpTypeFunction %v4float %11 %11 %v2int %ExternalTextureParams
|
%18 = OpTypeFunction %v4float %11 %11 %v2int %ExternalTextureParams
|
||||||
|
%v3float = OpTypeVector %float 3
|
||||||
|
%_ptr_Function_v3float = OpTypePointer Function %v3float
|
||||||
|
%30 = OpConstantNull %v3float
|
||||||
%uint_1 = OpConstant %uint 1
|
%uint_1 = OpConstant %uint 1
|
||||||
%bool = OpTypeBool
|
%bool = OpTypeBool
|
||||||
%int_0 = OpConstant %int 0
|
%int_0 = OpConstant %int 0
|
||||||
%float_0_0625 = OpConstant %float 0.0625
|
|
||||||
%v2float = OpTypeVector %float 2
|
%v2float = OpTypeVector %float 2
|
||||||
%float_0_5 = OpConstant %float 0.5
|
|
||||||
%_ptr_Function_v2float = OpTypePointer Function %v2float
|
|
||||||
%45 = OpConstantNull %v2float
|
|
||||||
%float_1_16400003 = OpConstant %float 1.16400003
|
|
||||||
%float_1 = OpConstant %float 1
|
%float_1 = OpConstant %float 1
|
||||||
%void = OpTypeVoid
|
%void = OpTypeVoid
|
||||||
%67 = OpTypeFunction %void
|
%57 = OpTypeFunction %void
|
||||||
%74 = OpConstantNull %v2int
|
%64 = OpConstantNull %v2int
|
||||||
%_ptr_Function_v4float = OpTypePointer Function %v4float
|
%_ptr_Function_v4float = OpTypePointer Function %v4float
|
||||||
%78 = OpTypeFunction %v4float
|
%68 = OpTypeFunction %v4float
|
||||||
%textureLoadExternal = OpFunction %v4float None %17
|
%textureLoadExternal = OpFunction %v4float None %18
|
||||||
%plane0 = OpFunctionParameter %11
|
%plane0 = OpFunctionParameter %11
|
||||||
%plane1 = OpFunctionParameter %11
|
%plane1 = OpFunctionParameter %11
|
||||||
%coord = OpFunctionParameter %v2int
|
%coord = OpFunctionParameter %v2int
|
||||||
%params = OpFunctionParameter %ExternalTextureParams
|
%params = OpFunctionParameter %ExternalTextureParams
|
||||||
%25 = OpLabel
|
%26 = OpLabel
|
||||||
%43 = OpVariable %_ptr_Function_v2float Function %45
|
%color = OpVariable %_ptr_Function_v3float Function %30
|
||||||
%26 = OpCompositeExtract %uint %params 0
|
%31 = OpCompositeExtract %uint %params 0
|
||||||
%28 = OpIEqual %bool %26 %uint_1
|
%33 = OpIEqual %bool %31 %uint_1
|
||||||
OpSelectionMerge %30 None
|
OpSelectionMerge %35 None
|
||||||
OpBranchConditional %28 %31 %30
|
OpBranchConditional %33 %36 %37
|
||||||
%31 = OpLabel
|
%36 = OpLabel
|
||||||
%32 = OpImageFetch %v4float %plane0 %coord Lod %int_0
|
%38 = OpImageFetch %v4float %plane0 %coord Lod %int_0
|
||||||
OpReturnValue %32
|
%40 = OpVectorShuffle %v3float %38 %38 0 1 2
|
||||||
%30 = OpLabel
|
OpStore %color %40
|
||||||
%34 = OpImageFetch %v4float %plane0 %coord Lod %int_0
|
OpBranch %35
|
||||||
%35 = OpCompositeExtract %float %34 0
|
%37 = OpLabel
|
||||||
%37 = OpFSub %float %35 %float_0_0625
|
%41 = OpImageFetch %v4float %plane0 %coord Lod %int_0
|
||||||
%38 = OpImageFetch %v4float %plane1 %coord Lod %int_0
|
%42 = OpCompositeExtract %float %41 0
|
||||||
%40 = OpVectorShuffle %v2float %38 %38 0 1
|
%43 = OpImageFetch %v4float %plane1 %coord Lod %int_0
|
||||||
%46 = OpCompositeConstruct %v2float %float_0_5 %float_0_5
|
%45 = OpVectorShuffle %v2float %43 %43 0 1
|
||||||
%42 = OpFSub %v2float %40 %46
|
%46 = OpCompositeExtract %float %45 0
|
||||||
%47 = OpCompositeExtract %float %42 0
|
%47 = OpCompositeExtract %float %45 1
|
||||||
%48 = OpCompositeExtract %float %42 1
|
%49 = OpCompositeConstruct %v4float %42 %46 %47 %float_1
|
||||||
%50 = OpFMul %float %float_1_16400003 %37
|
%50 = OpCompositeExtract %mat3v4float %params 1
|
||||||
%51 = OpCompositeExtract %float %params 1
|
%51 = OpVectorTimesMatrix %v3float %49 %50
|
||||||
%52 = OpFMul %float %51 %48
|
OpStore %color %51
|
||||||
%53 = OpFAdd %float %50 %52
|
OpBranch %35
|
||||||
%54 = OpFMul %float %float_1_16400003 %37
|
%35 = OpLabel
|
||||||
%55 = OpCompositeExtract %float %params 2
|
%52 = OpLoad %v3float %color
|
||||||
%56 = OpFMul %float %55 %47
|
%53 = OpCompositeExtract %float %52 0
|
||||||
%57 = OpFSub %float %54 %56
|
%54 = OpCompositeExtract %float %52 1
|
||||||
%58 = OpCompositeExtract %float %params 3
|
%55 = OpCompositeExtract %float %52 2
|
||||||
%59 = OpFMul %float %58 %48
|
%56 = OpCompositeConstruct %v4float %53 %54 %55 %float_1
|
||||||
%60 = OpFSub %float %57 %59
|
OpReturnValue %56
|
||||||
%61 = OpFMul %float %float_1_16400003 %37
|
|
||||||
%62 = OpCompositeExtract %float %params 4
|
|
||||||
%63 = OpFMul %float %62 %47
|
|
||||||
%64 = OpFAdd %float %61 %63
|
|
||||||
%66 = OpCompositeConstruct %v4float %53 %60 %64 %float_1
|
|
||||||
OpReturnValue %66
|
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%textureLoad_8acf41 = OpFunction %void None %67
|
%textureLoad_8acf41 = OpFunction %void None %57
|
||||||
%70 = OpLabel
|
%60 = OpLabel
|
||||||
%res = OpVariable %_ptr_Function_v4float Function %5
|
%res = OpVariable %_ptr_Function_v4float Function %5
|
||||||
%72 = OpLoad %11 %arg_0
|
%62 = OpLoad %11 %arg_0
|
||||||
%73 = OpLoad %11 %ext_tex_plane_1
|
%63 = OpLoad %11 %ext_tex_plane_1
|
||||||
%75 = OpLoad %ExternalTextureParams %ext_tex_params
|
%65 = OpLoad %ExternalTextureParams %ext_tex_params
|
||||||
%71 = OpFunctionCall %v4float %textureLoadExternal %72 %73 %74 %75
|
%61 = OpFunctionCall %v4float %textureLoadExternal %62 %63 %64 %65
|
||||||
OpStore %res %71
|
OpStore %res %61
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%vertex_main_inner = OpFunction %v4float None %78
|
%vertex_main_inner = OpFunction %v4float None %68
|
||||||
%80 = OpLabel
|
%70 = OpLabel
|
||||||
%81 = OpFunctionCall %void %textureLoad_8acf41
|
%71 = OpFunctionCall %void %textureLoad_8acf41
|
||||||
OpReturnValue %5
|
OpReturnValue %5
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%vertex_main = OpFunction %void None %67
|
%vertex_main = OpFunction %void None %57
|
||||||
%83 = OpLabel
|
%73 = OpLabel
|
||||||
%84 = OpFunctionCall %v4float %vertex_main_inner
|
%74 = OpFunctionCall %v4float %vertex_main_inner
|
||||||
OpStore %value %84
|
OpStore %value %74
|
||||||
OpStore %vertex_point_size %float_1
|
OpStore %vertex_point_size %float_1
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%fragment_main = OpFunction %void None %67
|
%fragment_main = OpFunction %void None %57
|
||||||
%86 = OpLabel
|
%76 = OpLabel
|
||||||
%87 = OpFunctionCall %void %textureLoad_8acf41
|
%77 = OpFunctionCall %void %textureLoad_8acf41
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%compute_main = OpFunction %void None %67
|
%compute_main = OpFunction %void None %57
|
||||||
%89 = OpLabel
|
%79 = OpLabel
|
||||||
%90 = OpFunctionCall %void %textureLoad_8acf41
|
%80 = OpFunctionCall %void %textureLoad_8acf41
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
|
|
|
@ -1,40 +1,36 @@
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
uint numPlanes;
|
uint numPlanes;
|
||||||
float vr;
|
float3x4 yuvToRgbConversionMatrix;
|
||||||
float ug;
|
|
||||||
float vg;
|
|
||||||
float ub;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Texture2D<float4> ext_tex_plane_1 : register(t2, space1);
|
Texture2D<float4> ext_tex_plane_1 : register(t2, space1);
|
||||||
cbuffer cbuffer_ext_tex_params : register(b3, space1) {
|
cbuffer cbuffer_ext_tex_params : register(b3, space1) {
|
||||||
uint4 ext_tex_params[2];
|
uint4 ext_tex_params[4];
|
||||||
};
|
};
|
||||||
Texture2D<float4> arg_0 : register(t0, space1);
|
Texture2D<float4> arg_0 : register(t0, space1);
|
||||||
SamplerState arg_1 : register(s1, space1);
|
SamplerState arg_1 : register(s1, space1);
|
||||||
|
|
||||||
float4 textureSampleExternal(Texture2D<float4> plane0, Texture2D<float4> plane1, SamplerState smp, float2 coord, ExternalTextureParams params) {
|
float4 textureSampleExternal(Texture2D<float4> plane0, Texture2D<float4> plane1, SamplerState smp, float2 coord, ExternalTextureParams params) {
|
||||||
|
float3 color = float3(0.0f, 0.0f, 0.0f);
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
return plane0.SampleLevel(smp, coord, 0.0f);
|
color = plane0.SampleLevel(smp, coord, 0.0f).rgb;
|
||||||
|
} else {
|
||||||
|
color = mul(params.yuvToRgbConversionMatrix, float4(plane0.SampleLevel(smp, coord, 0.0f).r, plane1.SampleLevel(smp, coord, 0.0f).rg, 1.0f));
|
||||||
}
|
}
|
||||||
const float y = (plane0.SampleLevel(smp, coord, 0.0f).r - 0.0625f);
|
return float4(color, 1.0f);
|
||||||
const float2 uv = (plane1.SampleLevel(smp, coord, 0.0f).rg - 0.5f);
|
|
||||||
const float u = uv.x;
|
|
||||||
const float v = uv.y;
|
|
||||||
const float r = ((1.164000034f * y) + (params.vr * v));
|
|
||||||
const float g = (((1.164000034f * y) - (params.ug * u)) - (params.vg * v));
|
|
||||||
const float b = ((1.164000034f * y) + (params.ub * u));
|
|
||||||
return float4(r, g, b, 1.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ExternalTextureParams tint_symbol_1(uint4 buffer[2], uint offset) {
|
float3x4 tint_symbol_3(uint4 buffer[4], uint offset) {
|
||||||
const uint scalar_offset = ((offset + 0u)) / 4;
|
const uint scalar_offset = ((offset + 0u)) / 4;
|
||||||
const uint scalar_offset_1 = ((offset + 4u)) / 4;
|
const uint scalar_offset_1 = ((offset + 16u)) / 4;
|
||||||
const uint scalar_offset_2 = ((offset + 8u)) / 4;
|
const uint scalar_offset_2 = ((offset + 32u)) / 4;
|
||||||
const uint scalar_offset_3 = ((offset + 12u)) / 4;
|
return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
|
||||||
const uint scalar_offset_4 = ((offset + 16u)) / 4;
|
}
|
||||||
const ExternalTextureParams tint_symbol_4 = {buffer[scalar_offset / 4][scalar_offset % 4], asfloat(buffer[scalar_offset_1 / 4][scalar_offset_1 % 4]), asfloat(buffer[scalar_offset_2 / 4][scalar_offset_2 % 4]), asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4])};
|
|
||||||
return tint_symbol_4;
|
ExternalTextureParams tint_symbol_1(uint4 buffer[4], uint offset) {
|
||||||
|
const uint scalar_offset_3 = ((offset + 0u)) / 4;
|
||||||
|
const ExternalTextureParams tint_symbol_5 = {buffer[scalar_offset_3 / 4][scalar_offset_3 % 4], tint_symbol_3(buffer, (offset + 16u))};
|
||||||
|
return tint_symbol_5;
|
||||||
}
|
}
|
||||||
|
|
||||||
void textureSampleLevel_979816() {
|
void textureSampleLevel_979816() {
|
||||||
|
|
|
@ -3,24 +3,18 @@
|
||||||
using namespace metal;
|
using namespace metal;
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
/* 0x0000 */ uint numPlanes;
|
/* 0x0000 */ uint numPlanes;
|
||||||
/* 0x0004 */ float vr;
|
/* 0x0004 */ int8_t tint_pad[12];
|
||||||
/* 0x0008 */ float ug;
|
/* 0x0010 */ float3x4 yuvToRgbConversionMatrix;
|
||||||
/* 0x000c */ float vg;
|
|
||||||
/* 0x0010 */ float ub;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
float4 textureSampleExternal(texture2d<float, access::sample> plane0, texture2d<float, access::sample> plane1, sampler smp, float2 coord, ExternalTextureParams params) {
|
float4 textureSampleExternal(texture2d<float, access::sample> plane0, texture2d<float, access::sample> plane1, sampler smp, float2 coord, ExternalTextureParams params) {
|
||||||
|
float3 color = 0.0f;
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
return plane0.sample(smp, coord, level(0.0f));
|
color = float4(plane0.sample(smp, coord, level(0.0f))).rgb;
|
||||||
|
} else {
|
||||||
|
color = (float4(plane0.sample(smp, coord, level(0.0f))[0], float4(plane1.sample(smp, coord, level(0.0f))).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
float const y = (plane0.sample(smp, coord, level(0.0f))[0] - 0.0625f);
|
return float4(color, 1.0f);
|
||||||
float2 const uv = (float4(plane1.sample(smp, coord, level(0.0f))).rg - 0.5f);
|
|
||||||
float const u = uv[0];
|
|
||||||
float const v = uv[1];
|
|
||||||
float const r = ((1.164000034f * y) + (params.vr * v));
|
|
||||||
float const g = (((1.164000034f * y) - (params.ug * u)) - (params.vg * v));
|
|
||||||
float const b = ((1.164000034f * y) + (params.ub * u));
|
|
||||||
return float4(r, g, b, 1.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void textureSampleLevel_979816(texture2d<float, access::sample> tint_symbol_1, texture2d<float, access::sample> tint_symbol_2, sampler tint_symbol_3, const constant ExternalTextureParams* const tint_symbol_4) {
|
void textureSampleLevel_979816(texture2d<float, access::sample> tint_symbol_1, texture2d<float, access::sample> tint_symbol_2, sampler tint_symbol_3, const constant ExternalTextureParams* const tint_symbol_4) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
; SPIR-V
|
; SPIR-V
|
||||||
; Version: 1.3
|
; Version: 1.3
|
||||||
; Generator: Google Tint Compiler; 0
|
; Generator: Google Tint Compiler; 0
|
||||||
; Bound: 97
|
; Bound: 88
|
||||||
; Schema: 0
|
; Schema: 0
|
||||||
OpCapability Shader
|
OpCapability Shader
|
||||||
OpMemoryModel Logical GLSL450
|
OpMemoryModel Logical GLSL450
|
||||||
|
@ -15,10 +15,7 @@
|
||||||
OpName %ext_tex_plane_1 "ext_tex_plane_1"
|
OpName %ext_tex_plane_1 "ext_tex_plane_1"
|
||||||
OpName %ExternalTextureParams "ExternalTextureParams"
|
OpName %ExternalTextureParams "ExternalTextureParams"
|
||||||
OpMemberName %ExternalTextureParams 0 "numPlanes"
|
OpMemberName %ExternalTextureParams 0 "numPlanes"
|
||||||
OpMemberName %ExternalTextureParams 1 "vr"
|
OpMemberName %ExternalTextureParams 1 "yuvToRgbConversionMatrix"
|
||||||
OpMemberName %ExternalTextureParams 2 "ug"
|
|
||||||
OpMemberName %ExternalTextureParams 3 "vg"
|
|
||||||
OpMemberName %ExternalTextureParams 4 "ub"
|
|
||||||
OpName %ext_tex_params "ext_tex_params"
|
OpName %ext_tex_params "ext_tex_params"
|
||||||
OpName %arg_0 "arg_0"
|
OpName %arg_0 "arg_0"
|
||||||
OpName %arg_1 "arg_1"
|
OpName %arg_1 "arg_1"
|
||||||
|
@ -28,6 +25,7 @@
|
||||||
OpName %smp "smp"
|
OpName %smp "smp"
|
||||||
OpName %coord "coord"
|
OpName %coord "coord"
|
||||||
OpName %params "params"
|
OpName %params "params"
|
||||||
|
OpName %color "color"
|
||||||
OpName %textureSampleLevel_979816 "textureSampleLevel_979816"
|
OpName %textureSampleLevel_979816 "textureSampleLevel_979816"
|
||||||
OpName %res "res"
|
OpName %res "res"
|
||||||
OpName %vertex_main_inner "vertex_main_inner"
|
OpName %vertex_main_inner "vertex_main_inner"
|
||||||
|
@ -40,10 +38,9 @@
|
||||||
OpDecorate %ext_tex_plane_1 Binding 2
|
OpDecorate %ext_tex_plane_1 Binding 2
|
||||||
OpDecorate %ExternalTextureParams Block
|
OpDecorate %ExternalTextureParams Block
|
||||||
OpMemberDecorate %ExternalTextureParams 0 Offset 0
|
OpMemberDecorate %ExternalTextureParams 0 Offset 0
|
||||||
OpMemberDecorate %ExternalTextureParams 1 Offset 4
|
OpMemberDecorate %ExternalTextureParams 1 Offset 16
|
||||||
OpMemberDecorate %ExternalTextureParams 2 Offset 8
|
OpMemberDecorate %ExternalTextureParams 1 ColMajor
|
||||||
OpMemberDecorate %ExternalTextureParams 3 Offset 12
|
OpMemberDecorate %ExternalTextureParams 1 MatrixStride 16
|
||||||
OpMemberDecorate %ExternalTextureParams 4 Offset 16
|
|
||||||
OpDecorate %ext_tex_params NonWritable
|
OpDecorate %ext_tex_params NonWritable
|
||||||
OpDecorate %ext_tex_params DescriptorSet 1
|
OpDecorate %ext_tex_params DescriptorSet 1
|
||||||
OpDecorate %ext_tex_params Binding 3
|
OpDecorate %ext_tex_params Binding 3
|
||||||
|
@ -63,105 +60,99 @@
|
||||||
%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
|
%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
|
||||||
%ext_tex_plane_1 = OpVariable %_ptr_UniformConstant_11 UniformConstant
|
%ext_tex_plane_1 = OpVariable %_ptr_UniformConstant_11 UniformConstant
|
||||||
%uint = OpTypeInt 32 0
|
%uint = OpTypeInt 32 0
|
||||||
%ExternalTextureParams = OpTypeStruct %uint %float %float %float %float
|
%mat3v4float = OpTypeMatrix %v4float 3
|
||||||
|
%ExternalTextureParams = OpTypeStruct %uint %mat3v4float
|
||||||
%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams
|
%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams
|
||||||
%ext_tex_params = OpVariable %_ptr_Uniform_ExternalTextureParams Uniform
|
%ext_tex_params = OpVariable %_ptr_Uniform_ExternalTextureParams Uniform
|
||||||
%arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant
|
%arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant
|
||||||
%19 = OpTypeSampler
|
%20 = OpTypeSampler
|
||||||
%_ptr_UniformConstant_19 = OpTypePointer UniformConstant %19
|
%_ptr_UniformConstant_20 = OpTypePointer UniformConstant %20
|
||||||
%arg_1 = OpVariable %_ptr_UniformConstant_19 UniformConstant
|
%arg_1 = OpVariable %_ptr_UniformConstant_20 UniformConstant
|
||||||
%v2float = OpTypeVector %float 2
|
%v2float = OpTypeVector %float 2
|
||||||
%20 = OpTypeFunction %v4float %11 %11 %19 %v2float %ExternalTextureParams
|
%21 = OpTypeFunction %v4float %11 %11 %20 %v2float %ExternalTextureParams
|
||||||
|
%v3float = OpTypeVector %float 3
|
||||||
|
%_ptr_Function_v3float = OpTypePointer Function %v3float
|
||||||
|
%33 = OpConstantNull %v3float
|
||||||
%uint_1 = OpConstant %uint 1
|
%uint_1 = OpConstant %uint 1
|
||||||
%bool = OpTypeBool
|
%bool = OpTypeBool
|
||||||
%36 = OpTypeSampledImage %11
|
%42 = OpTypeSampledImage %11
|
||||||
%float_0 = OpConstant %float 0
|
%float_0 = OpConstant %float 0
|
||||||
%float_0_0625 = OpConstant %float 0.0625
|
|
||||||
%float_0_5 = OpConstant %float 0.5
|
|
||||||
%_ptr_Function_v2float = OpTypePointer Function %v2float
|
|
||||||
%51 = OpConstantNull %v2float
|
|
||||||
%float_1_16400003 = OpConstant %float 1.16400003
|
|
||||||
%float_1 = OpConstant %float 1
|
%float_1 = OpConstant %float 1
|
||||||
%void = OpTypeVoid
|
%void = OpTypeVoid
|
||||||
%73 = OpTypeFunction %void
|
%63 = OpTypeFunction %void
|
||||||
|
%71 = OpConstantNull %v2float
|
||||||
%_ptr_Function_v4float = OpTypePointer Function %v4float
|
%_ptr_Function_v4float = OpTypePointer Function %v4float
|
||||||
%84 = OpTypeFunction %v4float
|
%75 = OpTypeFunction %v4float
|
||||||
%textureSampleExternal = OpFunction %v4float None %20
|
%textureSampleExternal = OpFunction %v4float None %21
|
||||||
%plane0 = OpFunctionParameter %11
|
%plane0 = OpFunctionParameter %11
|
||||||
%plane1 = OpFunctionParameter %11
|
%plane1 = OpFunctionParameter %11
|
||||||
%smp = OpFunctionParameter %19
|
%smp = OpFunctionParameter %20
|
||||||
%coord = OpFunctionParameter %v2float
|
%coord = OpFunctionParameter %v2float
|
||||||
%params = OpFunctionParameter %ExternalTextureParams
|
%params = OpFunctionParameter %ExternalTextureParams
|
||||||
%28 = OpLabel
|
%29 = OpLabel
|
||||||
%49 = OpVariable %_ptr_Function_v2float Function %51
|
%color = OpVariable %_ptr_Function_v3float Function %33
|
||||||
%29 = OpCompositeExtract %uint %params 0
|
%34 = OpCompositeExtract %uint %params 0
|
||||||
%31 = OpIEqual %bool %29 %uint_1
|
%36 = OpIEqual %bool %34 %uint_1
|
||||||
OpSelectionMerge %33 None
|
OpSelectionMerge %38 None
|
||||||
OpBranchConditional %31 %34 %33
|
OpBranchConditional %36 %39 %40
|
||||||
%34 = OpLabel
|
%39 = OpLabel
|
||||||
%37 = OpSampledImage %36 %plane0 %smp
|
%43 = OpSampledImage %42 %plane0 %smp
|
||||||
%35 = OpImageSampleExplicitLod %v4float %37 %coord Lod %float_0
|
%41 = OpImageSampleExplicitLod %v4float %43 %coord Lod %float_0
|
||||||
OpReturnValue %35
|
%45 = OpVectorShuffle %v3float %41 %41 0 1 2
|
||||||
%33 = OpLabel
|
OpStore %color %45
|
||||||
%40 = OpSampledImage %36 %plane0 %smp
|
OpBranch %38
|
||||||
%39 = OpImageSampleExplicitLod %v4float %40 %coord Lod %float_0
|
%40 = OpLabel
|
||||||
%41 = OpCompositeExtract %float %39 0
|
%47 = OpSampledImage %42 %plane0 %smp
|
||||||
%43 = OpFSub %float %41 %float_0_0625
|
%46 = OpImageSampleExplicitLod %v4float %47 %coord Lod %float_0
|
||||||
%45 = OpSampledImage %36 %plane1 %smp
|
%48 = OpCompositeExtract %float %46 0
|
||||||
%44 = OpImageSampleExplicitLod %v4float %45 %coord Lod %float_0
|
%50 = OpSampledImage %42 %plane1 %smp
|
||||||
%46 = OpVectorShuffle %v2float %44 %44 0 1
|
%49 = OpImageSampleExplicitLod %v4float %50 %coord Lod %float_0
|
||||||
%52 = OpCompositeConstruct %v2float %float_0_5 %float_0_5
|
%51 = OpVectorShuffle %v2float %49 %49 0 1
|
||||||
%48 = OpFSub %v2float %46 %52
|
%52 = OpCompositeExtract %float %51 0
|
||||||
%53 = OpCompositeExtract %float %48 0
|
%53 = OpCompositeExtract %float %51 1
|
||||||
%54 = OpCompositeExtract %float %48 1
|
%55 = OpCompositeConstruct %v4float %48 %52 %53 %float_1
|
||||||
%56 = OpFMul %float %float_1_16400003 %43
|
%56 = OpCompositeExtract %mat3v4float %params 1
|
||||||
%57 = OpCompositeExtract %float %params 1
|
%57 = OpVectorTimesMatrix %v3float %55 %56
|
||||||
%58 = OpFMul %float %57 %54
|
OpStore %color %57
|
||||||
%59 = OpFAdd %float %56 %58
|
OpBranch %38
|
||||||
%60 = OpFMul %float %float_1_16400003 %43
|
%38 = OpLabel
|
||||||
%61 = OpCompositeExtract %float %params 2
|
%58 = OpLoad %v3float %color
|
||||||
%62 = OpFMul %float %61 %53
|
%59 = OpCompositeExtract %float %58 0
|
||||||
%63 = OpFSub %float %60 %62
|
%60 = OpCompositeExtract %float %58 1
|
||||||
%64 = OpCompositeExtract %float %params 3
|
%61 = OpCompositeExtract %float %58 2
|
||||||
%65 = OpFMul %float %64 %54
|
%62 = OpCompositeConstruct %v4float %59 %60 %61 %float_1
|
||||||
%66 = OpFSub %float %63 %65
|
OpReturnValue %62
|
||||||
%67 = OpFMul %float %float_1_16400003 %43
|
|
||||||
%68 = OpCompositeExtract %float %params 4
|
|
||||||
%69 = OpFMul %float %68 %53
|
|
||||||
%70 = OpFAdd %float %67 %69
|
|
||||||
%72 = OpCompositeConstruct %v4float %59 %66 %70 %float_1
|
|
||||||
OpReturnValue %72
|
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%textureSampleLevel_979816 = OpFunction %void None %73
|
%textureSampleLevel_979816 = OpFunction %void None %63
|
||||||
%76 = OpLabel
|
%66 = OpLabel
|
||||||
%res = OpVariable %_ptr_Function_v4float Function %5
|
%res = OpVariable %_ptr_Function_v4float Function %5
|
||||||
%78 = OpLoad %11 %arg_0
|
%68 = OpLoad %11 %arg_0
|
||||||
%79 = OpLoad %11 %ext_tex_plane_1
|
%69 = OpLoad %11 %ext_tex_plane_1
|
||||||
%80 = OpLoad %19 %arg_1
|
%70 = OpLoad %20 %arg_1
|
||||||
%81 = OpLoad %ExternalTextureParams %ext_tex_params
|
%72 = OpLoad %ExternalTextureParams %ext_tex_params
|
||||||
%77 = OpFunctionCall %v4float %textureSampleExternal %78 %79 %80 %51 %81
|
%67 = OpFunctionCall %v4float %textureSampleExternal %68 %69 %70 %71 %72
|
||||||
OpStore %res %77
|
OpStore %res %67
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%vertex_main_inner = OpFunction %v4float None %84
|
%vertex_main_inner = OpFunction %v4float None %75
|
||||||
%86 = OpLabel
|
%77 = OpLabel
|
||||||
%87 = OpFunctionCall %void %textureSampleLevel_979816
|
%78 = OpFunctionCall %void %textureSampleLevel_979816
|
||||||
OpReturnValue %5
|
OpReturnValue %5
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%vertex_main = OpFunction %void None %73
|
%vertex_main = OpFunction %void None %63
|
||||||
%89 = OpLabel
|
%80 = OpLabel
|
||||||
%90 = OpFunctionCall %v4float %vertex_main_inner
|
%81 = OpFunctionCall %v4float %vertex_main_inner
|
||||||
OpStore %value %90
|
OpStore %value %81
|
||||||
OpStore %vertex_point_size %float_1
|
OpStore %vertex_point_size %float_1
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%fragment_main = OpFunction %void None %73
|
%fragment_main = OpFunction %void None %63
|
||||||
%92 = OpLabel
|
%83 = OpLabel
|
||||||
%93 = OpFunctionCall %void %textureSampleLevel_979816
|
%84 = OpFunctionCall %void %textureSampleLevel_979816
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%compute_main = OpFunction %void None %73
|
%compute_main = OpFunction %void None %63
|
||||||
%95 = OpLabel
|
%86 = OpLabel
|
||||||
%96 = OpFunctionCall %void %textureSampleLevel_979816
|
%87 = OpFunctionCall %void %textureSampleLevel_979816
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
|
|
|
@ -1,43 +1,39 @@
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
uint numPlanes;
|
uint numPlanes;
|
||||||
float vr;
|
float3x4 yuvToRgbConversionMatrix;
|
||||||
float ug;
|
|
||||||
float vg;
|
|
||||||
float ub;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Texture2D<float4> ext_tex_plane_1 : register(t1, space1);
|
Texture2D<float4> ext_tex_plane_1 : register(t1, space1);
|
||||||
cbuffer cbuffer_ext_tex_params : register(b2, space1) {
|
cbuffer cbuffer_ext_tex_params : register(b2, space1) {
|
||||||
uint4 ext_tex_params[2];
|
uint4 ext_tex_params[4];
|
||||||
};
|
};
|
||||||
Texture2D<float4> arg_0 : register(t0, space1);
|
Texture2D<float4> arg_0 : register(t0, space1);
|
||||||
|
|
||||||
float4 textureLoadExternal(Texture2D<float4> plane0, Texture2D<float4> plane1, int2 coord, ExternalTextureParams params) {
|
float4 textureLoadExternal(Texture2D<float4> plane0, Texture2D<float4> plane1, int2 coord, ExternalTextureParams params) {
|
||||||
|
float3 color = float3(0.0f, 0.0f, 0.0f);
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
return plane0.Load(int3(coord, 0));
|
color = plane0.Load(int3(coord, 0)).rgb;
|
||||||
|
} else {
|
||||||
|
color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord, 0)).rg, 1.0f));
|
||||||
}
|
}
|
||||||
const float y = (plane0.Load(int3(coord, 0)).r - 0.0625f);
|
return float4(color, 1.0f);
|
||||||
const float2 uv = (plane1.Load(int3(coord, 0)).rg - 0.5f);
|
|
||||||
const float u = uv.x;
|
|
||||||
const float v = uv.y;
|
|
||||||
const float r = ((1.164000034f * y) + (params.vr * v));
|
|
||||||
const float g = (((1.164000034f * y) - (params.ug * u)) - (params.vg * v));
|
|
||||||
const float b = ((1.164000034f * y) + (params.ub * u));
|
|
||||||
return float4(r, g, b, 1.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 textureLoad2d(Texture2D<float4> tint_symbol, Texture2D<float4> ext_tex_plane_1_1, ExternalTextureParams ext_tex_params_1, int2 coords) {
|
float4 textureLoad2d(Texture2D<float4> tint_symbol, Texture2D<float4> ext_tex_plane_1_1, ExternalTextureParams ext_tex_params_1, int2 coords) {
|
||||||
return textureLoadExternal(tint_symbol, ext_tex_plane_1_1, coords, ext_tex_params_1);
|
return textureLoadExternal(tint_symbol, ext_tex_plane_1_1, coords, ext_tex_params_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ExternalTextureParams tint_symbol_2(uint4 buffer[2], uint offset) {
|
float3x4 tint_symbol_4(uint4 buffer[4], uint offset) {
|
||||||
const uint scalar_offset = ((offset + 0u)) / 4;
|
const uint scalar_offset = ((offset + 0u)) / 4;
|
||||||
const uint scalar_offset_1 = ((offset + 4u)) / 4;
|
const uint scalar_offset_1 = ((offset + 16u)) / 4;
|
||||||
const uint scalar_offset_2 = ((offset + 8u)) / 4;
|
const uint scalar_offset_2 = ((offset + 32u)) / 4;
|
||||||
const uint scalar_offset_3 = ((offset + 12u)) / 4;
|
return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
|
||||||
const uint scalar_offset_4 = ((offset + 16u)) / 4;
|
}
|
||||||
const ExternalTextureParams tint_symbol_5 = {buffer[scalar_offset / 4][scalar_offset % 4], asfloat(buffer[scalar_offset_1 / 4][scalar_offset_1 % 4]), asfloat(buffer[scalar_offset_2 / 4][scalar_offset_2 % 4]), asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4])};
|
|
||||||
return tint_symbol_5;
|
ExternalTextureParams tint_symbol_2(uint4 buffer[4], uint offset) {
|
||||||
|
const uint scalar_offset_3 = ((offset + 0u)) / 4;
|
||||||
|
const ExternalTextureParams tint_symbol_6 = {buffer[scalar_offset_3 / 4][scalar_offset_3 % 4], tint_symbol_4(buffer, (offset + 16u))};
|
||||||
|
return tint_symbol_6;
|
||||||
}
|
}
|
||||||
|
|
||||||
void doTextureLoad() {
|
void doTextureLoad() {
|
||||||
|
|
|
@ -3,24 +3,18 @@
|
||||||
using namespace metal;
|
using namespace metal;
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
/* 0x0000 */ uint numPlanes;
|
/* 0x0000 */ uint numPlanes;
|
||||||
/* 0x0004 */ float vr;
|
/* 0x0004 */ int8_t tint_pad[12];
|
||||||
/* 0x0008 */ float ug;
|
/* 0x0010 */ float3x4 yuvToRgbConversionMatrix;
|
||||||
/* 0x000c */ float vg;
|
|
||||||
/* 0x0010 */ float ub;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
float4 textureLoadExternal(texture2d<float, access::sample> plane0, texture2d<float, access::sample> plane1, int2 coord, ExternalTextureParams params) {
|
float4 textureLoadExternal(texture2d<float, access::sample> plane0, texture2d<float, access::sample> plane1, int2 coord, ExternalTextureParams params) {
|
||||||
|
float3 color = 0.0f;
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
return plane0.read(uint2(coord), 0);
|
color = float4(plane0.read(uint2(coord), 0)).rgb;
|
||||||
|
} else {
|
||||||
|
color = (float4(plane0.read(uint2(coord), 0)[0], float4(plane1.read(uint2(coord), 0)).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
float const y = (plane0.read(uint2(coord), 0)[0] - 0.0625f);
|
return float4(color, 1.0f);
|
||||||
float2 const uv = (float4(plane1.read(uint2(coord), 0)).rg - 0.5f);
|
|
||||||
float const u = uv[0];
|
|
||||||
float const v = uv[1];
|
|
||||||
float const r = ((1.164000034f * y) + (params.vr * v));
|
|
||||||
float const g = (((1.164000034f * y) - (params.ug * u)) - (params.vg * v));
|
|
||||||
float const b = ((1.164000034f * y) + (params.ub * u));
|
|
||||||
return float4(r, g, b, 1.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float4 textureLoad2d(texture2d<float, access::sample> tint_symbol, texture2d<float, access::sample> ext_tex_plane_1_1, ExternalTextureParams ext_tex_params_1, int2 coords) {
|
float4 textureLoad2d(texture2d<float, access::sample> tint_symbol, texture2d<float, access::sample> ext_tex_plane_1_1, ExternalTextureParams ext_tex_params_1, int2 coords) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
; SPIR-V
|
; SPIR-V
|
||||||
; Version: 1.3
|
; Version: 1.3
|
||||||
; Generator: Google Tint Compiler; 0
|
; Generator: Google Tint Compiler; 0
|
||||||
; Bound: 99
|
; Bound: 89
|
||||||
; Schema: 0
|
; Schema: 0
|
||||||
OpCapability Shader
|
OpCapability Shader
|
||||||
OpMemoryModel Logical GLSL450
|
OpMemoryModel Logical GLSL450
|
||||||
|
@ -15,10 +15,7 @@
|
||||||
OpName %ext_tex_plane_1 "ext_tex_plane_1"
|
OpName %ext_tex_plane_1 "ext_tex_plane_1"
|
||||||
OpName %ExternalTextureParams "ExternalTextureParams"
|
OpName %ExternalTextureParams "ExternalTextureParams"
|
||||||
OpMemberName %ExternalTextureParams 0 "numPlanes"
|
OpMemberName %ExternalTextureParams 0 "numPlanes"
|
||||||
OpMemberName %ExternalTextureParams 1 "vr"
|
OpMemberName %ExternalTextureParams 1 "yuvToRgbConversionMatrix"
|
||||||
OpMemberName %ExternalTextureParams 2 "ug"
|
|
||||||
OpMemberName %ExternalTextureParams 3 "vg"
|
|
||||||
OpMemberName %ExternalTextureParams 4 "ub"
|
|
||||||
OpName %ext_tex_params "ext_tex_params"
|
OpName %ext_tex_params "ext_tex_params"
|
||||||
OpName %arg_0 "arg_0"
|
OpName %arg_0 "arg_0"
|
||||||
OpName %textureLoadExternal "textureLoadExternal"
|
OpName %textureLoadExternal "textureLoadExternal"
|
||||||
|
@ -26,6 +23,7 @@
|
||||||
OpName %plane1 "plane1"
|
OpName %plane1 "plane1"
|
||||||
OpName %coord "coord"
|
OpName %coord "coord"
|
||||||
OpName %params "params"
|
OpName %params "params"
|
||||||
|
OpName %color "color"
|
||||||
OpName %textureLoad2d "textureLoad2d"
|
OpName %textureLoad2d "textureLoad2d"
|
||||||
OpName %texture "texture"
|
OpName %texture "texture"
|
||||||
OpName %ext_tex_plane_1_1 "ext_tex_plane_1_1"
|
OpName %ext_tex_plane_1_1 "ext_tex_plane_1_1"
|
||||||
|
@ -43,10 +41,9 @@
|
||||||
OpDecorate %ext_tex_plane_1 Binding 1
|
OpDecorate %ext_tex_plane_1 Binding 1
|
||||||
OpDecorate %ExternalTextureParams Block
|
OpDecorate %ExternalTextureParams Block
|
||||||
OpMemberDecorate %ExternalTextureParams 0 Offset 0
|
OpMemberDecorate %ExternalTextureParams 0 Offset 0
|
||||||
OpMemberDecorate %ExternalTextureParams 1 Offset 4
|
OpMemberDecorate %ExternalTextureParams 1 Offset 16
|
||||||
OpMemberDecorate %ExternalTextureParams 2 Offset 8
|
OpMemberDecorate %ExternalTextureParams 1 ColMajor
|
||||||
OpMemberDecorate %ExternalTextureParams 3 Offset 12
|
OpMemberDecorate %ExternalTextureParams 1 MatrixStride 16
|
||||||
OpMemberDecorate %ExternalTextureParams 4 Offset 16
|
|
||||||
OpDecorate %ext_tex_params NonWritable
|
OpDecorate %ext_tex_params NonWritable
|
||||||
OpDecorate %ext_tex_params DescriptorSet 1
|
OpDecorate %ext_tex_params DescriptorSet 1
|
||||||
OpDecorate %ext_tex_params Binding 2
|
OpDecorate %ext_tex_params Binding 2
|
||||||
|
@ -64,109 +61,102 @@
|
||||||
%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
|
%_ptr_UniformConstant_11 = OpTypePointer UniformConstant %11
|
||||||
%ext_tex_plane_1 = OpVariable %_ptr_UniformConstant_11 UniformConstant
|
%ext_tex_plane_1 = OpVariable %_ptr_UniformConstant_11 UniformConstant
|
||||||
%uint = OpTypeInt 32 0
|
%uint = OpTypeInt 32 0
|
||||||
%ExternalTextureParams = OpTypeStruct %uint %float %float %float %float
|
%mat3v4float = OpTypeMatrix %v4float 3
|
||||||
|
%ExternalTextureParams = OpTypeStruct %uint %mat3v4float
|
||||||
%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams
|
%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams
|
||||||
%ext_tex_params = OpVariable %_ptr_Uniform_ExternalTextureParams Uniform
|
%ext_tex_params = OpVariable %_ptr_Uniform_ExternalTextureParams Uniform
|
||||||
%arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant
|
%arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant
|
||||||
%int = OpTypeInt 32 1
|
%int = OpTypeInt 32 1
|
||||||
%v2int = OpTypeVector %int 2
|
%v2int = OpTypeVector %int 2
|
||||||
%17 = OpTypeFunction %v4float %11 %11 %v2int %ExternalTextureParams
|
%18 = OpTypeFunction %v4float %11 %11 %v2int %ExternalTextureParams
|
||||||
|
%v3float = OpTypeVector %float 3
|
||||||
|
%_ptr_Function_v3float = OpTypePointer Function %v3float
|
||||||
|
%30 = OpConstantNull %v3float
|
||||||
%uint_1 = OpConstant %uint 1
|
%uint_1 = OpConstant %uint 1
|
||||||
%bool = OpTypeBool
|
%bool = OpTypeBool
|
||||||
%int_0 = OpConstant %int 0
|
%int_0 = OpConstant %int 0
|
||||||
%float_0_0625 = OpConstant %float 0.0625
|
|
||||||
%v2float = OpTypeVector %float 2
|
%v2float = OpTypeVector %float 2
|
||||||
%float_0_5 = OpConstant %float 0.5
|
|
||||||
%_ptr_Function_v2float = OpTypePointer Function %v2float
|
|
||||||
%45 = OpConstantNull %v2float
|
|
||||||
%float_1_16400003 = OpConstant %float 1.16400003
|
|
||||||
%float_1 = OpConstant %float 1
|
%float_1 = OpConstant %float 1
|
||||||
%67 = OpTypeFunction %v4float %11 %11 %ExternalTextureParams %v2int
|
%57 = OpTypeFunction %v4float %11 %11 %ExternalTextureParams %v2int
|
||||||
%void = OpTypeVoid
|
%void = OpTypeVoid
|
||||||
%75 = OpTypeFunction %void
|
%65 = OpTypeFunction %void
|
||||||
%83 = OpConstantNull %v2int
|
%73 = OpConstantNull %v2int
|
||||||
%_ptr_Function_v4float = OpTypePointer Function %v4float
|
%_ptr_Function_v4float = OpTypePointer Function %v4float
|
||||||
%86 = OpTypeFunction %v4float
|
%76 = OpTypeFunction %v4float
|
||||||
%textureLoadExternal = OpFunction %v4float None %17
|
%textureLoadExternal = OpFunction %v4float None %18
|
||||||
%plane0 = OpFunctionParameter %11
|
%plane0 = OpFunctionParameter %11
|
||||||
%plane1 = OpFunctionParameter %11
|
%plane1 = OpFunctionParameter %11
|
||||||
%coord = OpFunctionParameter %v2int
|
%coord = OpFunctionParameter %v2int
|
||||||
%params = OpFunctionParameter %ExternalTextureParams
|
%params = OpFunctionParameter %ExternalTextureParams
|
||||||
%25 = OpLabel
|
%26 = OpLabel
|
||||||
%43 = OpVariable %_ptr_Function_v2float Function %45
|
%color = OpVariable %_ptr_Function_v3float Function %30
|
||||||
%26 = OpCompositeExtract %uint %params 0
|
%31 = OpCompositeExtract %uint %params 0
|
||||||
%28 = OpIEqual %bool %26 %uint_1
|
%33 = OpIEqual %bool %31 %uint_1
|
||||||
OpSelectionMerge %30 None
|
OpSelectionMerge %35 None
|
||||||
OpBranchConditional %28 %31 %30
|
OpBranchConditional %33 %36 %37
|
||||||
%31 = OpLabel
|
%36 = OpLabel
|
||||||
%32 = OpImageFetch %v4float %plane0 %coord Lod %int_0
|
%38 = OpImageFetch %v4float %plane0 %coord Lod %int_0
|
||||||
OpReturnValue %32
|
%40 = OpVectorShuffle %v3float %38 %38 0 1 2
|
||||||
%30 = OpLabel
|
OpStore %color %40
|
||||||
%34 = OpImageFetch %v4float %plane0 %coord Lod %int_0
|
OpBranch %35
|
||||||
%35 = OpCompositeExtract %float %34 0
|
%37 = OpLabel
|
||||||
%37 = OpFSub %float %35 %float_0_0625
|
%41 = OpImageFetch %v4float %plane0 %coord Lod %int_0
|
||||||
%38 = OpImageFetch %v4float %plane1 %coord Lod %int_0
|
%42 = OpCompositeExtract %float %41 0
|
||||||
%40 = OpVectorShuffle %v2float %38 %38 0 1
|
%43 = OpImageFetch %v4float %plane1 %coord Lod %int_0
|
||||||
%46 = OpCompositeConstruct %v2float %float_0_5 %float_0_5
|
%45 = OpVectorShuffle %v2float %43 %43 0 1
|
||||||
%42 = OpFSub %v2float %40 %46
|
%46 = OpCompositeExtract %float %45 0
|
||||||
%47 = OpCompositeExtract %float %42 0
|
%47 = OpCompositeExtract %float %45 1
|
||||||
%48 = OpCompositeExtract %float %42 1
|
%49 = OpCompositeConstruct %v4float %42 %46 %47 %float_1
|
||||||
%50 = OpFMul %float %float_1_16400003 %37
|
%50 = OpCompositeExtract %mat3v4float %params 1
|
||||||
%51 = OpCompositeExtract %float %params 1
|
%51 = OpVectorTimesMatrix %v3float %49 %50
|
||||||
%52 = OpFMul %float %51 %48
|
OpStore %color %51
|
||||||
%53 = OpFAdd %float %50 %52
|
OpBranch %35
|
||||||
%54 = OpFMul %float %float_1_16400003 %37
|
%35 = OpLabel
|
||||||
%55 = OpCompositeExtract %float %params 2
|
%52 = OpLoad %v3float %color
|
||||||
%56 = OpFMul %float %55 %47
|
%53 = OpCompositeExtract %float %52 0
|
||||||
%57 = OpFSub %float %54 %56
|
%54 = OpCompositeExtract %float %52 1
|
||||||
%58 = OpCompositeExtract %float %params 3
|
%55 = OpCompositeExtract %float %52 2
|
||||||
%59 = OpFMul %float %58 %48
|
%56 = OpCompositeConstruct %v4float %53 %54 %55 %float_1
|
||||||
%60 = OpFSub %float %57 %59
|
OpReturnValue %56
|
||||||
%61 = OpFMul %float %float_1_16400003 %37
|
|
||||||
%62 = OpCompositeExtract %float %params 4
|
|
||||||
%63 = OpFMul %float %62 %47
|
|
||||||
%64 = OpFAdd %float %61 %63
|
|
||||||
%66 = OpCompositeConstruct %v4float %53 %60 %64 %float_1
|
|
||||||
OpReturnValue %66
|
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%textureLoad2d = OpFunction %v4float None %67
|
%textureLoad2d = OpFunction %v4float None %57
|
||||||
%texture = OpFunctionParameter %11
|
%texture = OpFunctionParameter %11
|
||||||
%ext_tex_plane_1_1 = OpFunctionParameter %11
|
%ext_tex_plane_1_1 = OpFunctionParameter %11
|
||||||
%ext_tex_params_1 = OpFunctionParameter %ExternalTextureParams
|
%ext_tex_params_1 = OpFunctionParameter %ExternalTextureParams
|
||||||
%coords = OpFunctionParameter %v2int
|
%coords = OpFunctionParameter %v2int
|
||||||
%73 = OpLabel
|
%63 = OpLabel
|
||||||
%74 = OpFunctionCall %v4float %textureLoadExternal %texture %ext_tex_plane_1_1 %coords %ext_tex_params_1
|
%64 = OpFunctionCall %v4float %textureLoadExternal %texture %ext_tex_plane_1_1 %coords %ext_tex_params_1
|
||||||
OpReturnValue %74
|
OpReturnValue %64
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%doTextureLoad = OpFunction %void None %75
|
%doTextureLoad = OpFunction %void None %65
|
||||||
%78 = OpLabel
|
%68 = OpLabel
|
||||||
%res = OpVariable %_ptr_Function_v4float Function %5
|
%res = OpVariable %_ptr_Function_v4float Function %5
|
||||||
%80 = OpLoad %11 %arg_0
|
%70 = OpLoad %11 %arg_0
|
||||||
%81 = OpLoad %11 %ext_tex_plane_1
|
%71 = OpLoad %11 %ext_tex_plane_1
|
||||||
%82 = OpLoad %ExternalTextureParams %ext_tex_params
|
%72 = OpLoad %ExternalTextureParams %ext_tex_params
|
||||||
%79 = OpFunctionCall %v4float %textureLoad2d %80 %81 %82 %83
|
%69 = OpFunctionCall %v4float %textureLoad2d %70 %71 %72 %73
|
||||||
OpStore %res %79
|
OpStore %res %69
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%vertex_main_inner = OpFunction %v4float None %86
|
%vertex_main_inner = OpFunction %v4float None %76
|
||||||
%88 = OpLabel
|
%78 = OpLabel
|
||||||
%89 = OpFunctionCall %void %doTextureLoad
|
%79 = OpFunctionCall %void %doTextureLoad
|
||||||
OpReturnValue %5
|
OpReturnValue %5
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%vertex_main = OpFunction %void None %75
|
%vertex_main = OpFunction %void None %65
|
||||||
%91 = OpLabel
|
%81 = OpLabel
|
||||||
%92 = OpFunctionCall %v4float %vertex_main_inner
|
%82 = OpFunctionCall %v4float %vertex_main_inner
|
||||||
OpStore %value %92
|
OpStore %value %82
|
||||||
OpStore %vertex_point_size %float_1
|
OpStore %vertex_point_size %float_1
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%fragment_main = OpFunction %void None %75
|
%fragment_main = OpFunction %void None %65
|
||||||
%94 = OpLabel
|
%84 = OpLabel
|
||||||
%95 = OpFunctionCall %void %doTextureLoad
|
%85 = OpFunctionCall %void %doTextureLoad
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%compute_main = OpFunction %void None %75
|
%compute_main = OpFunction %void None %65
|
||||||
%97 = OpLabel
|
%87 = OpLabel
|
||||||
%98 = OpFunctionCall %void %doTextureLoad
|
%88 = OpFunctionCall %void %doTextureLoad
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
|
|
Loading…
Reference in New Issue