Revert "Add External Texture Gamma/Gamut Correction"
This reverts commit 857175e59b
.
Reason for revert: Suspected change for Dawn -> Chromium roll failures:
* https://chromium-review.googlesource.com/c/chromium/src/+/3607875/
* https://ci.chromium.org/ui/p/chromium/builders/try/mac-rel/982037/overview
* https://chrome-public-gold.skia.org/search?issue=3607875&crs=gerrit&patchsets=3&corpus=chrome-gpu
Original change's description:
> Add External Texture Gamma/Gamut Correction
>
> Adds configurable gamma and gamut correction in Tint's external texture
> transform. Adds constants in Dawn to perform correct conversion from
> BT.709 to sRGB.
>
> Bug: dawn:1082
> Change-Id: Id5eecc37f0224541bf36e2f9757e7e2047e4b66b
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87666
> Kokoro: Kokoro <noreply+kokoro@google.com>
> Reviewed-by: Ben Clayton <bclayton@google.com>
> Commit-Queue: Brandon1 Jones <brandon1.jones@intel.com>
TBR=cwallez@chromium.org,enga@chromium.org,brandon1.jones@intel.com,bclayton@google.com,noreply+kokoro@google.com,dawn-scoped@luci-project-accounts.iam.gserviceaccount.com
Change-Id: Id3880e506172a18ff1258462c8c4cedb5c51c235
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: dawn:1082
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/88001
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
d93d0c994b
commit
1d882f55b7
|
@ -152,28 +152,12 @@ namespace dawn::native {
|
||||||
|
|
||||||
switch (descriptor->colorSpace) {
|
switch (descriptor->colorSpace) {
|
||||||
case wgpu::PredefinedColorSpace::Srgb:
|
case wgpu::PredefinedColorSpace::Srgb:
|
||||||
// TODO(dawn:1082): Make these fields configurable from outside of Dawn.
|
|
||||||
|
|
||||||
// Conversion matrix for BT.709 limited range. Columns 1, 2 and 3 are copied
|
// Conversion matrix for BT.709 limited range. Columns 1, 2 and 3 are copied
|
||||||
// directly from the corresponding matrix in SkYUVMath.cpp. Column 4 is the range
|
// directly from the corresponding matrix in SkYUVMath.cpp. Column 4 is the range
|
||||||
// bias (for RGB) found in column 5 of the same SkYUVMath.cpp matrix.
|
// bias (for RGB) found in column 5 of the same SkYUVMath.cpp matrix.
|
||||||
params.yuvToRgbConversionMatrix = {1.164384f, 0.0f, 1.792741f, -0.972945f,
|
params.yuvToRgbConversion = {1.164384f, 0.0f, 1.792741f, -0.972945f,
|
||||||
1.164384f, -0.213249f, -0.532909f, 0.301483f,
|
1.164384f, -0.213249f, -0.532909f, 0.301483f,
|
||||||
1.164384f, 2.112402f, 0.0f, -1.133402f};
|
1.164384f, 2.112402f, 0.0f, -1.133402f};
|
||||||
|
|
||||||
// These are the inverted parameters as specified by Rec. ITU-R BT.1886 for BT.709
|
|
||||||
params.gammaDecodingParams = {2.2, 1.0 / 1.099, 0.099 / 1.099, 1 / 4.5, 0.081,
|
|
||||||
0.0, 0.0};
|
|
||||||
|
|
||||||
// Constants for sRGB transfer function pulled from
|
|
||||||
// https://en.wikipedia.org/wiki/SRGB
|
|
||||||
params.gammaEncodingParams = {
|
|
||||||
1 / 2.4, 1.137119 /*1.055^2.4*/, 0.0, 12.92, 0.0031308, -0.055, 0.0};
|
|
||||||
|
|
||||||
// Use an identity matrix when converting BT.709 to sRGB because they shared the
|
|
||||||
// same primaries.
|
|
||||||
params.gamutConversionMatrix = {1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f,
|
|
||||||
0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f};
|
|
||||||
break;
|
break;
|
||||||
case wgpu::PredefinedColorSpace::Undefined:
|
case wgpu::PredefinedColorSpace::Undefined:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -26,24 +26,10 @@ namespace dawn::native {
|
||||||
|
|
||||||
class TextureViewBase;
|
class TextureViewBase;
|
||||||
|
|
||||||
struct GammaTransferParams {
|
|
||||||
float G = 0.0;
|
|
||||||
float A = 0.0;
|
|
||||||
float B = 0.0;
|
|
||||||
float C = 0.0;
|
|
||||||
float D = 0.0;
|
|
||||||
float E = 0.0;
|
|
||||||
float F = 0.0;
|
|
||||||
uint32_t padding = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
uint32_t numPlanes;
|
uint32_t numPlanes;
|
||||||
std::array<uint32_t, 3> padding;
|
std::array<uint32_t, 3> padding;
|
||||||
std::array<float, 12> yuvToRgbConversionMatrix;
|
std::array<float, 12> yuvToRgbConversion;
|
||||||
GammaTransferParams gammaDecodingParams = {};
|
|
||||||
GammaTransferParams gammaEncodingParams = {};
|
|
||||||
std::array<float, 12> gamutConversionMatrix = {};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
MaybeError ValidateExternalTextureDescriptor(const DeviceBase* device,
|
MaybeError ValidateExternalTextureDescriptor(const DeviceBase* device,
|
||||||
|
|
|
@ -191,15 +191,10 @@ TEST_P(ExternalTextureTests, SampleMultiplanarExternalTexture) {
|
||||||
RGBA8 rgba;
|
RGBA8 rgba;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Conversion expectations for BT.709 YUV source and sRGB destination.
|
std::array<ConversionExpectation, 4> expectations = {{{0.0, .5, .5, RGBA8::kBlack},
|
||||||
std::array<ConversionExpectation, 7> expectations = {
|
{0.2126, 0.4172, 1.0, RGBA8::kRed},
|
||||||
{{0.0, .5, .5, RGBA8::kBlack},
|
{0.7152, 0.1402, 0.0175, RGBA8::kGreen},
|
||||||
{0.2126, 0.4172, 1.0, RGBA8::kRed},
|
{0.0722, 1.0, 0.4937, RGBA8::kBlue}}};
|
||||||
{0.7152, 0.1402, 0.0175, RGBA8::kGreen},
|
|
||||||
{0.0722, 1.0, 0.4937, RGBA8::kBlue},
|
|
||||||
{0.6382, 0.3232, 0.6644, {246, 169, 90, 255}},
|
|
||||||
{0.5423, 0.5323, 0.4222, {120, 162, 169, 255}},
|
|
||||||
{0.2345, 0.4383, 0.6342, {126, 53, 33, 255}}}};
|
|
||||||
|
|
||||||
for (ConversionExpectation expectation : expectations) {
|
for (ConversionExpectation expectation : expectations) {
|
||||||
// Initialize the texture planes with YUV data
|
// Initialize the texture planes with YUV data
|
||||||
|
|
|
@ -51,9 +51,6 @@ struct MultiplanarExternalTexture::State {
|
||||||
/// as input into the transform.
|
/// as input into the transform.
|
||||||
const NewBindingPoints* new_binding_points;
|
const NewBindingPoints* new_binding_points;
|
||||||
|
|
||||||
/// Symbol for the GammaTransferParams
|
|
||||||
Symbol gamma_transfer_struct_sym;
|
|
||||||
|
|
||||||
/// Symbol for the ExternalTextureParams struct
|
/// Symbol for the ExternalTextureParams struct
|
||||||
Symbol params_struct_sym;
|
Symbol params_struct_sym;
|
||||||
|
|
||||||
|
@ -63,9 +60,6 @@ struct MultiplanarExternalTexture::State {
|
||||||
/// Symbol for the textureSampleExternal function
|
/// Symbol for the textureSampleExternal function
|
||||||
Symbol texture_sample_external_sym;
|
Symbol texture_sample_external_sym;
|
||||||
|
|
||||||
/// Symbol for the gammaCorrection function
|
|
||||||
Symbol gamma_correction_sym;
|
|
||||||
|
|
||||||
/// Storage for new bindings that have been created corresponding to an
|
/// Storage for new bindings that have been created corresponding to an
|
||||||
/// original texture_external binding.
|
/// original texture_external binding.
|
||||||
std::unordered_map<const sem::Variable*, NewBindingSymbols>
|
std::unordered_map<const sem::Variable*, NewBindingSymbols>
|
||||||
|
@ -102,7 +96,7 @@ struct MultiplanarExternalTexture::State {
|
||||||
// If we find a texture_external binding, we know we must emit the
|
// If we find a texture_external binding, we know we must emit the
|
||||||
// ExternalTextureParams struct.
|
// ExternalTextureParams struct.
|
||||||
if (!params_struct_sym.IsValid()) {
|
if (!params_struct_sym.IsValid()) {
|
||||||
createExtTexParamsStructs();
|
createExtTexParamsStruct();
|
||||||
}
|
}
|
||||||
|
|
||||||
// The binding points for the newly introduced bindings must have been
|
// The binding points for the newly introduced bindings must have been
|
||||||
|
@ -164,7 +158,7 @@ struct MultiplanarExternalTexture::State {
|
||||||
// If we find a texture_external, we must ensure the
|
// If we find a texture_external, we must ensure the
|
||||||
// ExternalTextureParams struct exists.
|
// ExternalTextureParams struct exists.
|
||||||
if (!params_struct_sym.IsValid()) {
|
if (!params_struct_sym.IsValid()) {
|
||||||
createExtTexParamsStructs();
|
createExtTexParamsStruct();
|
||||||
}
|
}
|
||||||
// When a texture_external is found, we insert all components
|
// When a texture_external is found, we insert all components
|
||||||
// the texture_external into the parameter list. We must also place
|
// the texture_external into the parameter list. We must also place
|
||||||
|
@ -242,69 +236,15 @@ struct MultiplanarExternalTexture::State {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates the parameter structs associated with the transform.
|
/// Creates the ExternalTextureParams struct.
|
||||||
void createExtTexParamsStructs() {
|
void createExtTexParamsStruct() {
|
||||||
// Create GammaTransferParams struct.
|
ast::StructMemberList member_list = {
|
||||||
ast::StructMemberList gamma_transfer_member_list = {
|
|
||||||
b.Member("G", b.ty.f32()), b.Member("A", b.ty.f32()),
|
|
||||||
b.Member("B", b.ty.f32()), b.Member("C", b.ty.f32()),
|
|
||||||
b.Member("D", b.ty.f32()), b.Member("E", b.ty.f32()),
|
|
||||||
b.Member("F", b.ty.f32()), b.Member("padding", b.ty.u32())};
|
|
||||||
|
|
||||||
gamma_transfer_struct_sym = b.Symbols().New("GammaTransferParams");
|
|
||||||
|
|
||||||
b.Structure(gamma_transfer_struct_sym, gamma_transfer_member_list);
|
|
||||||
|
|
||||||
// Create ExternalTextureParams struct.
|
|
||||||
ast::StructMemberList ext_tex_params_member_list = {
|
|
||||||
b.Member("numPlanes", b.ty.u32()),
|
b.Member("numPlanes", b.ty.u32()),
|
||||||
b.Member("yuvToRgbConversionMatrix", b.ty.mat3x4(b.ty.f32())),
|
b.Member("yuvToRgbConversionMatrix", b.ty.mat3x4(b.ty.f32()))};
|
||||||
b.Member("gammaDecodeParams", b.ty.type_name("GammaTransferParams")),
|
|
||||||
b.Member("gammaEncodeParams", b.ty.type_name("GammaTransferParams")),
|
|
||||||
b.Member("gamutConversionMatrix", b.ty.mat3x3(b.ty.f32()))};
|
|
||||||
|
|
||||||
params_struct_sym = b.Symbols().New("ExternalTextureParams");
|
params_struct_sym = b.Symbols().New("ExternalTextureParams");
|
||||||
|
|
||||||
b.Structure(params_struct_sym, ext_tex_params_member_list);
|
b.Structure(params_struct_sym, member_list);
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates the gammaCorrection function if needed and returns a call
|
|
||||||
/// expression to it.
|
|
||||||
void createGammaCorrectionFn() {
|
|
||||||
using f32 = ProgramBuilder::f32;
|
|
||||||
ast::VariableList varList = {
|
|
||||||
b.Param("v", b.ty.vec3<f32>()),
|
|
||||||
b.Param("params", b.ty.type_name(gamma_transfer_struct_sym))};
|
|
||||||
|
|
||||||
ast::StatementList statementList = {
|
|
||||||
// let cond = abs(v) < vec3(params.D);
|
|
||||||
b.Decl(
|
|
||||||
b.Const("cond", nullptr,
|
|
||||||
b.LessThan(b.Call("abs", "v"),
|
|
||||||
b.vec3<f32>(b.MemberAccessor("params", "D"))))),
|
|
||||||
// let t = sign(v) * ((params.C * abs(v)) + params.F);
|
|
||||||
b.Decl(b.Const("t", nullptr,
|
|
||||||
b.Mul(b.Call("sign", "v"),
|
|
||||||
b.Add(b.Mul(b.MemberAccessor("params", "C"),
|
|
||||||
b.Call("abs", "v")),
|
|
||||||
b.MemberAccessor("params", "F"))))),
|
|
||||||
// let f = (sign(v) * pow(((params.A * abs(v)) + params.B),
|
|
||||||
// vec3(params.G))) + params.E;
|
|
||||||
b.Decl(b.Const(
|
|
||||||
"f", nullptr,
|
|
||||||
b.Mul(b.Call("sign", "v"),
|
|
||||||
b.Add(b.Call("pow",
|
|
||||||
b.Add(b.Mul(b.MemberAccessor("params", "A"),
|
|
||||||
b.Call("abs", "v")),
|
|
||||||
b.MemberAccessor("params", "B")),
|
|
||||||
b.vec3<f32>(b.MemberAccessor("params", "G"))),
|
|
||||||
b.MemberAccessor("params", "E"))))),
|
|
||||||
// return select(f, t, cond);
|
|
||||||
b.Return(b.Call("select", "f", "t", "cond"))};
|
|
||||||
|
|
||||||
gamma_correction_sym = b.Symbols().New("gammaCorrection");
|
|
||||||
|
|
||||||
b.Func(gamma_correction_sym, varList, b.ty.vec3<f32>(), statementList, {});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Constructs a StatementList containing all the statements making up the
|
/// Constructs a StatementList containing all the statements making up the
|
||||||
|
@ -357,18 +297,6 @@ struct MultiplanarExternalTexture::State {
|
||||||
b.MemberAccessor(plane_1_call, "rg"), 1.0f),
|
b.MemberAccessor(plane_1_call, "rg"), 1.0f),
|
||||||
b.MemberAccessor(
|
b.MemberAccessor(
|
||||||
"params", "yuvToRgbConversionMatrix")))))),
|
"params", "yuvToRgbConversionMatrix")))))),
|
||||||
// color = gammaConversion(color, gammaDecodeParams);
|
|
||||||
b.Assign("color",
|
|
||||||
b.Call("gammaCorrection", "color",
|
|
||||||
b.MemberAccessor("params", "gammaDecodeParams"))),
|
|
||||||
// color = (params.gamutConversionMatrix * color);
|
|
||||||
b.Assign("color",
|
|
||||||
b.Mul(b.MemberAccessor("params", "gamutConversionMatrix"),
|
|
||||||
"color")),
|
|
||||||
// color = gammaConversion(color, gammaEncodeParams);
|
|
||||||
b.Assign("color",
|
|
||||||
b.Call("gammaCorrection", "color",
|
|
||||||
b.MemberAccessor("params", "gammaEncodeParams"))),
|
|
||||||
// return vec4<f32>(color, 1.0f);
|
// return vec4<f32>(color, 1.0f);
|
||||||
b.Return(b.vec4<f32>("color", 1.0f))};
|
b.Return(b.vec4<f32>("color", 1.0f))};
|
||||||
}
|
}
|
||||||
|
@ -390,12 +318,6 @@ struct MultiplanarExternalTexture::State {
|
||||||
<< expr->args.size() << " parameters";
|
<< expr->args.size() << " parameters";
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextureSampleExternal calls the gammaCorrection function, so ensure it
|
|
||||||
// exists.
|
|
||||||
if (!gamma_correction_sym.IsValid()) {
|
|
||||||
createGammaCorrectionFn();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!texture_sample_external_sym.IsValid()) {
|
if (!texture_sample_external_sym.IsValid()) {
|
||||||
texture_sample_external_sym = b.Symbols().New("textureSampleExternal");
|
texture_sample_external_sym = b.Symbols().New("textureSampleExternal");
|
||||||
|
|
||||||
|
@ -440,12 +362,6 @@ struct MultiplanarExternalTexture::State {
|
||||||
<< expr->args.size() << " parameters";
|
<< expr->args.size() << " parameters";
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextureLoadExternal calls the gammaCorrection function, so ensure it
|
|
||||||
// exists.
|
|
||||||
if (!gamma_correction_sym.IsValid()) {
|
|
||||||
createGammaCorrectionFn();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!texture_load_external_sym.IsValid()) {
|
if (!texture_load_external_sym.IsValid()) {
|
||||||
texture_load_external_sym = b.Symbols().New("textureLoadExternal");
|
texture_load_external_sym = b.Symbols().New("textureLoadExternal");
|
||||||
|
|
||||||
|
|
|
@ -106,23 +106,9 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||||
)";
|
)";
|
||||||
|
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct GammaTransferParams {
|
|
||||||
G : f32,
|
|
||||||
A : f32,
|
|
||||||
B : f32,
|
|
||||||
C : f32,
|
|
||||||
D : f32,
|
|
||||||
E : f32,
|
|
||||||
F : f32,
|
|
||||||
padding : u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
gammaDecodeParams : GammaTransferParams,
|
|
||||||
gammaEncodeParams : GammaTransferParams,
|
|
||||||
gamutConversionMatrix : mat3x3<f32>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
||||||
|
@ -160,23 +146,9 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||||
)";
|
)";
|
||||||
|
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct GammaTransferParams {
|
|
||||||
G : f32,
|
|
||||||
A : f32,
|
|
||||||
B : f32,
|
|
||||||
C : f32,
|
|
||||||
D : f32,
|
|
||||||
E : f32,
|
|
||||||
F : f32,
|
|
||||||
padding : u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
gammaDecodeParams : GammaTransferParams,
|
|
||||||
gammaEncodeParams : GammaTransferParams,
|
|
||||||
gamutConversionMatrix : mat3x3<f32>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
||||||
|
@ -213,23 +185,9 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||||
)";
|
)";
|
||||||
|
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct GammaTransferParams {
|
|
||||||
G : f32,
|
|
||||||
A : f32,
|
|
||||||
B : f32,
|
|
||||||
C : f32,
|
|
||||||
D : f32,
|
|
||||||
E : f32,
|
|
||||||
F : f32,
|
|
||||||
padding : u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
gammaDecodeParams : GammaTransferParams,
|
|
||||||
gammaEncodeParams : GammaTransferParams,
|
|
||||||
gamutConversionMatrix : mat3x3<f32>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||||
|
@ -240,13 +198,6 @@ struct ExternalTextureParams {
|
||||||
|
|
||||||
@group(0) @binding(1) var ext_tex : texture_2d<f32>;
|
@group(0) @binding(1) var ext_tex : texture_2d<f32>;
|
||||||
|
|
||||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
|
||||||
let cond = (abs(v) < vec3<f32>(params.D));
|
|
||||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
|
||||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
|
||||||
return select(f, t, cond);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||||
var color : vec3<f32>;
|
var color : vec3<f32>;
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
|
@ -254,9 +205,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||||
} else {
|
} else {
|
||||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = (params.gamutConversionMatrix * color);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return vec4<f32>(color, 1.0);
|
return vec4<f32>(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,36 +234,15 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||||
)";
|
)";
|
||||||
|
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct GammaTransferParams {
|
|
||||||
G : f32,
|
|
||||||
A : f32,
|
|
||||||
B : f32,
|
|
||||||
C : f32,
|
|
||||||
D : f32,
|
|
||||||
E : f32,
|
|
||||||
F : f32,
|
|
||||||
padding : u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
gammaDecodeParams : GammaTransferParams,
|
|
||||||
gammaEncodeParams : GammaTransferParams,
|
|
||||||
gamutConversionMatrix : mat3x3<f32>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||||
|
|
||||||
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||||
|
|
||||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
|
||||||
let cond = (abs(v) < vec3<f32>(params.D));
|
|
||||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
|
||||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
|
||||||
return select(f, t, cond);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||||
var color : vec3<f32>;
|
var color : vec3<f32>;
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
|
@ -323,9 +250,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||||
} else {
|
} else {
|
||||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = (params.gamutConversionMatrix * color);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return vec4<f32>(color, 1.0);
|
return vec4<f32>(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,23 +282,9 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||||
)";
|
)";
|
||||||
|
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct GammaTransferParams {
|
|
||||||
G : f32,
|
|
||||||
A : f32,
|
|
||||||
B : f32,
|
|
||||||
C : f32,
|
|
||||||
D : f32,
|
|
||||||
E : f32,
|
|
||||||
F : f32,
|
|
||||||
padding : u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
gammaDecodeParams : GammaTransferParams,
|
|
||||||
gammaEncodeParams : GammaTransferParams,
|
|
||||||
gamutConversionMatrix : mat3x3<f32>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
||||||
|
@ -383,13 +293,6 @@ struct ExternalTextureParams {
|
||||||
|
|
||||||
@group(0) @binding(0) var ext_tex : texture_2d<f32>;
|
@group(0) @binding(0) var ext_tex : texture_2d<f32>;
|
||||||
|
|
||||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
|
||||||
let cond = (abs(v) < vec3<f32>(params.D));
|
|
||||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
|
||||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
|
||||||
return select(f, t, cond);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<f32> {
|
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||||
var color : vec3<f32>;
|
var color : vec3<f32>;
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
|
@ -397,9 +300,6 @@ fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord
|
||||||
} else {
|
} else {
|
||||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = (params.gamutConversionMatrix * color);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return vec4<f32>(color, 1.0);
|
return vec4<f32>(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,36 +328,15 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||||
)";
|
)";
|
||||||
|
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct GammaTransferParams {
|
|
||||||
G : f32,
|
|
||||||
A : f32,
|
|
||||||
B : f32,
|
|
||||||
C : f32,
|
|
||||||
D : f32,
|
|
||||||
E : f32,
|
|
||||||
F : f32,
|
|
||||||
padding : u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
gammaDecodeParams : GammaTransferParams,
|
|
||||||
gammaEncodeParams : GammaTransferParams,
|
|
||||||
gamutConversionMatrix : mat3x3<f32>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
@group(0) @binding(1) var ext_tex_plane_1 : texture_2d<f32>;
|
||||||
|
|
||||||
@group(0) @binding(2) var<uniform> ext_tex_params : ExternalTextureParams;
|
@group(0) @binding(2) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||||
|
|
||||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
|
||||||
let cond = (abs(v) < vec3<f32>(params.D));
|
|
||||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
|
||||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
|
||||||
return select(f, t, cond);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<f32> {
|
fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord : vec2<i32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||||
var color : vec3<f32>;
|
var color : vec3<f32>;
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
|
@ -465,9 +344,6 @@ fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord
|
||||||
} else {
|
} else {
|
||||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = (params.gamutConversionMatrix * color);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return vec4<f32>(color, 1.0);
|
return vec4<f32>(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,23 +376,9 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||||
)";
|
)";
|
||||||
|
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct GammaTransferParams {
|
|
||||||
G : f32,
|
|
||||||
A : f32,
|
|
||||||
B : f32,
|
|
||||||
C : f32,
|
|
||||||
D : f32,
|
|
||||||
E : f32,
|
|
||||||
F : f32,
|
|
||||||
padding : u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
gammaDecodeParams : GammaTransferParams,
|
|
||||||
gammaEncodeParams : GammaTransferParams,
|
|
||||||
gamutConversionMatrix : mat3x3<f32>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||||
|
@ -527,13 +389,6 @@ struct ExternalTextureParams {
|
||||||
|
|
||||||
@group(0) @binding(1) var ext_tex : texture_2d<f32>;
|
@group(0) @binding(1) var ext_tex : texture_2d<f32>;
|
||||||
|
|
||||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
|
||||||
let cond = (abs(v) < vec3<f32>(params.D));
|
|
||||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
|
||||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
|
||||||
return select(f, t, cond);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||||
var color : vec3<f32>;
|
var color : vec3<f32>;
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
|
@ -541,9 +396,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||||
} else {
|
} else {
|
||||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = (params.gamutConversionMatrix * color);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return vec4<f32>(color, 1.0);
|
return vec4<f32>(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -554,9 +406,6 @@ fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord
|
||||||
} else {
|
} else {
|
||||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = (params.gamutConversionMatrix * color);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return vec4<f32>(color, 1.0);
|
return vec4<f32>(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -587,36 +436,15 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||||
)";
|
)";
|
||||||
|
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct GammaTransferParams {
|
|
||||||
G : f32,
|
|
||||||
A : f32,
|
|
||||||
B : f32,
|
|
||||||
C : f32,
|
|
||||||
D : f32,
|
|
||||||
E : f32,
|
|
||||||
F : f32,
|
|
||||||
padding : u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
gammaDecodeParams : GammaTransferParams,
|
|
||||||
gammaEncodeParams : GammaTransferParams,
|
|
||||||
gamutConversionMatrix : mat3x3<f32>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||||
|
|
||||||
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||||
|
|
||||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
|
||||||
let cond = (abs(v) < vec3<f32>(params.D));
|
|
||||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
|
||||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
|
||||||
return select(f, t, cond);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||||
var color : vec3<f32>;
|
var color : vec3<f32>;
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
|
@ -624,9 +452,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||||
} else {
|
} else {
|
||||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = (params.gamutConversionMatrix * color);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return vec4<f32>(color, 1.0);
|
return vec4<f32>(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -637,9 +462,6 @@ fn textureLoadExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, coord
|
||||||
} else {
|
} else {
|
||||||
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
color = (vec4<f32>(textureLoad(plane0, coord, 0).r, textureLoad(plane1, coord, 0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = (params.gamutConversionMatrix * color);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return vec4<f32>(color, 1.0);
|
return vec4<f32>(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -676,23 +498,9 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||||
)";
|
)";
|
||||||
|
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct GammaTransferParams {
|
|
||||||
G : f32,
|
|
||||||
A : f32,
|
|
||||||
B : f32,
|
|
||||||
C : f32,
|
|
||||||
D : f32,
|
|
||||||
E : f32,
|
|
||||||
F : f32,
|
|
||||||
padding : u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
gammaDecodeParams : GammaTransferParams,
|
|
||||||
gammaEncodeParams : GammaTransferParams,
|
|
||||||
gamutConversionMatrix : mat3x3<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>;
|
||||||
|
@ -721,13 +529,6 @@ 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 gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
|
||||||
let cond = (abs(v) < vec3<f32>(params.D));
|
|
||||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
|
||||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
|
||||||
return select(f, t, cond);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||||
var color : vec3<f32>;
|
var color : vec3<f32>;
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
|
@ -735,9 +536,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||||
} else {
|
} else {
|
||||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = (params.gamutConversionMatrix * color);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return vec4<f32>(color, 1.0);
|
return vec4<f32>(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -777,36 +575,15 @@ fn main() {
|
||||||
)";
|
)";
|
||||||
|
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct GammaTransferParams {
|
|
||||||
G : f32,
|
|
||||||
A : f32,
|
|
||||||
B : f32,
|
|
||||||
C : f32,
|
|
||||||
D : f32,
|
|
||||||
E : f32,
|
|
||||||
F : f32,
|
|
||||||
padding : u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
gammaDecodeParams : GammaTransferParams,
|
|
||||||
gammaEncodeParams : GammaTransferParams,
|
|
||||||
gamutConversionMatrix : mat3x3<f32>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||||
|
|
||||||
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||||
|
|
||||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
|
||||||
let cond = (abs(v) < vec3<f32>(params.D));
|
|
||||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
|
||||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
|
||||||
return select(f, t, cond);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||||
var color : vec3<f32>;
|
var color : vec3<f32>;
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
|
@ -814,9 +591,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||||
} else {
|
} else {
|
||||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = (params.gamutConversionMatrix * color);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return vec4<f32>(color, 1.0);
|
return vec4<f32>(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -861,23 +635,9 @@ fn f(t : texture_external, s : sampler) {
|
||||||
)";
|
)";
|
||||||
|
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct GammaTransferParams {
|
|
||||||
G : f32,
|
|
||||||
A : f32,
|
|
||||||
B : f32,
|
|
||||||
C : f32,
|
|
||||||
D : f32,
|
|
||||||
E : f32,
|
|
||||||
F : f32,
|
|
||||||
padding : u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
gammaDecodeParams : GammaTransferParams,
|
|
||||||
gammaEncodeParams : GammaTransferParams,
|
|
||||||
gamutConversionMatrix : mat3x3<f32>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||||
|
@ -889,13 +649,6 @@ fn main() {
|
||||||
f(ext_tex, ext_tex_plane_1, ext_tex_params, smp);
|
f(ext_tex, ext_tex_plane_1, ext_tex_params, smp);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
|
||||||
let cond = (abs(v) < vec3<f32>(params.D));
|
|
||||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
|
||||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
|
||||||
return select(f, t, cond);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||||
var color : vec3<f32>;
|
var color : vec3<f32>;
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
|
@ -903,9 +656,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||||
} else {
|
} else {
|
||||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = (params.gamutConversionMatrix * color);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return vec4<f32>(color, 1.0);
|
return vec4<f32>(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -944,36 +694,15 @@ fn main() {
|
||||||
)";
|
)";
|
||||||
|
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct GammaTransferParams {
|
|
||||||
G : f32,
|
|
||||||
A : f32,
|
|
||||||
B : f32,
|
|
||||||
C : f32,
|
|
||||||
D : f32,
|
|
||||||
E : f32,
|
|
||||||
F : f32,
|
|
||||||
padding : u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
gammaDecodeParams : GammaTransferParams,
|
|
||||||
gammaEncodeParams : GammaTransferParams,
|
|
||||||
gamutConversionMatrix : mat3x3<f32>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||||
|
|
||||||
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||||
|
|
||||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
|
||||||
let cond = (abs(v) < vec3<f32>(params.D));
|
|
||||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
|
||||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
|
||||||
return select(f, t, cond);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||||
var color : vec3<f32>;
|
var color : vec3<f32>;
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
|
@ -981,9 +710,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||||
} else {
|
} else {
|
||||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = (params.gamutConversionMatrix * color);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return vec4<f32>(color, 1.0);
|
return vec4<f32>(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1029,23 +755,9 @@ fn main() {
|
||||||
)";
|
)";
|
||||||
|
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct GammaTransferParams {
|
|
||||||
G : f32,
|
|
||||||
A : f32,
|
|
||||||
B : f32,
|
|
||||||
C : f32,
|
|
||||||
D : f32,
|
|
||||||
E : f32,
|
|
||||||
F : f32,
|
|
||||||
padding : u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
gammaDecodeParams : GammaTransferParams,
|
|
||||||
gammaEncodeParams : GammaTransferParams,
|
|
||||||
gamutConversionMatrix : mat3x3<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>;
|
||||||
|
@ -1056,13 +768,6 @@ 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 gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
|
||||||
let cond = (abs(v) < vec3<f32>(params.D));
|
|
||||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
|
||||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
|
||||||
return select(f, t, cond);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||||
var color : vec3<f32>;
|
var color : vec3<f32>;
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
|
@ -1070,9 +775,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||||
} else {
|
} else {
|
||||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = (params.gamutConversionMatrix * color);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return vec4<f32>(color, 1.0);
|
return vec4<f32>(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1124,23 +826,9 @@ fn f(t : texture_external, s : sampler, t2 : texture_external) {
|
||||||
)";
|
)";
|
||||||
|
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct GammaTransferParams {
|
|
||||||
G : f32,
|
|
||||||
A : f32,
|
|
||||||
B : f32,
|
|
||||||
C : f32,
|
|
||||||
D : f32,
|
|
||||||
E : f32,
|
|
||||||
F : f32,
|
|
||||||
padding : u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
gammaDecodeParams : GammaTransferParams,
|
|
||||||
gammaEncodeParams : GammaTransferParams,
|
|
||||||
gamutConversionMatrix : mat3x3<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>;
|
||||||
|
@ -1156,13 +844,6 @@ fn main() {
|
||||||
f(ext_tex, ext_tex_plane_1, ext_tex_params, smp, ext_tex2, ext_tex_plane_1_1, ext_tex_params_1);
|
f(ext_tex, ext_tex_plane_1, ext_tex_params, smp, ext_tex2, ext_tex_plane_1_1, ext_tex_params_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
|
||||||
let cond = (abs(v) < vec3<f32>(params.D));
|
|
||||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
|
||||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
|
||||||
return select(f, t, cond);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||||
var color : vec3<f32>;
|
var color : vec3<f32>;
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
|
@ -1170,9 +851,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||||
} else {
|
} else {
|
||||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = (params.gamutConversionMatrix * color);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return vec4<f32>(color, 1.0);
|
return vec4<f32>(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1219,36 +897,15 @@ fn main() {
|
||||||
)";
|
)";
|
||||||
|
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct GammaTransferParams {
|
|
||||||
G : f32,
|
|
||||||
A : f32,
|
|
||||||
B : f32,
|
|
||||||
C : f32,
|
|
||||||
D : f32,
|
|
||||||
E : f32,
|
|
||||||
F : f32,
|
|
||||||
padding : u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
gammaDecodeParams : GammaTransferParams,
|
|
||||||
gammaEncodeParams : GammaTransferParams,
|
|
||||||
gamutConversionMatrix : mat3x3<f32>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||||
|
|
||||||
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||||
|
|
||||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
|
||||||
let cond = (abs(v) < vec3<f32>(params.D));
|
|
||||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
|
||||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
|
||||||
return select(f, t, cond);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||||
var color : vec3<f32>;
|
var color : vec3<f32>;
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
|
@ -1256,9 +913,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||||
} else {
|
} else {
|
||||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = (params.gamutConversionMatrix * color);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return vec4<f32>(color, 1.0);
|
return vec4<f32>(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1311,36 +965,15 @@ fn main() {
|
||||||
)";
|
)";
|
||||||
|
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct GammaTransferParams {
|
|
||||||
G : f32,
|
|
||||||
A : f32,
|
|
||||||
B : f32,
|
|
||||||
C : f32,
|
|
||||||
D : f32,
|
|
||||||
E : f32,
|
|
||||||
F : f32,
|
|
||||||
padding : u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
gammaDecodeParams : GammaTransferParams,
|
|
||||||
gammaEncodeParams : GammaTransferParams,
|
|
||||||
gamutConversionMatrix : mat3x3<f32>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||||
|
|
||||||
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
@group(0) @binding(3) var<uniform> ext_tex_params : ExternalTextureParams;
|
||||||
|
|
||||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
|
||||||
let cond = (abs(v) < vec3<f32>(params.D));
|
|
||||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
|
||||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
|
||||||
return select(f, t, cond);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||||
var color : vec3<f32>;
|
var color : vec3<f32>;
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
|
@ -1348,9 +981,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||||
} else {
|
} else {
|
||||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = (params.gamutConversionMatrix * color);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return vec4<f32>(color, 1.0);
|
return vec4<f32>(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1391,23 +1021,9 @@ fn f(ext_tex : texture_external) -> vec2<i32> {
|
||||||
)";
|
)";
|
||||||
|
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct GammaTransferParams {
|
|
||||||
G : f32,
|
|
||||||
A : f32,
|
|
||||||
B : f32,
|
|
||||||
C : f32,
|
|
||||||
D : f32,
|
|
||||||
E : f32,
|
|
||||||
F : f32,
|
|
||||||
padding : u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
gammaDecodeParams : GammaTransferParams,
|
|
||||||
gammaEncodeParams : GammaTransferParams,
|
|
||||||
gamutConversionMatrix : mat3x3<f32>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn f(ext_tex : texture_2d<f32>, ext_tex_plane_1 : texture_2d<f32>, ext_tex_params : ExternalTextureParams) -> vec2<i32> {
|
fn f(ext_tex : texture_2d<f32>, ext_tex_plane_1 : texture_2d<f32>, ext_tex_params : ExternalTextureParams) -> vec2<i32> {
|
||||||
|
@ -1441,23 +1057,9 @@ fn main() {
|
||||||
)";
|
)";
|
||||||
|
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct GammaTransferParams {
|
|
||||||
G : f32,
|
|
||||||
A : f32,
|
|
||||||
B : f32,
|
|
||||||
C : f32,
|
|
||||||
D : f32,
|
|
||||||
E : f32,
|
|
||||||
F : f32,
|
|
||||||
padding : u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
gammaDecodeParams : GammaTransferParams,
|
|
||||||
gammaEncodeParams : GammaTransferParams,
|
|
||||||
gamutConversionMatrix : mat3x3<f32>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||||
|
@ -1466,13 +1068,6 @@ struct ExternalTextureParams {
|
||||||
|
|
||||||
type ET = texture_external;
|
type ET = texture_external;
|
||||||
|
|
||||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
|
||||||
let cond = (abs(v) < vec3<f32>(params.D));
|
|
||||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
|
||||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
|
||||||
return select(f, t, cond);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||||
var color : vec3<f32>;
|
var color : vec3<f32>;
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
|
@ -1480,9 +1075,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||||
} else {
|
} else {
|
||||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = (params.gamutConversionMatrix * color);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return vec4<f32>(color, 1.0);
|
return vec4<f32>(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1527,23 +1119,9 @@ type ET = texture_external;
|
||||||
)";
|
)";
|
||||||
|
|
||||||
auto* expect = R"(
|
auto* expect = R"(
|
||||||
struct GammaTransferParams {
|
|
||||||
G : f32,
|
|
||||||
A : f32,
|
|
||||||
B : f32,
|
|
||||||
C : f32,
|
|
||||||
D : f32,
|
|
||||||
E : f32,
|
|
||||||
F : f32,
|
|
||||||
padding : u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
numPlanes : u32,
|
numPlanes : u32,
|
||||||
yuvToRgbConversionMatrix : mat3x4<f32>,
|
yuvToRgbConversionMatrix : mat3x4<f32>,
|
||||||
gammaDecodeParams : GammaTransferParams,
|
|
||||||
gammaEncodeParams : GammaTransferParams,
|
|
||||||
gamutConversionMatrix : mat3x3<f32>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
@group(0) @binding(2) var ext_tex_plane_1 : texture_2d<f32>;
|
||||||
|
@ -1555,13 +1133,6 @@ fn main() {
|
||||||
f(ext_tex, ext_tex_plane_1, ext_tex_params, smp);
|
f(ext_tex, ext_tex_plane_1, ext_tex_params, smp);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gammaCorrection(v : vec3<f32>, params : GammaTransferParams) -> vec3<f32> {
|
|
||||||
let cond = (abs(v) < vec3<f32>(params.D));
|
|
||||||
let t = (sign(v) * ((params.C * abs(v)) + params.F));
|
|
||||||
let f = (sign(v) * (pow(((params.A * abs(v)) + params.B), vec3<f32>(params.G)) + params.E));
|
|
||||||
return select(f, t, cond);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp : sampler, coord : vec2<f32>, params : ExternalTextureParams) -> vec4<f32> {
|
||||||
var color : vec3<f32>;
|
var color : vec3<f32>;
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
|
@ -1569,9 +1140,6 @@ fn textureSampleExternal(plane0 : texture_2d<f32>, plane1 : texture_2d<f32>, smp
|
||||||
} else {
|
} else {
|
||||||
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0).r, textureSampleLevel(plane1, smp, coord, 0.0).rg, 1.0) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = (params.gamutConversionMatrix * color);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return vec4<f32>(color, 1.0);
|
return vec4<f32>(color, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,13 @@
|
||||||
#version 310 es
|
#version 310 es
|
||||||
|
|
||||||
struct GammaTransferParams {
|
|
||||||
float G;
|
|
||||||
float A;
|
|
||||||
float B;
|
|
||||||
float C;
|
|
||||||
float D;
|
|
||||||
float E;
|
|
||||||
float F;
|
|
||||||
uint padding;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
uint numPlanes;
|
uint numPlanes;
|
||||||
mat3x4 yuvToRgbConversionMatrix;
|
mat3x4 yuvToRgbConversionMatrix;
|
||||||
GammaTransferParams gammaDecodeParams;
|
|
||||||
GammaTransferParams gammaEncodeParams;
|
|
||||||
mat3 gamutConversionMatrix;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
layout(binding = 2) uniform ExternalTextureParams_1 {
|
layout(binding = 2) uniform ExternalTextureParams_1 {
|
||||||
uint numPlanes;
|
uint numPlanes;
|
||||||
mat3x4 yuvToRgbConversionMatrix;
|
mat3x4 yuvToRgbConversionMatrix;
|
||||||
GammaTransferParams gammaDecodeParams;
|
|
||||||
GammaTransferParams gammaEncodeParams;
|
|
||||||
mat3 gamutConversionMatrix;
|
|
||||||
} ext_tex_params;
|
} ext_tex_params;
|
||||||
|
|
||||||
uniform highp sampler2D arg_0_1;
|
uniform highp sampler2D arg_0_1;
|
||||||
|
@ -48,31 +31,14 @@ void main() {
|
||||||
#version 310 es
|
#version 310 es
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
struct GammaTransferParams {
|
|
||||||
float G;
|
|
||||||
float A;
|
|
||||||
float B;
|
|
||||||
float C;
|
|
||||||
float D;
|
|
||||||
float E;
|
|
||||||
float F;
|
|
||||||
uint padding;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
uint numPlanes;
|
uint numPlanes;
|
||||||
mat3x4 yuvToRgbConversionMatrix;
|
mat3x4 yuvToRgbConversionMatrix;
|
||||||
GammaTransferParams gammaDecodeParams;
|
|
||||||
GammaTransferParams gammaEncodeParams;
|
|
||||||
mat3 gamutConversionMatrix;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
layout(binding = 2) uniform ExternalTextureParams_1 {
|
layout(binding = 2) uniform ExternalTextureParams_1 {
|
||||||
uint numPlanes;
|
uint numPlanes;
|
||||||
mat3x4 yuvToRgbConversionMatrix;
|
mat3x4 yuvToRgbConversionMatrix;
|
||||||
GammaTransferParams gammaDecodeParams;
|
|
||||||
GammaTransferParams gammaEncodeParams;
|
|
||||||
mat3 gamutConversionMatrix;
|
|
||||||
} ext_tex_params;
|
} ext_tex_params;
|
||||||
|
|
||||||
uniform highp sampler2D arg_0_1;
|
uniform highp sampler2D arg_0_1;
|
||||||
|
@ -90,31 +56,14 @@ void main() {
|
||||||
}
|
}
|
||||||
#version 310 es
|
#version 310 es
|
||||||
|
|
||||||
struct GammaTransferParams {
|
|
||||||
float G;
|
|
||||||
float A;
|
|
||||||
float B;
|
|
||||||
float C;
|
|
||||||
float D;
|
|
||||||
float E;
|
|
||||||
float F;
|
|
||||||
uint padding;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
uint numPlanes;
|
uint numPlanes;
|
||||||
mat3x4 yuvToRgbConversionMatrix;
|
mat3x4 yuvToRgbConversionMatrix;
|
||||||
GammaTransferParams gammaDecodeParams;
|
|
||||||
GammaTransferParams gammaEncodeParams;
|
|
||||||
mat3 gamutConversionMatrix;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
layout(binding = 2) uniform ExternalTextureParams_1 {
|
layout(binding = 2) uniform ExternalTextureParams_1 {
|
||||||
uint numPlanes;
|
uint numPlanes;
|
||||||
mat3x4 yuvToRgbConversionMatrix;
|
mat3x4 yuvToRgbConversionMatrix;
|
||||||
GammaTransferParams gammaDecodeParams;
|
|
||||||
GammaTransferParams gammaEncodeParams;
|
|
||||||
mat3 gamutConversionMatrix;
|
|
||||||
} 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[11];
|
uint4 ext_tex_params[4];
|
||||||
};
|
};
|
||||||
Texture2D<float4> arg_0 : register(t0, space1);
|
Texture2D<float4> arg_0 : register(t0, space1);
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,9 @@
|
||||||
#include <metal_stdlib>
|
#include <metal_stdlib>
|
||||||
|
|
||||||
using namespace metal;
|
using namespace metal;
|
||||||
struct GammaTransferParams {
|
|
||||||
float G;
|
|
||||||
float A;
|
|
||||||
float B;
|
|
||||||
float C;
|
|
||||||
float D;
|
|
||||||
float E;
|
|
||||||
float F;
|
|
||||||
uint padding;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
uint numPlanes;
|
uint numPlanes;
|
||||||
float3x4 yuvToRgbConversionMatrix;
|
float3x4 yuvToRgbConversionMatrix;
|
||||||
GammaTransferParams gammaDecodeParams;
|
|
||||||
GammaTransferParams gammaEncodeParams;
|
|
||||||
float3x3 gamutConversionMatrix;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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: 47
|
; Bound: 44
|
||||||
; Schema: 0
|
; Schema: 0
|
||||||
OpCapability Shader
|
OpCapability Shader
|
||||||
OpCapability ImageQuery
|
OpCapability ImageQuery
|
||||||
|
@ -17,18 +17,6 @@
|
||||||
OpName %ExternalTextureParams "ExternalTextureParams"
|
OpName %ExternalTextureParams "ExternalTextureParams"
|
||||||
OpMemberName %ExternalTextureParams 0 "numPlanes"
|
OpMemberName %ExternalTextureParams 0 "numPlanes"
|
||||||
OpMemberName %ExternalTextureParams 1 "yuvToRgbConversionMatrix"
|
OpMemberName %ExternalTextureParams 1 "yuvToRgbConversionMatrix"
|
||||||
OpMemberName %ExternalTextureParams 2 "gammaDecodeParams"
|
|
||||||
OpName %GammaTransferParams "GammaTransferParams"
|
|
||||||
OpMemberName %GammaTransferParams 0 "G"
|
|
||||||
OpMemberName %GammaTransferParams 1 "A"
|
|
||||||
OpMemberName %GammaTransferParams 2 "B"
|
|
||||||
OpMemberName %GammaTransferParams 3 "C"
|
|
||||||
OpMemberName %GammaTransferParams 4 "D"
|
|
||||||
OpMemberName %GammaTransferParams 5 "E"
|
|
||||||
OpMemberName %GammaTransferParams 6 "F"
|
|
||||||
OpMemberName %GammaTransferParams 7 "padding"
|
|
||||||
OpMemberName %ExternalTextureParams 3 "gammaEncodeParams"
|
|
||||||
OpMemberName %ExternalTextureParams 4 "gamutConversionMatrix"
|
|
||||||
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"
|
||||||
|
@ -46,19 +34,6 @@
|
||||||
OpMemberDecorate %ExternalTextureParams 1 Offset 16
|
OpMemberDecorate %ExternalTextureParams 1 Offset 16
|
||||||
OpMemberDecorate %ExternalTextureParams 1 ColMajor
|
OpMemberDecorate %ExternalTextureParams 1 ColMajor
|
||||||
OpMemberDecorate %ExternalTextureParams 1 MatrixStride 16
|
OpMemberDecorate %ExternalTextureParams 1 MatrixStride 16
|
||||||
OpMemberDecorate %ExternalTextureParams 2 Offset 64
|
|
||||||
OpMemberDecorate %GammaTransferParams 0 Offset 0
|
|
||||||
OpMemberDecorate %GammaTransferParams 1 Offset 4
|
|
||||||
OpMemberDecorate %GammaTransferParams 2 Offset 8
|
|
||||||
OpMemberDecorate %GammaTransferParams 3 Offset 12
|
|
||||||
OpMemberDecorate %GammaTransferParams 4 Offset 16
|
|
||||||
OpMemberDecorate %GammaTransferParams 5 Offset 20
|
|
||||||
OpMemberDecorate %GammaTransferParams 6 Offset 24
|
|
||||||
OpMemberDecorate %GammaTransferParams 7 Offset 28
|
|
||||||
OpMemberDecorate %ExternalTextureParams 3 Offset 96
|
|
||||||
OpMemberDecorate %ExternalTextureParams 4 Offset 128
|
|
||||||
OpMemberDecorate %ExternalTextureParams 4 ColMajor
|
|
||||||
OpMemberDecorate %ExternalTextureParams 4 MatrixStride 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
|
||||||
|
@ -77,49 +52,46 @@
|
||||||
%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
|
||||||
%mat3v4float = OpTypeMatrix %v4float 3
|
%mat3v4float = OpTypeMatrix %v4float 3
|
||||||
%GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
|
%ExternalTextureParams = OpTypeStruct %uint %mat3v4float
|
||||||
%v3float = OpTypeVector %float 3
|
|
||||||
%mat3v3float = OpTypeMatrix %v3float 3
|
|
||||||
%ExternalTextureParams = OpTypeStruct %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
|
|
||||||
%_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
|
||||||
%21 = 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
|
||||||
%32 = OpConstantNull %v2int
|
%29 = OpConstantNull %v2int
|
||||||
%33 = OpTypeFunction %v4float
|
%30 = OpTypeFunction %v4float
|
||||||
%float_1 = OpConstant %float 1
|
%float_1 = OpConstant %float 1
|
||||||
%textureDimensions_ba1481 = OpFunction %void None %21
|
%textureDimensions_ba1481 = OpFunction %void None %18
|
||||||
%24 = OpLabel
|
%21 = OpLabel
|
||||||
%res = OpVariable %_ptr_Function_v2int Function %32
|
%res = OpVariable %_ptr_Function_v2int Function %29
|
||||||
%28 = OpLoad %11 %arg_0
|
%25 = OpLoad %11 %arg_0
|
||||||
%25 = OpImageQuerySizeLod %v2int %28 %int_0
|
%22 = OpImageQuerySizeLod %v2int %25 %int_0
|
||||||
OpStore %res %25
|
OpStore %res %22
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%vertex_main_inner = OpFunction %v4float None %33
|
%vertex_main_inner = OpFunction %v4float None %30
|
||||||
%35 = OpLabel
|
%32 = OpLabel
|
||||||
%36 = OpFunctionCall %void %textureDimensions_ba1481
|
%33 = OpFunctionCall %void %textureDimensions_ba1481
|
||||||
OpReturnValue %5
|
OpReturnValue %5
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%vertex_main = OpFunction %void None %21
|
%vertex_main = OpFunction %void None %18
|
||||||
%38 = OpLabel
|
%35 = OpLabel
|
||||||
%39 = OpFunctionCall %v4float %vertex_main_inner
|
%36 = OpFunctionCall %v4float %vertex_main_inner
|
||||||
OpStore %value %39
|
OpStore %value %36
|
||||||
OpStore %vertex_point_size %float_1
|
OpStore %vertex_point_size %float_1
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%fragment_main = OpFunction %void None %21
|
%fragment_main = OpFunction %void None %18
|
||||||
|
%39 = OpLabel
|
||||||
|
%40 = OpFunctionCall %void %textureDimensions_ba1481
|
||||||
|
OpReturn
|
||||||
|
OpFunctionEnd
|
||||||
|
%compute_main = OpFunction %void None %18
|
||||||
%42 = OpLabel
|
%42 = OpLabel
|
||||||
%43 = OpFunctionCall %void %textureDimensions_ba1481
|
%43 = OpFunctionCall %void %textureDimensions_ba1481
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%compute_main = OpFunction %void None %21
|
|
||||||
%45 = OpLabel
|
|
||||||
%46 = OpFunctionCall %void %textureDimensions_ba1481
|
|
||||||
OpReturn
|
|
||||||
OpFunctionEnd
|
|
||||||
|
|
|
@ -1,34 +1,14 @@
|
||||||
struct GammaTransferParams {
|
|
||||||
float G;
|
|
||||||
float A;
|
|
||||||
float B;
|
|
||||||
float C;
|
|
||||||
float D;
|
|
||||||
float E;
|
|
||||||
float F;
|
|
||||||
uint padding;
|
|
||||||
};
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
uint numPlanes;
|
uint numPlanes;
|
||||||
float3x4 yuvToRgbConversionMatrix;
|
float3x4 yuvToRgbConversionMatrix;
|
||||||
GammaTransferParams gammaDecodeParams;
|
|
||||||
GammaTransferParams gammaEncodeParams;
|
|
||||||
float3x3 gamutConversionMatrix;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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[11];
|
uint4 ext_tex_params[4];
|
||||||
};
|
};
|
||||||
Texture2D<float4> arg_0 : register(t0, space1);
|
Texture2D<float4> arg_0 : register(t0, space1);
|
||||||
|
|
||||||
float3 gammaCorrection(float3 v, GammaTransferParams params) {
|
|
||||||
const bool3 cond = (abs(v) < float3((params.D).xxx));
|
|
||||||
const float3 t = (sign(v) * ((params.C * abs(v)) + params.F));
|
|
||||||
const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E));
|
|
||||||
return (cond ? t : f);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
float3 color = float3(0.0f, 0.0f, 0.0f);
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
|
@ -36,43 +16,20 @@ float4 textureLoadExternal(Texture2D<float4> plane0, Texture2D<float4> plane1, i
|
||||||
} else {
|
} else {
|
||||||
color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord, 0)).rg, 1.0f));
|
color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord, 0)).rg, 1.0f));
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = mul(color, params.gamutConversionMatrix);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return float4(color, 1.0f);
|
return float4(color, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
float3x4 tint_symbol_3(uint4 buffer[11], 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 + 16u)) / 4;
|
const uint scalar_offset_1 = ((offset + 16u)) / 4;
|
||||||
const uint scalar_offset_2 = ((offset + 32u)) / 4;
|
const uint scalar_offset_2 = ((offset + 32u)) / 4;
|
||||||
return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
|
return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
|
||||||
}
|
}
|
||||||
|
|
||||||
GammaTransferParams tint_symbol_5(uint4 buffer[11], uint offset) {
|
ExternalTextureParams tint_symbol_1(uint4 buffer[4], uint offset) {
|
||||||
const uint scalar_offset_3 = ((offset + 0u)) / 4;
|
const uint scalar_offset_3 = ((offset + 0u)) / 4;
|
||||||
const uint scalar_offset_4 = ((offset + 4u)) / 4;
|
const ExternalTextureParams tint_symbol_5 = {buffer[scalar_offset_3 / 4][scalar_offset_3 % 4], tint_symbol_3(buffer, (offset + 16u))};
|
||||||
const uint scalar_offset_5 = ((offset + 8u)) / 4;
|
return tint_symbol_5;
|
||||||
const uint scalar_offset_6 = ((offset + 12u)) / 4;
|
|
||||||
const uint scalar_offset_7 = ((offset + 16u)) / 4;
|
|
||||||
const uint scalar_offset_8 = ((offset + 20u)) / 4;
|
|
||||||
const uint scalar_offset_9 = ((offset + 24u)) / 4;
|
|
||||||
const uint scalar_offset_10 = ((offset + 28u)) / 4;
|
|
||||||
const GammaTransferParams tint_symbol_9 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]};
|
|
||||||
return tint_symbol_9;
|
|
||||||
}
|
|
||||||
|
|
||||||
float3x3 tint_symbol_7(uint4 buffer[11], uint offset) {
|
|
||||||
const uint scalar_offset_11 = ((offset + 0u)) / 4;
|
|
||||||
const uint scalar_offset_12 = ((offset + 16u)) / 4;
|
|
||||||
const uint scalar_offset_13 = ((offset + 32u)) / 4;
|
|
||||||
return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
|
|
||||||
}
|
|
||||||
|
|
||||||
ExternalTextureParams tint_symbol_1(uint4 buffer[11], uint offset) {
|
|
||||||
const uint scalar_offset_14 = ((offset + 0u)) / 4;
|
|
||||||
const ExternalTextureParams tint_symbol_10 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u))};
|
|
||||||
return tint_symbol_10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void textureLoad_8acf41() {
|
void textureLoad_8acf41() {
|
||||||
|
|
|
@ -1,33 +1,12 @@
|
||||||
#include <metal_stdlib>
|
#include <metal_stdlib>
|
||||||
|
|
||||||
using namespace metal;
|
using namespace metal;
|
||||||
struct GammaTransferParams {
|
|
||||||
/* 0x0000 */ float G;
|
|
||||||
/* 0x0004 */ float A;
|
|
||||||
/* 0x0008 */ float B;
|
|
||||||
/* 0x000c */ float C;
|
|
||||||
/* 0x0010 */ float D;
|
|
||||||
/* 0x0014 */ float E;
|
|
||||||
/* 0x0018 */ float F;
|
|
||||||
/* 0x001c */ uint padding;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
/* 0x0000 */ uint numPlanes;
|
/* 0x0000 */ uint numPlanes;
|
||||||
/* 0x0004 */ int8_t tint_pad[12];
|
/* 0x0004 */ int8_t tint_pad[12];
|
||||||
/* 0x0010 */ float3x4 yuvToRgbConversionMatrix;
|
/* 0x0010 */ float3x4 yuvToRgbConversionMatrix;
|
||||||
/* 0x0040 */ GammaTransferParams gammaDecodeParams;
|
|
||||||
/* 0x0060 */ GammaTransferParams gammaEncodeParams;
|
|
||||||
/* 0x0080 */ float3x3 gamutConversionMatrix;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
float3 gammaCorrection(float3 v, GammaTransferParams params) {
|
|
||||||
bool3 const cond = (fabs(v) < float3(params.D));
|
|
||||||
float3 const t = (sign(v) * ((params.C * fabs(v)) + params.F));
|
|
||||||
float3 const f = (sign(v) * (pow(((params.A * fabs(v)) + params.B), float3(params.G)) + params.E));
|
|
||||||
return select(f, t, cond);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
float3 color = 0.0f;
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
|
@ -35,9 +14,6 @@ float4 textureLoadExternal(texture2d<float, access::sample> plane0, texture2d<fl
|
||||||
} else {
|
} else {
|
||||||
color = (float4(plane0.read(uint2(coord), 0)[0], float4(plane1.read(uint2(coord), 0)).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
color = (float4(plane0.read(uint2(coord), 0)[0], float4(plane1.read(uint2(coord), 0)).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = (params.gamutConversionMatrix * color);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return float4(color, 1.0f);
|
return float4(color, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
; SPIR-V
|
; SPIR-V
|
||||||
; Version: 1.3
|
; Version: 1.3
|
||||||
; Generator: Google Tint Compiler; 0
|
; Generator: Google Tint Compiler; 0
|
||||||
; Bound: 129
|
; Bound: 81
|
||||||
; Schema: 0
|
; Schema: 0
|
||||||
OpCapability Shader
|
OpCapability Shader
|
||||||
%27 = OpExtInstImport "GLSL.std.450"
|
|
||||||
OpMemoryModel Logical GLSL450
|
OpMemoryModel Logical GLSL450
|
||||||
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
|
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
|
||||||
OpEntryPoint Fragment %fragment_main "fragment_main"
|
OpEntryPoint Fragment %fragment_main "fragment_main"
|
||||||
|
@ -17,28 +16,13 @@
|
||||||
OpName %ExternalTextureParams "ExternalTextureParams"
|
OpName %ExternalTextureParams "ExternalTextureParams"
|
||||||
OpMemberName %ExternalTextureParams 0 "numPlanes"
|
OpMemberName %ExternalTextureParams 0 "numPlanes"
|
||||||
OpMemberName %ExternalTextureParams 1 "yuvToRgbConversionMatrix"
|
OpMemberName %ExternalTextureParams 1 "yuvToRgbConversionMatrix"
|
||||||
OpMemberName %ExternalTextureParams 2 "gammaDecodeParams"
|
|
||||||
OpName %GammaTransferParams "GammaTransferParams"
|
|
||||||
OpMemberName %GammaTransferParams 0 "G"
|
|
||||||
OpMemberName %GammaTransferParams 1 "A"
|
|
||||||
OpMemberName %GammaTransferParams 2 "B"
|
|
||||||
OpMemberName %GammaTransferParams 3 "C"
|
|
||||||
OpMemberName %GammaTransferParams 4 "D"
|
|
||||||
OpMemberName %GammaTransferParams 5 "E"
|
|
||||||
OpMemberName %GammaTransferParams 6 "F"
|
|
||||||
OpMemberName %GammaTransferParams 7 "padding"
|
|
||||||
OpMemberName %ExternalTextureParams 3 "gammaEncodeParams"
|
|
||||||
OpMemberName %ExternalTextureParams 4 "gamutConversionMatrix"
|
|
||||||
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 %gammaCorrection "gammaCorrection"
|
|
||||||
OpName %v "v"
|
|
||||||
OpName %params "params"
|
|
||||||
OpName %textureLoadExternal "textureLoadExternal"
|
OpName %textureLoadExternal "textureLoadExternal"
|
||||||
OpName %plane0 "plane0"
|
OpName %plane0 "plane0"
|
||||||
OpName %plane1 "plane1"
|
OpName %plane1 "plane1"
|
||||||
OpName %coord "coord"
|
OpName %coord "coord"
|
||||||
OpName %params_0 "params"
|
OpName %params "params"
|
||||||
OpName %color "color"
|
OpName %color "color"
|
||||||
OpName %textureLoad_8acf41 "textureLoad_8acf41"
|
OpName %textureLoad_8acf41 "textureLoad_8acf41"
|
||||||
OpName %res "res"
|
OpName %res "res"
|
||||||
|
@ -55,19 +39,6 @@
|
||||||
OpMemberDecorate %ExternalTextureParams 1 Offset 16
|
OpMemberDecorate %ExternalTextureParams 1 Offset 16
|
||||||
OpMemberDecorate %ExternalTextureParams 1 ColMajor
|
OpMemberDecorate %ExternalTextureParams 1 ColMajor
|
||||||
OpMemberDecorate %ExternalTextureParams 1 MatrixStride 16
|
OpMemberDecorate %ExternalTextureParams 1 MatrixStride 16
|
||||||
OpMemberDecorate %ExternalTextureParams 2 Offset 64
|
|
||||||
OpMemberDecorate %GammaTransferParams 0 Offset 0
|
|
||||||
OpMemberDecorate %GammaTransferParams 1 Offset 4
|
|
||||||
OpMemberDecorate %GammaTransferParams 2 Offset 8
|
|
||||||
OpMemberDecorate %GammaTransferParams 3 Offset 12
|
|
||||||
OpMemberDecorate %GammaTransferParams 4 Offset 16
|
|
||||||
OpMemberDecorate %GammaTransferParams 5 Offset 20
|
|
||||||
OpMemberDecorate %GammaTransferParams 6 Offset 24
|
|
||||||
OpMemberDecorate %GammaTransferParams 7 Offset 28
|
|
||||||
OpMemberDecorate %ExternalTextureParams 3 Offset 96
|
|
||||||
OpMemberDecorate %ExternalTextureParams 4 Offset 128
|
|
||||||
OpMemberDecorate %ExternalTextureParams 4 ColMajor
|
|
||||||
OpMemberDecorate %ExternalTextureParams 4 MatrixStride 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
|
||||||
|
@ -86,143 +57,91 @@
|
||||||
%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
|
||||||
%mat3v4float = OpTypeMatrix %v4float 3
|
%mat3v4float = OpTypeMatrix %v4float 3
|
||||||
%GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
|
%ExternalTextureParams = OpTypeStruct %uint %mat3v4float
|
||||||
%v3float = OpTypeVector %float 3
|
|
||||||
%mat3v3float = OpTypeMatrix %v3float 3
|
|
||||||
%ExternalTextureParams = OpTypeStruct %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
|
|
||||||
%_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
|
||||||
%21 = OpTypeFunction %v3float %v3float %GammaTransferParams
|
|
||||||
%bool = OpTypeBool
|
|
||||||
%v3bool = OpTypeVector %bool 3
|
|
||||||
%_ptr_Function_v3float = OpTypePointer Function %v3float
|
|
||||||
%41 = OpConstantNull %v3float
|
|
||||||
%int = OpTypeInt 32 1
|
%int = OpTypeInt 32 1
|
||||||
%v2int = OpTypeVector %int 2
|
%v2int = OpTypeVector %int 2
|
||||||
%61 = 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
|
||||||
%int_0 = OpConstant %int 0
|
%int_0 = OpConstant %int 0
|
||||||
%v2float = OpTypeVector %float 2
|
%v2float = OpTypeVector %float 2
|
||||||
%float_1 = OpConstant %float 1
|
%float_1 = OpConstant %float 1
|
||||||
%void = OpTypeVoid
|
%void = OpTypeVoid
|
||||||
%105 = OpTypeFunction %void
|
%57 = OpTypeFunction %void
|
||||||
%112 = OpConstantNull %v2int
|
%64 = OpConstantNull %v2int
|
||||||
%_ptr_Function_v4float = OpTypePointer Function %v4float
|
%_ptr_Function_v4float = OpTypePointer Function %v4float
|
||||||
%116 = OpTypeFunction %v4float
|
%68 = OpTypeFunction %v4float
|
||||||
%gammaCorrection = OpFunction %v3float None %21
|
%textureLoadExternal = OpFunction %v4float None %18
|
||||||
%v = OpFunctionParameter %v3float
|
|
||||||
%params = OpFunctionParameter %GammaTransferParams
|
|
||||||
%25 = OpLabel
|
|
||||||
%39 = OpVariable %_ptr_Function_v3float Function %41
|
|
||||||
%51 = OpVariable %_ptr_Function_v3float Function %41
|
|
||||||
%57 = OpVariable %_ptr_Function_v3float Function %41
|
|
||||||
%26 = OpExtInst %v3float %27 FAbs %v
|
|
||||||
%28 = OpCompositeExtract %float %params 4
|
|
||||||
%29 = OpCompositeConstruct %v3float %28 %28 %28
|
|
||||||
%30 = OpFOrdLessThan %v3bool %26 %29
|
|
||||||
%33 = OpExtInst %v3float %27 FSign %v
|
|
||||||
%34 = OpCompositeExtract %float %params 3
|
|
||||||
%35 = OpExtInst %v3float %27 FAbs %v
|
|
||||||
%36 = OpVectorTimesScalar %v3float %35 %34
|
|
||||||
%37 = OpCompositeExtract %float %params 6
|
|
||||||
%42 = OpCompositeConstruct %v3float %37 %37 %37
|
|
||||||
%38 = OpFAdd %v3float %36 %42
|
|
||||||
%43 = OpFMul %v3float %33 %38
|
|
||||||
%44 = OpExtInst %v3float %27 FSign %v
|
|
||||||
%46 = OpCompositeExtract %float %params 1
|
|
||||||
%47 = OpExtInst %v3float %27 FAbs %v
|
|
||||||
%48 = OpVectorTimesScalar %v3float %47 %46
|
|
||||||
%49 = OpCompositeExtract %float %params 2
|
|
||||||
%52 = OpCompositeConstruct %v3float %49 %49 %49
|
|
||||||
%50 = OpFAdd %v3float %48 %52
|
|
||||||
%53 = OpCompositeExtract %float %params 0
|
|
||||||
%54 = OpCompositeConstruct %v3float %53 %53 %53
|
|
||||||
%45 = OpExtInst %v3float %27 Pow %50 %54
|
|
||||||
%55 = OpCompositeExtract %float %params 5
|
|
||||||
%58 = OpCompositeConstruct %v3float %55 %55 %55
|
|
||||||
%56 = OpFAdd %v3float %45 %58
|
|
||||||
%59 = OpFMul %v3float %44 %56
|
|
||||||
%60 = OpSelect %v3float %30 %43 %59
|
|
||||||
OpReturnValue %60
|
|
||||||
OpFunctionEnd
|
|
||||||
%textureLoadExternal = OpFunction %v4float None %61
|
|
||||||
%plane0 = OpFunctionParameter %11
|
%plane0 = OpFunctionParameter %11
|
||||||
%plane1 = OpFunctionParameter %11
|
%plane1 = OpFunctionParameter %11
|
||||||
%coord = OpFunctionParameter %v2int
|
%coord = OpFunctionParameter %v2int
|
||||||
%params_0 = OpFunctionParameter %ExternalTextureParams
|
%params = OpFunctionParameter %ExternalTextureParams
|
||||||
%69 = OpLabel
|
%26 = OpLabel
|
||||||
%color = OpVariable %_ptr_Function_v3float Function %41
|
%color = OpVariable %_ptr_Function_v3float Function %30
|
||||||
%71 = OpCompositeExtract %uint %params_0 0
|
%31 = OpCompositeExtract %uint %params 0
|
||||||
%73 = OpIEqual %bool %71 %uint_1
|
%33 = OpIEqual %bool %31 %uint_1
|
||||||
OpSelectionMerge %74 None
|
OpSelectionMerge %35 None
|
||||||
OpBranchConditional %73 %75 %76
|
OpBranchConditional %33 %36 %37
|
||||||
%75 = OpLabel
|
%36 = OpLabel
|
||||||
%77 = OpImageFetch %v4float %plane0 %coord Lod %int_0
|
%38 = OpImageFetch %v4float %plane0 %coord Lod %int_0
|
||||||
%79 = OpVectorShuffle %v3float %77 %77 0 1 2
|
%40 = OpVectorShuffle %v3float %38 %38 0 1 2
|
||||||
OpStore %color %79
|
OpStore %color %40
|
||||||
OpBranch %74
|
OpBranch %35
|
||||||
%76 = OpLabel
|
%37 = OpLabel
|
||||||
%80 = OpImageFetch %v4float %plane0 %coord Lod %int_0
|
%41 = OpImageFetch %v4float %plane0 %coord Lod %int_0
|
||||||
%81 = OpCompositeExtract %float %80 0
|
%42 = OpCompositeExtract %float %41 0
|
||||||
%82 = OpImageFetch %v4float %plane1 %coord Lod %int_0
|
%43 = OpImageFetch %v4float %plane1 %coord Lod %int_0
|
||||||
%84 = OpVectorShuffle %v2float %82 %82 0 1
|
%45 = OpVectorShuffle %v2float %43 %43 0 1
|
||||||
%85 = OpCompositeExtract %float %84 0
|
%46 = OpCompositeExtract %float %45 0
|
||||||
%86 = OpCompositeExtract %float %84 1
|
%47 = OpCompositeExtract %float %45 1
|
||||||
%88 = OpCompositeConstruct %v4float %81 %85 %86 %float_1
|
%49 = OpCompositeConstruct %v4float %42 %46 %47 %float_1
|
||||||
%89 = OpCompositeExtract %mat3v4float %params_0 1
|
%50 = OpCompositeExtract %mat3v4float %params 1
|
||||||
%90 = OpVectorTimesMatrix %v3float %88 %89
|
%51 = OpVectorTimesMatrix %v3float %49 %50
|
||||||
OpStore %color %90
|
OpStore %color %51
|
||||||
OpBranch %74
|
OpBranch %35
|
||||||
%74 = OpLabel
|
%35 = OpLabel
|
||||||
%92 = OpLoad %v3float %color
|
%52 = OpLoad %v3float %color
|
||||||
%93 = OpCompositeExtract %GammaTransferParams %params_0 2
|
%53 = OpCompositeExtract %float %52 0
|
||||||
%91 = OpFunctionCall %v3float %gammaCorrection %92 %93
|
%54 = OpCompositeExtract %float %52 1
|
||||||
OpStore %color %91
|
%55 = OpCompositeExtract %float %52 2
|
||||||
%94 = OpCompositeExtract %mat3v3float %params_0 4
|
%56 = OpCompositeConstruct %v4float %53 %54 %55 %float_1
|
||||||
%95 = OpLoad %v3float %color
|
OpReturnValue %56
|
||||||
%96 = OpMatrixTimesVector %v3float %94 %95
|
|
||||||
OpStore %color %96
|
|
||||||
%98 = OpLoad %v3float %color
|
|
||||||
%99 = OpCompositeExtract %GammaTransferParams %params_0 3
|
|
||||||
%97 = OpFunctionCall %v3float %gammaCorrection %98 %99
|
|
||||||
OpStore %color %97
|
|
||||||
%100 = OpLoad %v3float %color
|
|
||||||
%101 = OpCompositeExtract %float %100 0
|
|
||||||
%102 = OpCompositeExtract %float %100 1
|
|
||||||
%103 = OpCompositeExtract %float %100 2
|
|
||||||
%104 = OpCompositeConstruct %v4float %101 %102 %103 %float_1
|
|
||||||
OpReturnValue %104
|
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%textureLoad_8acf41 = OpFunction %void None %105
|
%textureLoad_8acf41 = OpFunction %void None %57
|
||||||
%108 = OpLabel
|
%60 = OpLabel
|
||||||
%res = OpVariable %_ptr_Function_v4float Function %5
|
%res = OpVariable %_ptr_Function_v4float Function %5
|
||||||
%110 = OpLoad %11 %arg_0
|
%62 = OpLoad %11 %arg_0
|
||||||
%111 = OpLoad %11 %ext_tex_plane_1
|
%63 = OpLoad %11 %ext_tex_plane_1
|
||||||
%113 = OpLoad %ExternalTextureParams %ext_tex_params
|
%65 = OpLoad %ExternalTextureParams %ext_tex_params
|
||||||
%109 = OpFunctionCall %v4float %textureLoadExternal %110 %111 %112 %113
|
%61 = OpFunctionCall %v4float %textureLoadExternal %62 %63 %64 %65
|
||||||
OpStore %res %109
|
OpStore %res %61
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%vertex_main_inner = OpFunction %v4float None %116
|
%vertex_main_inner = OpFunction %v4float None %68
|
||||||
%118 = OpLabel
|
%70 = OpLabel
|
||||||
%119 = OpFunctionCall %void %textureLoad_8acf41
|
%71 = OpFunctionCall %void %textureLoad_8acf41
|
||||||
OpReturnValue %5
|
OpReturnValue %5
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%vertex_main = OpFunction %void None %105
|
%vertex_main = OpFunction %void None %57
|
||||||
%121 = OpLabel
|
%73 = OpLabel
|
||||||
%122 = OpFunctionCall %v4float %vertex_main_inner
|
%74 = OpFunctionCall %v4float %vertex_main_inner
|
||||||
OpStore %value %122
|
OpStore %value %74
|
||||||
OpStore %vertex_point_size %float_1
|
OpStore %vertex_point_size %float_1
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%fragment_main = OpFunction %void None %105
|
%fragment_main = OpFunction %void None %57
|
||||||
%124 = OpLabel
|
%76 = OpLabel
|
||||||
%125 = OpFunctionCall %void %textureLoad_8acf41
|
%77 = OpFunctionCall %void %textureLoad_8acf41
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%compute_main = OpFunction %void None %105
|
%compute_main = OpFunction %void None %57
|
||||||
%127 = OpLabel
|
%79 = OpLabel
|
||||||
%128 = OpFunctionCall %void %textureLoad_8acf41
|
%80 = OpFunctionCall %void %textureLoad_8acf41
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
|
|
|
@ -1,35 +1,15 @@
|
||||||
struct GammaTransferParams {
|
|
||||||
float G;
|
|
||||||
float A;
|
|
||||||
float B;
|
|
||||||
float C;
|
|
||||||
float D;
|
|
||||||
float E;
|
|
||||||
float F;
|
|
||||||
uint padding;
|
|
||||||
};
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
uint numPlanes;
|
uint numPlanes;
|
||||||
float3x4 yuvToRgbConversionMatrix;
|
float3x4 yuvToRgbConversionMatrix;
|
||||||
GammaTransferParams gammaDecodeParams;
|
|
||||||
GammaTransferParams gammaEncodeParams;
|
|
||||||
float3x3 gamutConversionMatrix;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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[11];
|
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);
|
||||||
|
|
||||||
float3 gammaCorrection(float3 v, GammaTransferParams params) {
|
|
||||||
const bool3 cond = (abs(v) < float3((params.D).xxx));
|
|
||||||
const float3 t = (sign(v) * ((params.C * abs(v)) + params.F));
|
|
||||||
const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E));
|
|
||||||
return (cond ? t : f);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
float3 color = float3(0.0f, 0.0f, 0.0f);
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
|
@ -37,43 +17,20 @@ float4 textureSampleExternal(Texture2D<float4> plane0, Texture2D<float4> plane1,
|
||||||
} else {
|
} else {
|
||||||
color = mul(params.yuvToRgbConversionMatrix, float4(plane0.SampleLevel(smp, coord, 0.0f).r, plane1.SampleLevel(smp, coord, 0.0f).rg, 1.0f));
|
color = mul(params.yuvToRgbConversionMatrix, float4(plane0.SampleLevel(smp, coord, 0.0f).r, plane1.SampleLevel(smp, coord, 0.0f).rg, 1.0f));
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = mul(color, params.gamutConversionMatrix);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return float4(color, 1.0f);
|
return float4(color, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
float3x4 tint_symbol_3(uint4 buffer[11], 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 + 16u)) / 4;
|
const uint scalar_offset_1 = ((offset + 16u)) / 4;
|
||||||
const uint scalar_offset_2 = ((offset + 32u)) / 4;
|
const uint scalar_offset_2 = ((offset + 32u)) / 4;
|
||||||
return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
|
return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
|
||||||
}
|
}
|
||||||
|
|
||||||
GammaTransferParams tint_symbol_5(uint4 buffer[11], uint offset) {
|
ExternalTextureParams tint_symbol_1(uint4 buffer[4], uint offset) {
|
||||||
const uint scalar_offset_3 = ((offset + 0u)) / 4;
|
const uint scalar_offset_3 = ((offset + 0u)) / 4;
|
||||||
const uint scalar_offset_4 = ((offset + 4u)) / 4;
|
const ExternalTextureParams tint_symbol_5 = {buffer[scalar_offset_3 / 4][scalar_offset_3 % 4], tint_symbol_3(buffer, (offset + 16u))};
|
||||||
const uint scalar_offset_5 = ((offset + 8u)) / 4;
|
return tint_symbol_5;
|
||||||
const uint scalar_offset_6 = ((offset + 12u)) / 4;
|
|
||||||
const uint scalar_offset_7 = ((offset + 16u)) / 4;
|
|
||||||
const uint scalar_offset_8 = ((offset + 20u)) / 4;
|
|
||||||
const uint scalar_offset_9 = ((offset + 24u)) / 4;
|
|
||||||
const uint scalar_offset_10 = ((offset + 28u)) / 4;
|
|
||||||
const GammaTransferParams tint_symbol_9 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]};
|
|
||||||
return tint_symbol_9;
|
|
||||||
}
|
|
||||||
|
|
||||||
float3x3 tint_symbol_7(uint4 buffer[11], uint offset) {
|
|
||||||
const uint scalar_offset_11 = ((offset + 0u)) / 4;
|
|
||||||
const uint scalar_offset_12 = ((offset + 16u)) / 4;
|
|
||||||
const uint scalar_offset_13 = ((offset + 32u)) / 4;
|
|
||||||
return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
|
|
||||||
}
|
|
||||||
|
|
||||||
ExternalTextureParams tint_symbol_1(uint4 buffer[11], uint offset) {
|
|
||||||
const uint scalar_offset_14 = ((offset + 0u)) / 4;
|
|
||||||
const ExternalTextureParams tint_symbol_10 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], tint_symbol_3(buffer, (offset + 16u)), tint_symbol_5(buffer, (offset + 64u)), tint_symbol_5(buffer, (offset + 96u)), tint_symbol_7(buffer, (offset + 128u))};
|
|
||||||
return tint_symbol_10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void textureSampleLevel_979816() {
|
void textureSampleLevel_979816() {
|
||||||
|
|
|
@ -1,33 +1,12 @@
|
||||||
#include <metal_stdlib>
|
#include <metal_stdlib>
|
||||||
|
|
||||||
using namespace metal;
|
using namespace metal;
|
||||||
struct GammaTransferParams {
|
|
||||||
/* 0x0000 */ float G;
|
|
||||||
/* 0x0004 */ float A;
|
|
||||||
/* 0x0008 */ float B;
|
|
||||||
/* 0x000c */ float C;
|
|
||||||
/* 0x0010 */ float D;
|
|
||||||
/* 0x0014 */ float E;
|
|
||||||
/* 0x0018 */ float F;
|
|
||||||
/* 0x001c */ uint padding;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
/* 0x0000 */ uint numPlanes;
|
/* 0x0000 */ uint numPlanes;
|
||||||
/* 0x0004 */ int8_t tint_pad[12];
|
/* 0x0004 */ int8_t tint_pad[12];
|
||||||
/* 0x0010 */ float3x4 yuvToRgbConversionMatrix;
|
/* 0x0010 */ float3x4 yuvToRgbConversionMatrix;
|
||||||
/* 0x0040 */ GammaTransferParams gammaDecodeParams;
|
|
||||||
/* 0x0060 */ GammaTransferParams gammaEncodeParams;
|
|
||||||
/* 0x0080 */ float3x3 gamutConversionMatrix;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
float3 gammaCorrection(float3 v, GammaTransferParams params) {
|
|
||||||
bool3 const cond = (fabs(v) < float3(params.D));
|
|
||||||
float3 const t = (sign(v) * ((params.C * fabs(v)) + params.F));
|
|
||||||
float3 const f = (sign(v) * (pow(((params.A * fabs(v)) + params.B), float3(params.G)) + params.E));
|
|
||||||
return select(f, t, cond);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
float3 color = 0.0f;
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
|
@ -35,9 +14,6 @@ float4 textureSampleExternal(texture2d<float, access::sample> plane0, texture2d<
|
||||||
} else {
|
} else {
|
||||||
color = (float4(plane0.sample(smp, coord, level(0.0f))[0], float4(plane1.sample(smp, coord, level(0.0f))).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
color = (float4(plane0.sample(smp, coord, level(0.0f))[0], float4(plane1.sample(smp, coord, level(0.0f))).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = (params.gamutConversionMatrix * color);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return float4(color, 1.0f);
|
return float4(color, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
; SPIR-V
|
; SPIR-V
|
||||||
; Version: 1.3
|
; Version: 1.3
|
||||||
; Generator: Google Tint Compiler; 0
|
; Generator: Google Tint Compiler; 0
|
||||||
; Bound: 136
|
; Bound: 88
|
||||||
; Schema: 0
|
; Schema: 0
|
||||||
OpCapability Shader
|
OpCapability Shader
|
||||||
%30 = OpExtInstImport "GLSL.std.450"
|
|
||||||
OpMemoryModel Logical GLSL450
|
OpMemoryModel Logical GLSL450
|
||||||
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
|
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
|
||||||
OpEntryPoint Fragment %fragment_main "fragment_main"
|
OpEntryPoint Fragment %fragment_main "fragment_main"
|
||||||
|
@ -17,30 +16,15 @@
|
||||||
OpName %ExternalTextureParams "ExternalTextureParams"
|
OpName %ExternalTextureParams "ExternalTextureParams"
|
||||||
OpMemberName %ExternalTextureParams 0 "numPlanes"
|
OpMemberName %ExternalTextureParams 0 "numPlanes"
|
||||||
OpMemberName %ExternalTextureParams 1 "yuvToRgbConversionMatrix"
|
OpMemberName %ExternalTextureParams 1 "yuvToRgbConversionMatrix"
|
||||||
OpMemberName %ExternalTextureParams 2 "gammaDecodeParams"
|
|
||||||
OpName %GammaTransferParams "GammaTransferParams"
|
|
||||||
OpMemberName %GammaTransferParams 0 "G"
|
|
||||||
OpMemberName %GammaTransferParams 1 "A"
|
|
||||||
OpMemberName %GammaTransferParams 2 "B"
|
|
||||||
OpMemberName %GammaTransferParams 3 "C"
|
|
||||||
OpMemberName %GammaTransferParams 4 "D"
|
|
||||||
OpMemberName %GammaTransferParams 5 "E"
|
|
||||||
OpMemberName %GammaTransferParams 6 "F"
|
|
||||||
OpMemberName %GammaTransferParams 7 "padding"
|
|
||||||
OpMemberName %ExternalTextureParams 3 "gammaEncodeParams"
|
|
||||||
OpMemberName %ExternalTextureParams 4 "gamutConversionMatrix"
|
|
||||||
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"
|
||||||
OpName %gammaCorrection "gammaCorrection"
|
|
||||||
OpName %v "v"
|
|
||||||
OpName %params "params"
|
|
||||||
OpName %textureSampleExternal "textureSampleExternal"
|
OpName %textureSampleExternal "textureSampleExternal"
|
||||||
OpName %plane0 "plane0"
|
OpName %plane0 "plane0"
|
||||||
OpName %plane1 "plane1"
|
OpName %plane1 "plane1"
|
||||||
OpName %smp "smp"
|
OpName %smp "smp"
|
||||||
OpName %coord "coord"
|
OpName %coord "coord"
|
||||||
OpName %params_0 "params"
|
OpName %params "params"
|
||||||
OpName %color "color"
|
OpName %color "color"
|
||||||
OpName %textureSampleLevel_979816 "textureSampleLevel_979816"
|
OpName %textureSampleLevel_979816 "textureSampleLevel_979816"
|
||||||
OpName %res "res"
|
OpName %res "res"
|
||||||
|
@ -57,19 +41,6 @@
|
||||||
OpMemberDecorate %ExternalTextureParams 1 Offset 16
|
OpMemberDecorate %ExternalTextureParams 1 Offset 16
|
||||||
OpMemberDecorate %ExternalTextureParams 1 ColMajor
|
OpMemberDecorate %ExternalTextureParams 1 ColMajor
|
||||||
OpMemberDecorate %ExternalTextureParams 1 MatrixStride 16
|
OpMemberDecorate %ExternalTextureParams 1 MatrixStride 16
|
||||||
OpMemberDecorate %ExternalTextureParams 2 Offset 64
|
|
||||||
OpMemberDecorate %GammaTransferParams 0 Offset 0
|
|
||||||
OpMemberDecorate %GammaTransferParams 1 Offset 4
|
|
||||||
OpMemberDecorate %GammaTransferParams 2 Offset 8
|
|
||||||
OpMemberDecorate %GammaTransferParams 3 Offset 12
|
|
||||||
OpMemberDecorate %GammaTransferParams 4 Offset 16
|
|
||||||
OpMemberDecorate %GammaTransferParams 5 Offset 20
|
|
||||||
OpMemberDecorate %GammaTransferParams 6 Offset 24
|
|
||||||
OpMemberDecorate %GammaTransferParams 7 Offset 28
|
|
||||||
OpMemberDecorate %ExternalTextureParams 3 Offset 96
|
|
||||||
OpMemberDecorate %ExternalTextureParams 4 Offset 128
|
|
||||||
OpMemberDecorate %ExternalTextureParams 4 ColMajor
|
|
||||||
OpMemberDecorate %ExternalTextureParams 4 MatrixStride 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
|
||||||
|
@ -90,150 +61,98 @@
|
||||||
%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
|
||||||
%mat3v4float = OpTypeMatrix %v4float 3
|
%mat3v4float = OpTypeMatrix %v4float 3
|
||||||
%GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
|
%ExternalTextureParams = OpTypeStruct %uint %mat3v4float
|
||||||
%v3float = OpTypeVector %float 3
|
|
||||||
%mat3v3float = OpTypeMatrix %v3float 3
|
|
||||||
%ExternalTextureParams = OpTypeStruct %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
|
|
||||||
%_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
|
||||||
%23 = OpTypeSampler
|
%20 = OpTypeSampler
|
||||||
%_ptr_UniformConstant_23 = OpTypePointer UniformConstant %23
|
%_ptr_UniformConstant_20 = OpTypePointer UniformConstant %20
|
||||||
%arg_1 = OpVariable %_ptr_UniformConstant_23 UniformConstant
|
%arg_1 = OpVariable %_ptr_UniformConstant_20 UniformConstant
|
||||||
%24 = OpTypeFunction %v3float %v3float %GammaTransferParams
|
|
||||||
%bool = OpTypeBool
|
|
||||||
%v3bool = OpTypeVector %bool 3
|
|
||||||
%_ptr_Function_v3float = OpTypePointer Function %v3float
|
|
||||||
%44 = OpConstantNull %v3float
|
|
||||||
%v2float = OpTypeVector %float 2
|
%v2float = OpTypeVector %float 2
|
||||||
%64 = OpTypeFunction %v4float %11 %11 %23 %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
|
||||||
%81 = OpTypeSampledImage %11
|
%bool = OpTypeBool
|
||||||
|
%42 = OpTypeSampledImage %11
|
||||||
%float_0 = OpConstant %float 0
|
%float_0 = OpConstant %float 0
|
||||||
%float_1 = OpConstant %float 1
|
%float_1 = OpConstant %float 1
|
||||||
%void = OpTypeVoid
|
%void = OpTypeVoid
|
||||||
%111 = OpTypeFunction %void
|
%63 = OpTypeFunction %void
|
||||||
%119 = OpConstantNull %v2float
|
%71 = OpConstantNull %v2float
|
||||||
%_ptr_Function_v4float = OpTypePointer Function %v4float
|
%_ptr_Function_v4float = OpTypePointer Function %v4float
|
||||||
%123 = OpTypeFunction %v4float
|
%75 = OpTypeFunction %v4float
|
||||||
%gammaCorrection = OpFunction %v3float None %24
|
%textureSampleExternal = OpFunction %v4float None %21
|
||||||
%v = OpFunctionParameter %v3float
|
|
||||||
%params = OpFunctionParameter %GammaTransferParams
|
|
||||||
%28 = OpLabel
|
|
||||||
%42 = OpVariable %_ptr_Function_v3float Function %44
|
|
||||||
%54 = OpVariable %_ptr_Function_v3float Function %44
|
|
||||||
%60 = OpVariable %_ptr_Function_v3float Function %44
|
|
||||||
%29 = OpExtInst %v3float %30 FAbs %v
|
|
||||||
%31 = OpCompositeExtract %float %params 4
|
|
||||||
%32 = OpCompositeConstruct %v3float %31 %31 %31
|
|
||||||
%33 = OpFOrdLessThan %v3bool %29 %32
|
|
||||||
%36 = OpExtInst %v3float %30 FSign %v
|
|
||||||
%37 = OpCompositeExtract %float %params 3
|
|
||||||
%38 = OpExtInst %v3float %30 FAbs %v
|
|
||||||
%39 = OpVectorTimesScalar %v3float %38 %37
|
|
||||||
%40 = OpCompositeExtract %float %params 6
|
|
||||||
%45 = OpCompositeConstruct %v3float %40 %40 %40
|
|
||||||
%41 = OpFAdd %v3float %39 %45
|
|
||||||
%46 = OpFMul %v3float %36 %41
|
|
||||||
%47 = OpExtInst %v3float %30 FSign %v
|
|
||||||
%49 = OpCompositeExtract %float %params 1
|
|
||||||
%50 = OpExtInst %v3float %30 FAbs %v
|
|
||||||
%51 = OpVectorTimesScalar %v3float %50 %49
|
|
||||||
%52 = OpCompositeExtract %float %params 2
|
|
||||||
%55 = OpCompositeConstruct %v3float %52 %52 %52
|
|
||||||
%53 = OpFAdd %v3float %51 %55
|
|
||||||
%56 = OpCompositeExtract %float %params 0
|
|
||||||
%57 = OpCompositeConstruct %v3float %56 %56 %56
|
|
||||||
%48 = OpExtInst %v3float %30 Pow %53 %57
|
|
||||||
%58 = OpCompositeExtract %float %params 5
|
|
||||||
%61 = OpCompositeConstruct %v3float %58 %58 %58
|
|
||||||
%59 = OpFAdd %v3float %48 %61
|
|
||||||
%62 = OpFMul %v3float %47 %59
|
|
||||||
%63 = OpSelect %v3float %33 %46 %62
|
|
||||||
OpReturnValue %63
|
|
||||||
OpFunctionEnd
|
|
||||||
%textureSampleExternal = OpFunction %v4float None %64
|
|
||||||
%plane0 = OpFunctionParameter %11
|
%plane0 = OpFunctionParameter %11
|
||||||
%plane1 = OpFunctionParameter %11
|
%plane1 = OpFunctionParameter %11
|
||||||
%smp = OpFunctionParameter %23
|
%smp = OpFunctionParameter %20
|
||||||
%coord = OpFunctionParameter %v2float
|
%coord = OpFunctionParameter %v2float
|
||||||
%params_0 = OpFunctionParameter %ExternalTextureParams
|
%params = OpFunctionParameter %ExternalTextureParams
|
||||||
%72 = OpLabel
|
%29 = OpLabel
|
||||||
%color = OpVariable %_ptr_Function_v3float Function %44
|
%color = OpVariable %_ptr_Function_v3float Function %33
|
||||||
%74 = OpCompositeExtract %uint %params_0 0
|
%34 = OpCompositeExtract %uint %params 0
|
||||||
%76 = OpIEqual %bool %74 %uint_1
|
%36 = OpIEqual %bool %34 %uint_1
|
||||||
OpSelectionMerge %77 None
|
OpSelectionMerge %38 None
|
||||||
OpBranchConditional %76 %78 %79
|
OpBranchConditional %36 %39 %40
|
||||||
%78 = OpLabel
|
%39 = OpLabel
|
||||||
%82 = OpSampledImage %81 %plane0 %smp
|
%43 = OpSampledImage %42 %plane0 %smp
|
||||||
%80 = OpImageSampleExplicitLod %v4float %82 %coord Lod %float_0
|
%41 = OpImageSampleExplicitLod %v4float %43 %coord Lod %float_0
|
||||||
%84 = OpVectorShuffle %v3float %80 %80 0 1 2
|
%45 = OpVectorShuffle %v3float %41 %41 0 1 2
|
||||||
OpStore %color %84
|
OpStore %color %45
|
||||||
OpBranch %77
|
OpBranch %38
|
||||||
%79 = OpLabel
|
%40 = OpLabel
|
||||||
%86 = OpSampledImage %81 %plane0 %smp
|
%47 = OpSampledImage %42 %plane0 %smp
|
||||||
%85 = OpImageSampleExplicitLod %v4float %86 %coord Lod %float_0
|
%46 = OpImageSampleExplicitLod %v4float %47 %coord Lod %float_0
|
||||||
%87 = OpCompositeExtract %float %85 0
|
%48 = OpCompositeExtract %float %46 0
|
||||||
%89 = OpSampledImage %81 %plane1 %smp
|
%50 = OpSampledImage %42 %plane1 %smp
|
||||||
%88 = OpImageSampleExplicitLod %v4float %89 %coord Lod %float_0
|
%49 = OpImageSampleExplicitLod %v4float %50 %coord Lod %float_0
|
||||||
%90 = OpVectorShuffle %v2float %88 %88 0 1
|
%51 = OpVectorShuffle %v2float %49 %49 0 1
|
||||||
%91 = OpCompositeExtract %float %90 0
|
%52 = OpCompositeExtract %float %51 0
|
||||||
%92 = OpCompositeExtract %float %90 1
|
%53 = OpCompositeExtract %float %51 1
|
||||||
%94 = OpCompositeConstruct %v4float %87 %91 %92 %float_1
|
%55 = OpCompositeConstruct %v4float %48 %52 %53 %float_1
|
||||||
%95 = OpCompositeExtract %mat3v4float %params_0 1
|
%56 = OpCompositeExtract %mat3v4float %params 1
|
||||||
%96 = OpVectorTimesMatrix %v3float %94 %95
|
%57 = OpVectorTimesMatrix %v3float %55 %56
|
||||||
OpStore %color %96
|
OpStore %color %57
|
||||||
OpBranch %77
|
OpBranch %38
|
||||||
%77 = OpLabel
|
%38 = OpLabel
|
||||||
%98 = OpLoad %v3float %color
|
%58 = OpLoad %v3float %color
|
||||||
%99 = OpCompositeExtract %GammaTransferParams %params_0 2
|
%59 = OpCompositeExtract %float %58 0
|
||||||
%97 = OpFunctionCall %v3float %gammaCorrection %98 %99
|
%60 = OpCompositeExtract %float %58 1
|
||||||
OpStore %color %97
|
%61 = OpCompositeExtract %float %58 2
|
||||||
%100 = OpCompositeExtract %mat3v3float %params_0 4
|
%62 = OpCompositeConstruct %v4float %59 %60 %61 %float_1
|
||||||
%101 = OpLoad %v3float %color
|
OpReturnValue %62
|
||||||
%102 = OpMatrixTimesVector %v3float %100 %101
|
|
||||||
OpStore %color %102
|
|
||||||
%104 = OpLoad %v3float %color
|
|
||||||
%105 = OpCompositeExtract %GammaTransferParams %params_0 3
|
|
||||||
%103 = OpFunctionCall %v3float %gammaCorrection %104 %105
|
|
||||||
OpStore %color %103
|
|
||||||
%106 = OpLoad %v3float %color
|
|
||||||
%107 = OpCompositeExtract %float %106 0
|
|
||||||
%108 = OpCompositeExtract %float %106 1
|
|
||||||
%109 = OpCompositeExtract %float %106 2
|
|
||||||
%110 = OpCompositeConstruct %v4float %107 %108 %109 %float_1
|
|
||||||
OpReturnValue %110
|
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%textureSampleLevel_979816 = OpFunction %void None %111
|
%textureSampleLevel_979816 = OpFunction %void None %63
|
||||||
%114 = OpLabel
|
%66 = OpLabel
|
||||||
%res = OpVariable %_ptr_Function_v4float Function %5
|
%res = OpVariable %_ptr_Function_v4float Function %5
|
||||||
%116 = OpLoad %11 %arg_0
|
%68 = OpLoad %11 %arg_0
|
||||||
%117 = OpLoad %11 %ext_tex_plane_1
|
%69 = OpLoad %11 %ext_tex_plane_1
|
||||||
%118 = OpLoad %23 %arg_1
|
%70 = OpLoad %20 %arg_1
|
||||||
%120 = OpLoad %ExternalTextureParams %ext_tex_params
|
%72 = OpLoad %ExternalTextureParams %ext_tex_params
|
||||||
%115 = OpFunctionCall %v4float %textureSampleExternal %116 %117 %118 %119 %120
|
%67 = OpFunctionCall %v4float %textureSampleExternal %68 %69 %70 %71 %72
|
||||||
OpStore %res %115
|
OpStore %res %67
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%vertex_main_inner = OpFunction %v4float None %123
|
%vertex_main_inner = OpFunction %v4float None %75
|
||||||
%125 = OpLabel
|
%77 = OpLabel
|
||||||
%126 = OpFunctionCall %void %textureSampleLevel_979816
|
%78 = OpFunctionCall %void %textureSampleLevel_979816
|
||||||
OpReturnValue %5
|
OpReturnValue %5
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%vertex_main = OpFunction %void None %111
|
%vertex_main = OpFunction %void None %63
|
||||||
%128 = OpLabel
|
%80 = OpLabel
|
||||||
%129 = OpFunctionCall %v4float %vertex_main_inner
|
%81 = OpFunctionCall %v4float %vertex_main_inner
|
||||||
OpStore %value %129
|
OpStore %value %81
|
||||||
OpStore %vertex_point_size %float_1
|
OpStore %vertex_point_size %float_1
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%fragment_main = OpFunction %void None %111
|
%fragment_main = OpFunction %void None %63
|
||||||
%131 = OpLabel
|
%83 = OpLabel
|
||||||
%132 = OpFunctionCall %void %textureSampleLevel_979816
|
%84 = OpFunctionCall %void %textureSampleLevel_979816
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%compute_main = OpFunction %void None %111
|
%compute_main = OpFunction %void None %63
|
||||||
%134 = OpLabel
|
%86 = OpLabel
|
||||||
%135 = OpFunctionCall %void %textureSampleLevel_979816
|
%87 = OpFunctionCall %void %textureSampleLevel_979816
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
|
|
|
@ -1,34 +1,14 @@
|
||||||
struct GammaTransferParams {
|
|
||||||
float G;
|
|
||||||
float A;
|
|
||||||
float B;
|
|
||||||
float C;
|
|
||||||
float D;
|
|
||||||
float E;
|
|
||||||
float F;
|
|
||||||
uint padding;
|
|
||||||
};
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
uint numPlanes;
|
uint numPlanes;
|
||||||
float3x4 yuvToRgbConversionMatrix;
|
float3x4 yuvToRgbConversionMatrix;
|
||||||
GammaTransferParams gammaDecodeParams;
|
|
||||||
GammaTransferParams gammaEncodeParams;
|
|
||||||
float3x3 gamutConversionMatrix;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
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[11];
|
uint4 ext_tex_params[4];
|
||||||
};
|
};
|
||||||
Texture2D<float4> arg_0 : register(t0, space1);
|
Texture2D<float4> arg_0 : register(t0, space1);
|
||||||
|
|
||||||
float3 gammaCorrection(float3 v, GammaTransferParams params) {
|
|
||||||
const bool3 cond = (abs(v) < float3((params.D).xxx));
|
|
||||||
const float3 t = (sign(v) * ((params.C * abs(v)) + params.F));
|
|
||||||
const float3 f = (sign(v) * (pow(((params.A * abs(v)) + params.B), float3((params.G).xxx)) + params.E));
|
|
||||||
return (cond ? t : f);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
float3 color = float3(0.0f, 0.0f, 0.0f);
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
|
@ -36,9 +16,6 @@ float4 textureLoadExternal(Texture2D<float4> plane0, Texture2D<float4> plane1, i
|
||||||
} else {
|
} else {
|
||||||
color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord, 0)).rg, 1.0f));
|
color = mul(params.yuvToRgbConversionMatrix, float4(plane0.Load(int3(coord, 0)).r, plane1.Load(int3(coord, 0)).rg, 1.0f));
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = mul(color, params.gamutConversionMatrix);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return float4(color, 1.0f);
|
return float4(color, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,37 +23,17 @@ float4 textureLoad2d(Texture2D<float4> tint_symbol, Texture2D<float4> ext_tex_pl
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
float3x4 tint_symbol_4(uint4 buffer[11], 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 + 16u)) / 4;
|
const uint scalar_offset_1 = ((offset + 16u)) / 4;
|
||||||
const uint scalar_offset_2 = ((offset + 32u)) / 4;
|
const uint scalar_offset_2 = ((offset + 32u)) / 4;
|
||||||
return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
|
return float3x4(asfloat(buffer[scalar_offset / 4]), asfloat(buffer[scalar_offset_1 / 4]), asfloat(buffer[scalar_offset_2 / 4]));
|
||||||
}
|
}
|
||||||
|
|
||||||
GammaTransferParams tint_symbol_6(uint4 buffer[11], uint offset) {
|
ExternalTextureParams tint_symbol_2(uint4 buffer[4], uint offset) {
|
||||||
const uint scalar_offset_3 = ((offset + 0u)) / 4;
|
const uint scalar_offset_3 = ((offset + 0u)) / 4;
|
||||||
const uint scalar_offset_4 = ((offset + 4u)) / 4;
|
const ExternalTextureParams tint_symbol_6 = {buffer[scalar_offset_3 / 4][scalar_offset_3 % 4], tint_symbol_4(buffer, (offset + 16u))};
|
||||||
const uint scalar_offset_5 = ((offset + 8u)) / 4;
|
return tint_symbol_6;
|
||||||
const uint scalar_offset_6 = ((offset + 12u)) / 4;
|
|
||||||
const uint scalar_offset_7 = ((offset + 16u)) / 4;
|
|
||||||
const uint scalar_offset_8 = ((offset + 20u)) / 4;
|
|
||||||
const uint scalar_offset_9 = ((offset + 24u)) / 4;
|
|
||||||
const uint scalar_offset_10 = ((offset + 28u)) / 4;
|
|
||||||
const GammaTransferParams tint_symbol_10 = {asfloat(buffer[scalar_offset_3 / 4][scalar_offset_3 % 4]), asfloat(buffer[scalar_offset_4 / 4][scalar_offset_4 % 4]), asfloat(buffer[scalar_offset_5 / 4][scalar_offset_5 % 4]), asfloat(buffer[scalar_offset_6 / 4][scalar_offset_6 % 4]), asfloat(buffer[scalar_offset_7 / 4][scalar_offset_7 % 4]), asfloat(buffer[scalar_offset_8 / 4][scalar_offset_8 % 4]), asfloat(buffer[scalar_offset_9 / 4][scalar_offset_9 % 4]), buffer[scalar_offset_10 / 4][scalar_offset_10 % 4]};
|
|
||||||
return tint_symbol_10;
|
|
||||||
}
|
|
||||||
|
|
||||||
float3x3 tint_symbol_8(uint4 buffer[11], uint offset) {
|
|
||||||
const uint scalar_offset_11 = ((offset + 0u)) / 4;
|
|
||||||
const uint scalar_offset_12 = ((offset + 16u)) / 4;
|
|
||||||
const uint scalar_offset_13 = ((offset + 32u)) / 4;
|
|
||||||
return float3x3(asfloat(buffer[scalar_offset_11 / 4].xyz), asfloat(buffer[scalar_offset_12 / 4].xyz), asfloat(buffer[scalar_offset_13 / 4].xyz));
|
|
||||||
}
|
|
||||||
|
|
||||||
ExternalTextureParams tint_symbol_2(uint4 buffer[11], uint offset) {
|
|
||||||
const uint scalar_offset_14 = ((offset + 0u)) / 4;
|
|
||||||
const ExternalTextureParams tint_symbol_11 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], tint_symbol_4(buffer, (offset + 16u)), tint_symbol_6(buffer, (offset + 64u)), tint_symbol_6(buffer, (offset + 96u)), tint_symbol_8(buffer, (offset + 128u))};
|
|
||||||
return tint_symbol_11;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void doTextureLoad() {
|
void doTextureLoad() {
|
||||||
|
|
|
@ -1,33 +1,12 @@
|
||||||
#include <metal_stdlib>
|
#include <metal_stdlib>
|
||||||
|
|
||||||
using namespace metal;
|
using namespace metal;
|
||||||
struct GammaTransferParams {
|
|
||||||
/* 0x0000 */ float G;
|
|
||||||
/* 0x0004 */ float A;
|
|
||||||
/* 0x0008 */ float B;
|
|
||||||
/* 0x000c */ float C;
|
|
||||||
/* 0x0010 */ float D;
|
|
||||||
/* 0x0014 */ float E;
|
|
||||||
/* 0x0018 */ float F;
|
|
||||||
/* 0x001c */ uint padding;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ExternalTextureParams {
|
struct ExternalTextureParams {
|
||||||
/* 0x0000 */ uint numPlanes;
|
/* 0x0000 */ uint numPlanes;
|
||||||
/* 0x0004 */ int8_t tint_pad[12];
|
/* 0x0004 */ int8_t tint_pad[12];
|
||||||
/* 0x0010 */ float3x4 yuvToRgbConversionMatrix;
|
/* 0x0010 */ float3x4 yuvToRgbConversionMatrix;
|
||||||
/* 0x0040 */ GammaTransferParams gammaDecodeParams;
|
|
||||||
/* 0x0060 */ GammaTransferParams gammaEncodeParams;
|
|
||||||
/* 0x0080 */ float3x3 gamutConversionMatrix;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
float3 gammaCorrection(float3 v, GammaTransferParams params) {
|
|
||||||
bool3 const cond = (fabs(v) < float3(params.D));
|
|
||||||
float3 const t = (sign(v) * ((params.C * fabs(v)) + params.F));
|
|
||||||
float3 const f = (sign(v) * (pow(((params.A * fabs(v)) + params.B), float3(params.G)) + params.E));
|
|
||||||
return select(f, t, cond);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
float3 color = 0.0f;
|
||||||
if ((params.numPlanes == 1u)) {
|
if ((params.numPlanes == 1u)) {
|
||||||
|
@ -35,9 +14,6 @@ float4 textureLoadExternal(texture2d<float, access::sample> plane0, texture2d<fl
|
||||||
} else {
|
} else {
|
||||||
color = (float4(plane0.read(uint2(coord), 0)[0], float4(plane1.read(uint2(coord), 0)).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
color = (float4(plane0.read(uint2(coord), 0)[0], float4(plane1.read(uint2(coord), 0)).rg, 1.0f) * params.yuvToRgbConversionMatrix);
|
||||||
}
|
}
|
||||||
color = gammaCorrection(color, params.gammaDecodeParams);
|
|
||||||
color = (params.gamutConversionMatrix * color);
|
|
||||||
color = gammaCorrection(color, params.gammaEncodeParams);
|
|
||||||
return float4(color, 1.0f);
|
return float4(color, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
; SPIR-V
|
; SPIR-V
|
||||||
; Version: 1.3
|
; Version: 1.3
|
||||||
; Generator: Google Tint Compiler; 0
|
; Generator: Google Tint Compiler; 0
|
||||||
; Bound: 137
|
; Bound: 89
|
||||||
; Schema: 0
|
; Schema: 0
|
||||||
OpCapability Shader
|
OpCapability Shader
|
||||||
%27 = OpExtInstImport "GLSL.std.450"
|
|
||||||
OpMemoryModel Logical GLSL450
|
OpMemoryModel Logical GLSL450
|
||||||
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
|
OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
|
||||||
OpEntryPoint Fragment %fragment_main "fragment_main"
|
OpEntryPoint Fragment %fragment_main "fragment_main"
|
||||||
|
@ -17,28 +16,13 @@
|
||||||
OpName %ExternalTextureParams "ExternalTextureParams"
|
OpName %ExternalTextureParams "ExternalTextureParams"
|
||||||
OpMemberName %ExternalTextureParams 0 "numPlanes"
|
OpMemberName %ExternalTextureParams 0 "numPlanes"
|
||||||
OpMemberName %ExternalTextureParams 1 "yuvToRgbConversionMatrix"
|
OpMemberName %ExternalTextureParams 1 "yuvToRgbConversionMatrix"
|
||||||
OpMemberName %ExternalTextureParams 2 "gammaDecodeParams"
|
|
||||||
OpName %GammaTransferParams "GammaTransferParams"
|
|
||||||
OpMemberName %GammaTransferParams 0 "G"
|
|
||||||
OpMemberName %GammaTransferParams 1 "A"
|
|
||||||
OpMemberName %GammaTransferParams 2 "B"
|
|
||||||
OpMemberName %GammaTransferParams 3 "C"
|
|
||||||
OpMemberName %GammaTransferParams 4 "D"
|
|
||||||
OpMemberName %GammaTransferParams 5 "E"
|
|
||||||
OpMemberName %GammaTransferParams 6 "F"
|
|
||||||
OpMemberName %GammaTransferParams 7 "padding"
|
|
||||||
OpMemberName %ExternalTextureParams 3 "gammaEncodeParams"
|
|
||||||
OpMemberName %ExternalTextureParams 4 "gamutConversionMatrix"
|
|
||||||
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 %gammaCorrection "gammaCorrection"
|
|
||||||
OpName %v "v"
|
|
||||||
OpName %params "params"
|
|
||||||
OpName %textureLoadExternal "textureLoadExternal"
|
OpName %textureLoadExternal "textureLoadExternal"
|
||||||
OpName %plane0 "plane0"
|
OpName %plane0 "plane0"
|
||||||
OpName %plane1 "plane1"
|
OpName %plane1 "plane1"
|
||||||
OpName %coord "coord"
|
OpName %coord "coord"
|
||||||
OpName %params_0 "params"
|
OpName %params "params"
|
||||||
OpName %color "color"
|
OpName %color "color"
|
||||||
OpName %textureLoad2d "textureLoad2d"
|
OpName %textureLoad2d "textureLoad2d"
|
||||||
OpName %texture "texture"
|
OpName %texture "texture"
|
||||||
|
@ -60,19 +44,6 @@
|
||||||
OpMemberDecorate %ExternalTextureParams 1 Offset 16
|
OpMemberDecorate %ExternalTextureParams 1 Offset 16
|
||||||
OpMemberDecorate %ExternalTextureParams 1 ColMajor
|
OpMemberDecorate %ExternalTextureParams 1 ColMajor
|
||||||
OpMemberDecorate %ExternalTextureParams 1 MatrixStride 16
|
OpMemberDecorate %ExternalTextureParams 1 MatrixStride 16
|
||||||
OpMemberDecorate %ExternalTextureParams 2 Offset 64
|
|
||||||
OpMemberDecorate %GammaTransferParams 0 Offset 0
|
|
||||||
OpMemberDecorate %GammaTransferParams 1 Offset 4
|
|
||||||
OpMemberDecorate %GammaTransferParams 2 Offset 8
|
|
||||||
OpMemberDecorate %GammaTransferParams 3 Offset 12
|
|
||||||
OpMemberDecorate %GammaTransferParams 4 Offset 16
|
|
||||||
OpMemberDecorate %GammaTransferParams 5 Offset 20
|
|
||||||
OpMemberDecorate %GammaTransferParams 6 Offset 24
|
|
||||||
OpMemberDecorate %GammaTransferParams 7 Offset 28
|
|
||||||
OpMemberDecorate %ExternalTextureParams 3 Offset 96
|
|
||||||
OpMemberDecorate %ExternalTextureParams 4 Offset 128
|
|
||||||
OpMemberDecorate %ExternalTextureParams 4 ColMajor
|
|
||||||
OpMemberDecorate %ExternalTextureParams 4 MatrixStride 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
|
||||||
|
@ -91,153 +62,101 @@
|
||||||
%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
|
||||||
%mat3v4float = OpTypeMatrix %v4float 3
|
%mat3v4float = OpTypeMatrix %v4float 3
|
||||||
%GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
|
%ExternalTextureParams = OpTypeStruct %uint %mat3v4float
|
||||||
%v3float = OpTypeVector %float 3
|
|
||||||
%mat3v3float = OpTypeMatrix %v3float 3
|
|
||||||
%ExternalTextureParams = OpTypeStruct %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
|
|
||||||
%_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
|
||||||
%21 = OpTypeFunction %v3float %v3float %GammaTransferParams
|
|
||||||
%bool = OpTypeBool
|
|
||||||
%v3bool = OpTypeVector %bool 3
|
|
||||||
%_ptr_Function_v3float = OpTypePointer Function %v3float
|
|
||||||
%41 = OpConstantNull %v3float
|
|
||||||
%int = OpTypeInt 32 1
|
%int = OpTypeInt 32 1
|
||||||
%v2int = OpTypeVector %int 2
|
%v2int = OpTypeVector %int 2
|
||||||
%61 = 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
|
||||||
%int_0 = OpConstant %int 0
|
%int_0 = OpConstant %int 0
|
||||||
%v2float = OpTypeVector %float 2
|
%v2float = OpTypeVector %float 2
|
||||||
%float_1 = OpConstant %float 1
|
%float_1 = OpConstant %float 1
|
||||||
%105 = OpTypeFunction %v4float %11 %11 %ExternalTextureParams %v2int
|
%57 = OpTypeFunction %v4float %11 %11 %ExternalTextureParams %v2int
|
||||||
%void = OpTypeVoid
|
%void = OpTypeVoid
|
||||||
%113 = OpTypeFunction %void
|
%65 = OpTypeFunction %void
|
||||||
%121 = OpConstantNull %v2int
|
%73 = OpConstantNull %v2int
|
||||||
%_ptr_Function_v4float = OpTypePointer Function %v4float
|
%_ptr_Function_v4float = OpTypePointer Function %v4float
|
||||||
%124 = OpTypeFunction %v4float
|
%76 = OpTypeFunction %v4float
|
||||||
%gammaCorrection = OpFunction %v3float None %21
|
%textureLoadExternal = OpFunction %v4float None %18
|
||||||
%v = OpFunctionParameter %v3float
|
|
||||||
%params = OpFunctionParameter %GammaTransferParams
|
|
||||||
%25 = OpLabel
|
|
||||||
%39 = OpVariable %_ptr_Function_v3float Function %41
|
|
||||||
%51 = OpVariable %_ptr_Function_v3float Function %41
|
|
||||||
%57 = OpVariable %_ptr_Function_v3float Function %41
|
|
||||||
%26 = OpExtInst %v3float %27 FAbs %v
|
|
||||||
%28 = OpCompositeExtract %float %params 4
|
|
||||||
%29 = OpCompositeConstruct %v3float %28 %28 %28
|
|
||||||
%30 = OpFOrdLessThan %v3bool %26 %29
|
|
||||||
%33 = OpExtInst %v3float %27 FSign %v
|
|
||||||
%34 = OpCompositeExtract %float %params 3
|
|
||||||
%35 = OpExtInst %v3float %27 FAbs %v
|
|
||||||
%36 = OpVectorTimesScalar %v3float %35 %34
|
|
||||||
%37 = OpCompositeExtract %float %params 6
|
|
||||||
%42 = OpCompositeConstruct %v3float %37 %37 %37
|
|
||||||
%38 = OpFAdd %v3float %36 %42
|
|
||||||
%43 = OpFMul %v3float %33 %38
|
|
||||||
%44 = OpExtInst %v3float %27 FSign %v
|
|
||||||
%46 = OpCompositeExtract %float %params 1
|
|
||||||
%47 = OpExtInst %v3float %27 FAbs %v
|
|
||||||
%48 = OpVectorTimesScalar %v3float %47 %46
|
|
||||||
%49 = OpCompositeExtract %float %params 2
|
|
||||||
%52 = OpCompositeConstruct %v3float %49 %49 %49
|
|
||||||
%50 = OpFAdd %v3float %48 %52
|
|
||||||
%53 = OpCompositeExtract %float %params 0
|
|
||||||
%54 = OpCompositeConstruct %v3float %53 %53 %53
|
|
||||||
%45 = OpExtInst %v3float %27 Pow %50 %54
|
|
||||||
%55 = OpCompositeExtract %float %params 5
|
|
||||||
%58 = OpCompositeConstruct %v3float %55 %55 %55
|
|
||||||
%56 = OpFAdd %v3float %45 %58
|
|
||||||
%59 = OpFMul %v3float %44 %56
|
|
||||||
%60 = OpSelect %v3float %30 %43 %59
|
|
||||||
OpReturnValue %60
|
|
||||||
OpFunctionEnd
|
|
||||||
%textureLoadExternal = OpFunction %v4float None %61
|
|
||||||
%plane0 = OpFunctionParameter %11
|
%plane0 = OpFunctionParameter %11
|
||||||
%plane1 = OpFunctionParameter %11
|
%plane1 = OpFunctionParameter %11
|
||||||
%coord = OpFunctionParameter %v2int
|
%coord = OpFunctionParameter %v2int
|
||||||
%params_0 = OpFunctionParameter %ExternalTextureParams
|
%params = OpFunctionParameter %ExternalTextureParams
|
||||||
%69 = OpLabel
|
%26 = OpLabel
|
||||||
%color = OpVariable %_ptr_Function_v3float Function %41
|
%color = OpVariable %_ptr_Function_v3float Function %30
|
||||||
%71 = OpCompositeExtract %uint %params_0 0
|
%31 = OpCompositeExtract %uint %params 0
|
||||||
%73 = OpIEqual %bool %71 %uint_1
|
%33 = OpIEqual %bool %31 %uint_1
|
||||||
OpSelectionMerge %74 None
|
OpSelectionMerge %35 None
|
||||||
OpBranchConditional %73 %75 %76
|
OpBranchConditional %33 %36 %37
|
||||||
%75 = OpLabel
|
%36 = OpLabel
|
||||||
%77 = OpImageFetch %v4float %plane0 %coord Lod %int_0
|
%38 = OpImageFetch %v4float %plane0 %coord Lod %int_0
|
||||||
%79 = OpVectorShuffle %v3float %77 %77 0 1 2
|
%40 = OpVectorShuffle %v3float %38 %38 0 1 2
|
||||||
OpStore %color %79
|
OpStore %color %40
|
||||||
OpBranch %74
|
OpBranch %35
|
||||||
%76 = OpLabel
|
%37 = OpLabel
|
||||||
%80 = OpImageFetch %v4float %plane0 %coord Lod %int_0
|
%41 = OpImageFetch %v4float %plane0 %coord Lod %int_0
|
||||||
%81 = OpCompositeExtract %float %80 0
|
%42 = OpCompositeExtract %float %41 0
|
||||||
%82 = OpImageFetch %v4float %plane1 %coord Lod %int_0
|
%43 = OpImageFetch %v4float %plane1 %coord Lod %int_0
|
||||||
%84 = OpVectorShuffle %v2float %82 %82 0 1
|
%45 = OpVectorShuffle %v2float %43 %43 0 1
|
||||||
%85 = OpCompositeExtract %float %84 0
|
%46 = OpCompositeExtract %float %45 0
|
||||||
%86 = OpCompositeExtract %float %84 1
|
%47 = OpCompositeExtract %float %45 1
|
||||||
%88 = OpCompositeConstruct %v4float %81 %85 %86 %float_1
|
%49 = OpCompositeConstruct %v4float %42 %46 %47 %float_1
|
||||||
%89 = OpCompositeExtract %mat3v4float %params_0 1
|
%50 = OpCompositeExtract %mat3v4float %params 1
|
||||||
%90 = OpVectorTimesMatrix %v3float %88 %89
|
%51 = OpVectorTimesMatrix %v3float %49 %50
|
||||||
OpStore %color %90
|
OpStore %color %51
|
||||||
OpBranch %74
|
OpBranch %35
|
||||||
%74 = OpLabel
|
%35 = OpLabel
|
||||||
%92 = OpLoad %v3float %color
|
%52 = OpLoad %v3float %color
|
||||||
%93 = OpCompositeExtract %GammaTransferParams %params_0 2
|
%53 = OpCompositeExtract %float %52 0
|
||||||
%91 = OpFunctionCall %v3float %gammaCorrection %92 %93
|
%54 = OpCompositeExtract %float %52 1
|
||||||
OpStore %color %91
|
%55 = OpCompositeExtract %float %52 2
|
||||||
%94 = OpCompositeExtract %mat3v3float %params_0 4
|
%56 = OpCompositeConstruct %v4float %53 %54 %55 %float_1
|
||||||
%95 = OpLoad %v3float %color
|
OpReturnValue %56
|
||||||
%96 = OpMatrixTimesVector %v3float %94 %95
|
|
||||||
OpStore %color %96
|
|
||||||
%98 = OpLoad %v3float %color
|
|
||||||
%99 = OpCompositeExtract %GammaTransferParams %params_0 3
|
|
||||||
%97 = OpFunctionCall %v3float %gammaCorrection %98 %99
|
|
||||||
OpStore %color %97
|
|
||||||
%100 = OpLoad %v3float %color
|
|
||||||
%101 = OpCompositeExtract %float %100 0
|
|
||||||
%102 = OpCompositeExtract %float %100 1
|
|
||||||
%103 = OpCompositeExtract %float %100 2
|
|
||||||
%104 = OpCompositeConstruct %v4float %101 %102 %103 %float_1
|
|
||||||
OpReturnValue %104
|
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%textureLoad2d = OpFunction %v4float None %105
|
%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
|
||||||
%111 = OpLabel
|
%63 = OpLabel
|
||||||
%112 = 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 %112
|
OpReturnValue %64
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%doTextureLoad = OpFunction %void None %113
|
%doTextureLoad = OpFunction %void None %65
|
||||||
%116 = OpLabel
|
%68 = OpLabel
|
||||||
%res = OpVariable %_ptr_Function_v4float Function %5
|
%res = OpVariable %_ptr_Function_v4float Function %5
|
||||||
%118 = OpLoad %11 %arg_0
|
%70 = OpLoad %11 %arg_0
|
||||||
%119 = OpLoad %11 %ext_tex_plane_1
|
%71 = OpLoad %11 %ext_tex_plane_1
|
||||||
%120 = OpLoad %ExternalTextureParams %ext_tex_params
|
%72 = OpLoad %ExternalTextureParams %ext_tex_params
|
||||||
%117 = OpFunctionCall %v4float %textureLoad2d %118 %119 %120 %121
|
%69 = OpFunctionCall %v4float %textureLoad2d %70 %71 %72 %73
|
||||||
OpStore %res %117
|
OpStore %res %69
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%vertex_main_inner = OpFunction %v4float None %124
|
%vertex_main_inner = OpFunction %v4float None %76
|
||||||
%126 = OpLabel
|
%78 = OpLabel
|
||||||
%127 = OpFunctionCall %void %doTextureLoad
|
%79 = OpFunctionCall %void %doTextureLoad
|
||||||
OpReturnValue %5
|
OpReturnValue %5
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%vertex_main = OpFunction %void None %113
|
%vertex_main = OpFunction %void None %65
|
||||||
%129 = OpLabel
|
%81 = OpLabel
|
||||||
%130 = OpFunctionCall %v4float %vertex_main_inner
|
%82 = OpFunctionCall %v4float %vertex_main_inner
|
||||||
OpStore %value %130
|
OpStore %value %82
|
||||||
OpStore %vertex_point_size %float_1
|
OpStore %vertex_point_size %float_1
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%fragment_main = OpFunction %void None %113
|
%fragment_main = OpFunction %void None %65
|
||||||
%132 = OpLabel
|
%84 = OpLabel
|
||||||
%133 = OpFunctionCall %void %doTextureLoad
|
%85 = OpFunctionCall %void %doTextureLoad
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
%compute_main = OpFunction %void None %113
|
%compute_main = OpFunction %void None %65
|
||||||
%135 = OpLabel
|
%87 = OpLabel
|
||||||
%136 = OpFunctionCall %void %doTextureLoad
|
%88 = OpFunctionCall %void %doTextureLoad
|
||||||
OpReturn
|
OpReturn
|
||||||
OpFunctionEnd
|
OpFunctionEnd
|
||||||
|
|
Loading…
Reference in New Issue