Skip Gamma and Gamut conversions for BT.709->SRGB
This introduces a new field 'doYuvToRgbConversionOnly' in
ExternalTextureParams to have the WGSL only do yuv->rgb conversion for
better performance. User studies shows that users don't really care
about the Gamma difference between 2.4 and 2.2.
https://source.chromium.org/chromium/chromium/src/+/main:ui/gfx/color_space.cc;l=1022;drc=a1dbb594a6741a400db35fe3678e77bad2504ea4
Bug: dawn:1082
Bug: dawn:1466
Change-Id: I61c0fe65c5969d8a61c267c202c8dd64c259ed8a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92901
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
diff --git a/dawn.json b/dawn.json
index 0c51df3..f6cac03 100644
--- a/dawn.json
+++ b/dawn.json
@@ -1330,6 +1330,7 @@
{"name": "label", "type": "char", "annotation": "const*", "length": "strlen", "optional": true},
{"name": "plane 0", "type": "texture view"},
{"name": "plane 1", "type": "texture view", "optional": true},
+ {"name": "do yuv to rgb conversion only", "type": "bool", "default": "false"},
{"name": "yuv to rgb conversion matrix", "type": "float", "annotation": "const*",
"length": 12, "optional": true},
{"name": "src transfer function parameters", "type": "float", "annotation": "const*",
diff --git a/src/dawn/native/ExternalTexture.cpp b/src/dawn/native/ExternalTexture.cpp
index 0dfa963..978fb9e 100644
--- a/src/dawn/native/ExternalTexture.cpp
+++ b/src/dawn/native/ExternalTexture.cpp
@@ -152,6 +152,8 @@
ExternalTextureParams params;
params.numPlanes = descriptor->plane1 == nullptr ? 1 : 2;
+ params.doYuvToRgbConversionOnly = descriptor->doYuvToRgbConversionOnly ? 1 : 0;
+
// YUV-to-RGB conversion is performed by multiplying the source YUV values with a 4x3 matrix
// passed from Chromium. The matrix was originally sourced from /skia/src/core/SkYUVMath.cpp.
// This matrix is only used in multiplanar scenarios.
diff --git a/src/dawn/native/ExternalTexture.h b/src/dawn/native/ExternalTexture.h
index 50f3b89..509a7ee 100644
--- a/src/dawn/native/ExternalTexture.h
+++ b/src/dawn/native/ExternalTexture.h
@@ -28,7 +28,9 @@
struct ExternalTextureParams {
uint32_t numPlanes;
- std::array<uint32_t, 3> padding;
+ // TODO(crbug.com/dawn/1466): Only go as few steps as necessary.
+ uint32_t doYuvToRgbConversionOnly;
+ std::array<uint32_t, 2> padding;
std::array<float, 12> yuvToRgbConversionMatrix;
std::array<float, 8> gammaDecodingParams = {};
std::array<float, 8> gammaEncodingParams = {};
diff --git a/src/tint/transform/multiplanar_external_texture.cc b/src/tint/transform/multiplanar_external_texture.cc
index 8b85573..cf5a5a6 100644
--- a/src/tint/transform/multiplanar_external_texture.cc
+++ b/src/tint/transform/multiplanar_external_texture.cc
@@ -251,6 +251,7 @@
// Create ExternalTextureParams struct.
ast::StructMemberList ext_tex_params_member_list = {
b.Member("numPlanes", b.ty.u32()),
+ b.Member("doYuvToRgbConversionOnly", b.ty.u32()),
b.Member("yuvToRgbConversionMatrix", b.ty.mat3x4(b.ty.f32())),
b.Member("gammaDecodeParams", b.ty.type_name("GammaTransferParams")),
b.Member("gammaEncodeParams", b.ty.type_name("GammaTransferParams")),
@@ -340,14 +341,20 @@
b.Mul(b.vec4<f32>(b.MemberAccessor(plane_0_call, "r"),
b.MemberAccessor(plane_1_call, "rg"), 1_f),
b.MemberAccessor("params", "yuvToRgbConversionMatrix")))))),
- // color = gammaConversion(color, gammaDecodeParams);
- b.Assign("color", b.Call("gammaCorrection", "color",
- b.MemberAccessor("params", "gammaDecodeParams"))),
- // color = (params.gamutConversionMatrix * color);
- b.Assign("color", b.Mul(b.MemberAccessor("params", "gamutConversionMatrix"), "color")),
- // color = gammaConversion(color, gammaEncodeParams);
- b.Assign("color", b.Call("gammaCorrection", "color",
- b.MemberAccessor("params", "gammaEncodeParams"))),
+ // if (params.doYuvToRgbConversionOnly == 0u)
+ b.If(b.create<ast::BinaryExpression>(
+ ast::BinaryOp::kEqual, b.MemberAccessor("params", "doYuvToRgbConversionOnly"),
+ b.Expr(0_u)),
+ b.Block(
+ // 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.f);
b.Return(b.vec4<f32>("color", 1_f))};
}
diff --git a/src/tint/transform/multiplanar_external_texture.h b/src/tint/transform/multiplanar_external_texture.h
index 88cbc981..fcb5156 100644
--- a/src/tint/transform/multiplanar_external_texture.h
+++ b/src/tint/transform/multiplanar_external_texture.h
@@ -46,7 +46,10 @@
/// textureSampleLevel that contain a texture_external parameter will be
/// transformed into a newly generated version of the function, which can
/// perform the desired operation on a single RGBA plane or on seperate Y and UV
-/// planes.
+/// planes, and do colorspace conversions including yuv->rgb conversion, gamma
+/// decoding, gamut conversion, and gamma encoding steps. Specifically
+// for BT.709 to SRGB conversion, it takes the fast path only doing the yuv->rgb
+// step and skipping all other steps.
class MultiplanarExternalTexture : public Castable<MultiplanarExternalTexture, Transform> {
public:
/// BindingsMap is a map where the key is the binding location of a
diff --git a/src/tint/transform/multiplanar_external_texture_test.cc b/src/tint/transform/multiplanar_external_texture_test.cc
index 63d12f1..79f9fdd 100644
--- a/src/tint/transform/multiplanar_external_texture_test.cc
+++ b/src/tint/transform/multiplanar_external_texture_test.cc
@@ -118,6 +118,7 @@
struct ExternalTextureParams {
numPlanes : u32,
+ doYuvToRgbConversionOnly : u32,
yuvToRgbConversionMatrix : mat3x4<f32>,
gammaDecodeParams : GammaTransferParams,
gammaEncodeParams : GammaTransferParams,
@@ -172,6 +173,7 @@
struct ExternalTextureParams {
numPlanes : u32,
+ doYuvToRgbConversionOnly : u32,
yuvToRgbConversionMatrix : mat3x4<f32>,
gammaDecodeParams : GammaTransferParams,
gammaEncodeParams : GammaTransferParams,
@@ -225,6 +227,7 @@
struct ExternalTextureParams {
numPlanes : u32,
+ doYuvToRgbConversionOnly : u32,
yuvToRgbConversionMatrix : mat3x4<f32>,
gammaDecodeParams : GammaTransferParams,
gammaEncodeParams : GammaTransferParams,
@@ -253,9 +256,11 @@
} else {
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0f).r, textureSampleLevel(plane1, smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
}
- color = gammaCorrection(color, params.gammaDecodeParams);
- color = (params.gamutConversionMatrix * color);
- color = gammaCorrection(color, params.gammaEncodeParams);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return vec4<f32>(color, 1.0f);
}
@@ -298,6 +303,7 @@
struct ExternalTextureParams {
numPlanes : u32,
+ doYuvToRgbConversionOnly : u32,
yuvToRgbConversionMatrix : mat3x4<f32>,
gammaDecodeParams : GammaTransferParams,
gammaEncodeParams : GammaTransferParams,
@@ -322,9 +328,11 @@
} else {
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0f).r, textureSampleLevel(plane1, smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
}
- color = gammaCorrection(color, params.gammaDecodeParams);
- color = (params.gamutConversionMatrix * color);
- color = gammaCorrection(color, params.gammaEncodeParams);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return vec4<f32>(color, 1.0f);
}
@@ -370,6 +378,7 @@
struct ExternalTextureParams {
numPlanes : u32,
+ doYuvToRgbConversionOnly : u32,
yuvToRgbConversionMatrix : mat3x4<f32>,
gammaDecodeParams : GammaTransferParams,
gammaEncodeParams : GammaTransferParams,
@@ -396,9 +405,11 @@
} else {
color = (vec4<f32>(textureLoad(plane0, coord, 0i).r, textureLoad(plane1, coord, 0i).rg, 1.0f) * params.yuvToRgbConversionMatrix);
}
- color = gammaCorrection(color, params.gammaDecodeParams);
- color = (params.gamutConversionMatrix * color);
- color = gammaCorrection(color, params.gammaEncodeParams);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return vec4<f32>(color, 1.0f);
}
@@ -440,6 +451,7 @@
struct ExternalTextureParams {
numPlanes : u32,
+ doYuvToRgbConversionOnly : u32,
yuvToRgbConversionMatrix : mat3x4<f32>,
gammaDecodeParams : GammaTransferParams,
gammaEncodeParams : GammaTransferParams,
@@ -464,9 +476,11 @@
} else {
color = (vec4<f32>(textureLoad(plane0, coord, 0i).r, textureLoad(plane1, coord, 0i).rg, 1.0f) * params.yuvToRgbConversionMatrix);
}
- color = gammaCorrection(color, params.gammaDecodeParams);
- color = (params.gamutConversionMatrix * color);
- color = gammaCorrection(color, params.gammaEncodeParams);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return vec4<f32>(color, 1.0f);
}
@@ -512,6 +526,7 @@
struct ExternalTextureParams {
numPlanes : u32,
+ doYuvToRgbConversionOnly : u32,
yuvToRgbConversionMatrix : mat3x4<f32>,
gammaDecodeParams : GammaTransferParams,
gammaEncodeParams : GammaTransferParams,
@@ -540,9 +555,11 @@
} else {
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0f).r, textureSampleLevel(plane1, smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
}
- color = gammaCorrection(color, params.gammaDecodeParams);
- color = (params.gamutConversionMatrix * color);
- color = gammaCorrection(color, params.gammaEncodeParams);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return vec4<f32>(color, 1.0f);
}
@@ -553,9 +570,11 @@
} else {
color = (vec4<f32>(textureLoad(plane0, coord, 0i).r, textureLoad(plane1, coord, 0i).rg, 1.0f) * params.yuvToRgbConversionMatrix);
}
- color = gammaCorrection(color, params.gammaDecodeParams);
- color = (params.gamutConversionMatrix * color);
- color = gammaCorrection(color, params.gammaEncodeParams);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return vec4<f32>(color, 1.0f);
}
@@ -599,6 +618,7 @@
struct ExternalTextureParams {
numPlanes : u32,
+ doYuvToRgbConversionOnly : u32,
yuvToRgbConversionMatrix : mat3x4<f32>,
gammaDecodeParams : GammaTransferParams,
gammaEncodeParams : GammaTransferParams,
@@ -623,9 +643,11 @@
} else {
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0f).r, textureSampleLevel(plane1, smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
}
- color = gammaCorrection(color, params.gammaDecodeParams);
- color = (params.gamutConversionMatrix * color);
- color = gammaCorrection(color, params.gammaEncodeParams);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return vec4<f32>(color, 1.0f);
}
@@ -636,9 +658,11 @@
} else {
color = (vec4<f32>(textureLoad(plane0, coord, 0i).r, textureLoad(plane1, coord, 0i).rg, 1.0f) * params.yuvToRgbConversionMatrix);
}
- color = gammaCorrection(color, params.gammaDecodeParams);
- color = (params.gamutConversionMatrix * color);
- color = gammaCorrection(color, params.gammaEncodeParams);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return vec4<f32>(color, 1.0f);
}
@@ -688,6 +712,7 @@
struct ExternalTextureParams {
numPlanes : u32,
+ doYuvToRgbConversionOnly : u32,
yuvToRgbConversionMatrix : mat3x4<f32>,
gammaDecodeParams : GammaTransferParams,
gammaEncodeParams : GammaTransferParams,
@@ -734,9 +759,11 @@
} else {
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0f).r, textureSampleLevel(plane1, smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
}
- color = gammaCorrection(color, params.gammaDecodeParams);
- color = (params.gamutConversionMatrix * color);
- color = gammaCorrection(color, params.gammaEncodeParams);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return vec4<f32>(color, 1.0f);
}
@@ -788,6 +815,7 @@
struct ExternalTextureParams {
numPlanes : u32,
+ doYuvToRgbConversionOnly : u32,
yuvToRgbConversionMatrix : mat3x4<f32>,
gammaDecodeParams : GammaTransferParams,
gammaEncodeParams : GammaTransferParams,
@@ -812,9 +840,11 @@
} else {
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0f).r, textureSampleLevel(plane1, smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
}
- color = gammaCorrection(color, params.gammaDecodeParams);
- color = (params.gamutConversionMatrix * color);
- color = gammaCorrection(color, params.gammaEncodeParams);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return vec4<f32>(color, 1.0f);
}
@@ -870,6 +900,7 @@
struct ExternalTextureParams {
numPlanes : u32,
+ doYuvToRgbConversionOnly : u32,
yuvToRgbConversionMatrix : mat3x4<f32>,
gammaDecodeParams : GammaTransferParams,
gammaEncodeParams : GammaTransferParams,
@@ -899,9 +930,11 @@
} else {
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0f).r, textureSampleLevel(plane1, smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
}
- color = gammaCorrection(color, params.gammaDecodeParams);
- color = (params.gamutConversionMatrix * color);
- color = gammaCorrection(color, params.gammaEncodeParams);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return vec4<f32>(color, 1.0f);
}
@@ -952,6 +985,7 @@
struct ExternalTextureParams {
numPlanes : u32,
+ doYuvToRgbConversionOnly : u32,
yuvToRgbConversionMatrix : mat3x4<f32>,
gammaDecodeParams : GammaTransferParams,
gammaEncodeParams : GammaTransferParams,
@@ -976,9 +1010,11 @@
} else {
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0f).r, textureSampleLevel(plane1, smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
}
- color = gammaCorrection(color, params.gammaDecodeParams);
- color = (params.gamutConversionMatrix * color);
- color = gammaCorrection(color, params.gammaEncodeParams);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return vec4<f32>(color, 1.0f);
}
@@ -1036,6 +1072,7 @@
struct ExternalTextureParams {
numPlanes : u32,
+ doYuvToRgbConversionOnly : u32,
yuvToRgbConversionMatrix : mat3x4<f32>,
gammaDecodeParams : GammaTransferParams,
gammaEncodeParams : GammaTransferParams,
@@ -1064,9 +1101,11 @@
} else {
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0f).r, textureSampleLevel(plane1, smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
}
- color = gammaCorrection(color, params.gammaDecodeParams);
- color = (params.gamutConversionMatrix * color);
- color = gammaCorrection(color, params.gammaEncodeParams);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return vec4<f32>(color, 1.0f);
}
@@ -1129,6 +1168,7 @@
struct ExternalTextureParams {
numPlanes : u32,
+ doYuvToRgbConversionOnly : u32,
yuvToRgbConversionMatrix : mat3x4<f32>,
gammaDecodeParams : GammaTransferParams,
gammaEncodeParams : GammaTransferParams,
@@ -1162,9 +1202,11 @@
} else {
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0f).r, textureSampleLevel(plane1, smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
}
- color = gammaCorrection(color, params.gammaDecodeParams);
- color = (params.gamutConversionMatrix * color);
- color = gammaCorrection(color, params.gammaEncodeParams);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return vec4<f32>(color, 1.0f);
}
@@ -1223,6 +1265,7 @@
struct ExternalTextureParams {
numPlanes : u32,
+ doYuvToRgbConversionOnly : u32,
yuvToRgbConversionMatrix : mat3x4<f32>,
gammaDecodeParams : GammaTransferParams,
gammaEncodeParams : GammaTransferParams,
@@ -1247,9 +1290,11 @@
} else {
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0f).r, textureSampleLevel(plane1, smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
}
- color = gammaCorrection(color, params.gammaDecodeParams);
- color = (params.gamutConversionMatrix * color);
- color = gammaCorrection(color, params.gammaEncodeParams);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return vec4<f32>(color, 1.0f);
}
@@ -1313,6 +1358,7 @@
struct ExternalTextureParams {
numPlanes : u32,
+ doYuvToRgbConversionOnly : u32,
yuvToRgbConversionMatrix : mat3x4<f32>,
gammaDecodeParams : GammaTransferParams,
gammaEncodeParams : GammaTransferParams,
@@ -1337,9 +1383,11 @@
} else {
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0f).r, textureSampleLevel(plane1, smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
}
- color = gammaCorrection(color, params.gammaDecodeParams);
- color = (params.gamutConversionMatrix * color);
- color = gammaCorrection(color, params.gammaEncodeParams);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return vec4<f32>(color, 1.0f);
}
@@ -1391,6 +1439,7 @@
struct ExternalTextureParams {
numPlanes : u32,
+ doYuvToRgbConversionOnly : u32,
yuvToRgbConversionMatrix : mat3x4<f32>,
gammaDecodeParams : GammaTransferParams,
gammaEncodeParams : GammaTransferParams,
@@ -1441,6 +1490,7 @@
struct ExternalTextureParams {
numPlanes : u32,
+ doYuvToRgbConversionOnly : u32,
yuvToRgbConversionMatrix : mat3x4<f32>,
gammaDecodeParams : GammaTransferParams,
gammaEncodeParams : GammaTransferParams,
@@ -1467,9 +1517,11 @@
} else {
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0f).r, textureSampleLevel(plane1, smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
}
- color = gammaCorrection(color, params.gammaDecodeParams);
- color = (params.gamutConversionMatrix * color);
- color = gammaCorrection(color, params.gammaEncodeParams);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return vec4<f32>(color, 1.0f);
}
@@ -1526,6 +1578,7 @@
struct ExternalTextureParams {
numPlanes : u32,
+ doYuvToRgbConversionOnly : u32,
yuvToRgbConversionMatrix : mat3x4<f32>,
gammaDecodeParams : GammaTransferParams,
gammaEncodeParams : GammaTransferParams,
@@ -1555,9 +1608,11 @@
} else {
color = (vec4<f32>(textureSampleLevel(plane0, smp, coord, 0.0f).r, textureSampleLevel(plane1, smp, coord, 0.0f).rg, 1.0f) * params.yuvToRgbConversionMatrix);
}
- color = gammaCorrection(color, params.gammaDecodeParams);
- color = (params.gamutConversionMatrix * color);
- color = gammaCorrection(color, params.gammaEncodeParams);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return vec4<f32>(color, 1.0f);
}
diff --git a/test/tint/builtins/gen/literal/textureDimensions/ba1481.wgsl.expected.glsl b/test/tint/builtins/gen/literal/textureDimensions/ba1481.wgsl.expected.glsl
index 25eab78..47564ae 100644
--- a/test/tint/builtins/gen/literal/textureDimensions/ba1481.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/literal/textureDimensions/ba1481.wgsl.expected.glsl
@@ -13,6 +13,7 @@
struct ExternalTextureParams {
uint numPlanes;
+ uint doYuvToRgbConversionOnly;
mat3x4 yuvToRgbConversionMatrix;
GammaTransferParams gammaDecodeParams;
GammaTransferParams gammaEncodeParams;
@@ -21,6 +22,7 @@
layout(binding = 2) uniform ExternalTextureParams_1 {
uint numPlanes;
+ uint doYuvToRgbConversionOnly;
mat3x4 yuvToRgbConversionMatrix;
GammaTransferParams gammaDecodeParams;
GammaTransferParams gammaEncodeParams;
@@ -61,6 +63,7 @@
struct ExternalTextureParams {
uint numPlanes;
+ uint doYuvToRgbConversionOnly;
mat3x4 yuvToRgbConversionMatrix;
GammaTransferParams gammaDecodeParams;
GammaTransferParams gammaEncodeParams;
@@ -69,6 +72,7 @@
layout(binding = 2) uniform ExternalTextureParams_1 {
uint numPlanes;
+ uint doYuvToRgbConversionOnly;
mat3x4 yuvToRgbConversionMatrix;
GammaTransferParams gammaDecodeParams;
GammaTransferParams gammaEncodeParams;
@@ -103,6 +107,7 @@
struct ExternalTextureParams {
uint numPlanes;
+ uint doYuvToRgbConversionOnly;
mat3x4 yuvToRgbConversionMatrix;
GammaTransferParams gammaDecodeParams;
GammaTransferParams gammaEncodeParams;
@@ -111,6 +116,7 @@
layout(binding = 2) uniform ExternalTextureParams_1 {
uint numPlanes;
+ uint doYuvToRgbConversionOnly;
mat3x4 yuvToRgbConversionMatrix;
GammaTransferParams gammaDecodeParams;
GammaTransferParams gammaEncodeParams;
diff --git a/test/tint/builtins/gen/literal/textureDimensions/ba1481.wgsl.expected.msl b/test/tint/builtins/gen/literal/textureDimensions/ba1481.wgsl.expected.msl
index cf84f15..f659868 100644
--- a/test/tint/builtins/gen/literal/textureDimensions/ba1481.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/textureDimensions/ba1481.wgsl.expected.msl
@@ -14,6 +14,7 @@
struct ExternalTextureParams {
uint numPlanes;
+ uint doYuvToRgbConversionOnly;
float3x4 yuvToRgbConversionMatrix;
GammaTransferParams gammaDecodeParams;
GammaTransferParams gammaEncodeParams;
diff --git a/test/tint/builtins/gen/literal/textureDimensions/ba1481.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/textureDimensions/ba1481.wgsl.expected.spvasm
index c0f550a..a7eb76b 100644
--- a/test/tint/builtins/gen/literal/textureDimensions/ba1481.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/textureDimensions/ba1481.wgsl.expected.spvasm
@@ -16,8 +16,9 @@
OpName %ext_tex_plane_1 "ext_tex_plane_1"
OpName %ExternalTextureParams "ExternalTextureParams"
OpMemberName %ExternalTextureParams 0 "numPlanes"
- OpMemberName %ExternalTextureParams 1 "yuvToRgbConversionMatrix"
- OpMemberName %ExternalTextureParams 2 "gammaDecodeParams"
+ OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly"
+ OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix"
+ OpMemberName %ExternalTextureParams 3 "gammaDecodeParams"
OpName %GammaTransferParams "GammaTransferParams"
OpMemberName %GammaTransferParams 0 "G"
OpMemberName %GammaTransferParams 1 "A"
@@ -27,8 +28,8 @@
OpMemberName %GammaTransferParams 5 "E"
OpMemberName %GammaTransferParams 6 "F"
OpMemberName %GammaTransferParams 7 "padding"
- OpMemberName %ExternalTextureParams 3 "gammaEncodeParams"
- OpMemberName %ExternalTextureParams 4 "gamutConversionMatrix"
+ OpMemberName %ExternalTextureParams 4 "gammaEncodeParams"
+ OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix"
OpName %ext_tex_params "ext_tex_params"
OpName %arg_0 "arg_0"
OpName %textureDimensions_ba1481 "textureDimensions_ba1481"
@@ -43,10 +44,11 @@
OpDecorate %ext_tex_plane_1 Binding 1
OpDecorate %ExternalTextureParams Block
OpMemberDecorate %ExternalTextureParams 0 Offset 0
- OpMemberDecorate %ExternalTextureParams 1 Offset 16
- OpMemberDecorate %ExternalTextureParams 1 ColMajor
- OpMemberDecorate %ExternalTextureParams 1 MatrixStride 16
- OpMemberDecorate %ExternalTextureParams 2 Offset 64
+ OpMemberDecorate %ExternalTextureParams 1 Offset 4
+ OpMemberDecorate %ExternalTextureParams 2 Offset 16
+ OpMemberDecorate %ExternalTextureParams 2 ColMajor
+ OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16
+ OpMemberDecorate %ExternalTextureParams 3 Offset 64
OpMemberDecorate %GammaTransferParams 0 Offset 0
OpMemberDecorate %GammaTransferParams 1 Offset 4
OpMemberDecorate %GammaTransferParams 2 Offset 8
@@ -55,10 +57,10 @@
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
+ OpMemberDecorate %ExternalTextureParams 4 Offset 96
+ OpMemberDecorate %ExternalTextureParams 5 Offset 128
+ OpMemberDecorate %ExternalTextureParams 5 ColMajor
+ OpMemberDecorate %ExternalTextureParams 5 MatrixStride 16
OpDecorate %ext_tex_params NonWritable
OpDecorate %ext_tex_params DescriptorSet 1
OpDecorate %ext_tex_params Binding 2
@@ -80,7 +82,7 @@
%GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
%v3float = OpTypeVector %float 3
%mat3v3float = OpTypeMatrix %v3float 3
-%ExternalTextureParams = OpTypeStruct %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
+%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams
%ext_tex_params = OpVariable %_ptr_Uniform_ExternalTextureParams Uniform
%arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant
diff --git a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.hlsl b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.hlsl
index 471ccc9..33ee497 100644
--- a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.hlsl
+++ b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.hlsl
@@ -10,6 +10,7 @@
};
struct ExternalTextureParams {
uint numPlanes;
+ uint doYuvToRgbConversionOnly;
float3x4 yuvToRgbConversionMatrix;
GammaTransferParams gammaDecodeParams;
GammaTransferParams gammaEncodeParams;
@@ -36,9 +37,11 @@
} else {
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);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = mul(color, params.gamutConversionMatrix);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return float4(color, 1.0f);
}
@@ -71,7 +74,8 @@
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))};
+ const uint scalar_offset_15 = ((offset + 4u)) / 4;
+ const ExternalTextureParams tint_symbol_10 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], buffer[scalar_offset_15 / 4][scalar_offset_15 % 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;
}
diff --git a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.msl b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.msl
index b52cfa7..04f882d 100644
--- a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.msl
@@ -14,7 +14,8 @@
struct ExternalTextureParams {
/* 0x0000 */ uint numPlanes;
- /* 0x0004 */ int8_t tint_pad[12];
+ /* 0x0004 */ uint doYuvToRgbConversionOnly;
+ /* 0x0008 */ int8_t tint_pad[8];
/* 0x0010 */ float3x4 yuvToRgbConversionMatrix;
/* 0x0040 */ GammaTransferParams gammaDecodeParams;
/* 0x0060 */ GammaTransferParams gammaEncodeParams;
@@ -35,9 +36,11 @@
} else {
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);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return float4(color, 1.0f);
}
diff --git a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.spvasm
index 7fe7f87..01d8762 100644
--- a/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/textureLoad/8acf41.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 129
+; Bound: 134
; Schema: 0
OpCapability Shader
%27 = OpExtInstImport "GLSL.std.450"
@@ -16,8 +16,9 @@
OpName %ext_tex_plane_1 "ext_tex_plane_1"
OpName %ExternalTextureParams "ExternalTextureParams"
OpMemberName %ExternalTextureParams 0 "numPlanes"
- OpMemberName %ExternalTextureParams 1 "yuvToRgbConversionMatrix"
- OpMemberName %ExternalTextureParams 2 "gammaDecodeParams"
+ OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly"
+ OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix"
+ OpMemberName %ExternalTextureParams 3 "gammaDecodeParams"
OpName %GammaTransferParams "GammaTransferParams"
OpMemberName %GammaTransferParams 0 "G"
OpMemberName %GammaTransferParams 1 "A"
@@ -27,8 +28,8 @@
OpMemberName %GammaTransferParams 5 "E"
OpMemberName %GammaTransferParams 6 "F"
OpMemberName %GammaTransferParams 7 "padding"
- OpMemberName %ExternalTextureParams 3 "gammaEncodeParams"
- OpMemberName %ExternalTextureParams 4 "gamutConversionMatrix"
+ OpMemberName %ExternalTextureParams 4 "gammaEncodeParams"
+ OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix"
OpName %ext_tex_params "ext_tex_params"
OpName %arg_0 "arg_0"
OpName %gammaCorrection "gammaCorrection"
@@ -52,10 +53,11 @@
OpDecorate %ext_tex_plane_1 Binding 1
OpDecorate %ExternalTextureParams Block
OpMemberDecorate %ExternalTextureParams 0 Offset 0
- OpMemberDecorate %ExternalTextureParams 1 Offset 16
- OpMemberDecorate %ExternalTextureParams 1 ColMajor
- OpMemberDecorate %ExternalTextureParams 1 MatrixStride 16
- OpMemberDecorate %ExternalTextureParams 2 Offset 64
+ OpMemberDecorate %ExternalTextureParams 1 Offset 4
+ OpMemberDecorate %ExternalTextureParams 2 Offset 16
+ OpMemberDecorate %ExternalTextureParams 2 ColMajor
+ OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16
+ OpMemberDecorate %ExternalTextureParams 3 Offset 64
OpMemberDecorate %GammaTransferParams 0 Offset 0
OpMemberDecorate %GammaTransferParams 1 Offset 4
OpMemberDecorate %GammaTransferParams 2 Offset 8
@@ -64,10 +66,10 @@
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
+ OpMemberDecorate %ExternalTextureParams 4 Offset 96
+ OpMemberDecorate %ExternalTextureParams 5 Offset 128
+ OpMemberDecorate %ExternalTextureParams 5 ColMajor
+ OpMemberDecorate %ExternalTextureParams 5 MatrixStride 16
OpDecorate %ext_tex_params NonWritable
OpDecorate %ext_tex_params DescriptorSet 1
OpDecorate %ext_tex_params Binding 2
@@ -89,7 +91,7 @@
%GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
%v3float = OpTypeVector %float 3
%mat3v3float = OpTypeMatrix %v3float 3
-%ExternalTextureParams = OpTypeStruct %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
+%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams
%ext_tex_params = OpVariable %_ptr_Uniform_ExternalTextureParams Uniform
%arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant
@@ -105,11 +107,12 @@
%78 = OpConstantNull %int
%v2float = OpTypeVector %float 2
%float_1 = OpConstant %float 1
+ %92 = OpConstantNull %uint
%void = OpTypeVoid
- %105 = OpTypeFunction %void
- %112 = OpConstantNull %v2int
+ %110 = OpTypeFunction %void
+ %117 = OpConstantNull %v2int
%_ptr_Function_v4float = OpTypePointer Function %v4float
- %116 = OpTypeFunction %v4float
+ %121 = OpTypeFunction %v4float
%gammaCorrection = OpFunction %v3float None %21
%v = OpFunctionParameter %v3float
%params = OpFunctionParameter %GammaTransferParams
@@ -170,59 +173,66 @@
%85 = OpCompositeExtract %float %84 0
%86 = OpCompositeExtract %float %84 1
%88 = OpCompositeConstruct %v4float %81 %85 %86 %float_1
- %89 = OpCompositeExtract %mat3v4float %params_0 1
+ %89 = OpCompositeExtract %mat3v4float %params_0 2
%90 = OpVectorTimesMatrix %v3float %88 %89
OpStore %color %90
OpBranch %74
%74 = OpLabel
- %92 = OpLoad %v3float %color
- %93 = OpCompositeExtract %GammaTransferParams %params_0 2
- %91 = OpFunctionCall %v3float %gammaCorrection %92 %93
- OpStore %color %91
- %94 = OpCompositeExtract %mat3v3float %params_0 4
- %95 = OpLoad %v3float %color
- %96 = OpMatrixTimesVector %v3float %94 %95
+ %91 = OpCompositeExtract %uint %params_0 1
+ %93 = OpIEqual %bool %91 %92
+ OpSelectionMerge %94 None
+ OpBranchConditional %93 %95 %94
+ %95 = OpLabel
+ %97 = OpLoad %v3float %color
+ %98 = OpCompositeExtract %GammaTransferParams %params_0 3
+ %96 = OpFunctionCall %v3float %gammaCorrection %97 %98
OpStore %color %96
- %98 = OpLoad %v3float %color
- %99 = OpCompositeExtract %GammaTransferParams %params_0 3
- %97 = OpFunctionCall %v3float %gammaCorrection %98 %99
- OpStore %color %97
+ %99 = OpCompositeExtract %mat3v3float %params_0 5
%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
+ %101 = OpMatrixTimesVector %v3float %99 %100
+ OpStore %color %101
+ %103 = OpLoad %v3float %color
+ %104 = OpCompositeExtract %GammaTransferParams %params_0 4
+ %102 = OpFunctionCall %v3float %gammaCorrection %103 %104
+ OpStore %color %102
+ OpBranch %94
+ %94 = OpLabel
+ %105 = OpLoad %v3float %color
+ %106 = OpCompositeExtract %float %105 0
+ %107 = OpCompositeExtract %float %105 1
+ %108 = OpCompositeExtract %float %105 2
+ %109 = OpCompositeConstruct %v4float %106 %107 %108 %float_1
+ OpReturnValue %109
OpFunctionEnd
-%textureLoad_8acf41 = OpFunction %void None %105
- %108 = OpLabel
+%textureLoad_8acf41 = OpFunction %void None %110
+ %113 = OpLabel
%res = OpVariable %_ptr_Function_v4float Function %5
- %110 = OpLoad %11 %arg_0
- %111 = OpLoad %11 %ext_tex_plane_1
- %113 = OpLoad %ExternalTextureParams %ext_tex_params
- %109 = OpFunctionCall %v4float %textureLoadExternal %110 %111 %112 %113
- OpStore %res %109
+ %115 = OpLoad %11 %arg_0
+ %116 = OpLoad %11 %ext_tex_plane_1
+ %118 = OpLoad %ExternalTextureParams %ext_tex_params
+ %114 = OpFunctionCall %v4float %textureLoadExternal %115 %116 %117 %118
+ OpStore %res %114
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %116
- %118 = OpLabel
- %119 = OpFunctionCall %void %textureLoad_8acf41
+%vertex_main_inner = OpFunction %v4float None %121
+ %123 = OpLabel
+ %124 = OpFunctionCall %void %textureLoad_8acf41
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %105
- %121 = OpLabel
- %122 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %122
+%vertex_main = OpFunction %void None %110
+ %126 = OpLabel
+ %127 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %127
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %105
- %124 = OpLabel
- %125 = OpFunctionCall %void %textureLoad_8acf41
+%fragment_main = OpFunction %void None %110
+ %129 = OpLabel
+ %130 = OpFunctionCall %void %textureLoad_8acf41
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %105
- %127 = OpLabel
- %128 = OpFunctionCall %void %textureLoad_8acf41
+%compute_main = OpFunction %void None %110
+ %132 = OpLabel
+ %133 = OpFunctionCall %void %textureLoad_8acf41
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.hlsl b/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.hlsl
index ffc9899..914a3c9 100644
--- a/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.hlsl
+++ b/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.hlsl
@@ -10,6 +10,7 @@
};
struct ExternalTextureParams {
uint numPlanes;
+ uint doYuvToRgbConversionOnly;
float3x4 yuvToRgbConversionMatrix;
GammaTransferParams gammaDecodeParams;
GammaTransferParams gammaEncodeParams;
@@ -37,9 +38,11 @@
} else {
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);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = mul(color, params.gamutConversionMatrix);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return float4(color, 1.0f);
}
@@ -72,7 +75,8 @@
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))};
+ const uint scalar_offset_15 = ((offset + 4u)) / 4;
+ const ExternalTextureParams tint_symbol_10 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], buffer[scalar_offset_15 / 4][scalar_offset_15 % 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;
}
diff --git a/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.msl b/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.msl
index 57d9745..fa5b6c3 100644
--- a/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.msl
+++ b/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.msl
@@ -14,7 +14,8 @@
struct ExternalTextureParams {
/* 0x0000 */ uint numPlanes;
- /* 0x0004 */ int8_t tint_pad[12];
+ /* 0x0004 */ uint doYuvToRgbConversionOnly;
+ /* 0x0008 */ int8_t tint_pad[8];
/* 0x0010 */ float3x4 yuvToRgbConversionMatrix;
/* 0x0040 */ GammaTransferParams gammaDecodeParams;
/* 0x0060 */ GammaTransferParams gammaEncodeParams;
@@ -35,9 +36,11 @@
} 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 = gammaCorrection(color, params.gammaDecodeParams);
- color = (params.gamutConversionMatrix * color);
- color = gammaCorrection(color, params.gammaEncodeParams);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return float4(color, 1.0f);
}
diff --git a/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.spvasm b/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.spvasm
index ab657b0..444e4c2 100644
--- a/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/literal/textureSampleLevel/979816.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 135
+; Bound: 140
; Schema: 0
OpCapability Shader
%30 = OpExtInstImport "GLSL.std.450"
@@ -16,8 +16,9 @@
OpName %ext_tex_plane_1 "ext_tex_plane_1"
OpName %ExternalTextureParams "ExternalTextureParams"
OpMemberName %ExternalTextureParams 0 "numPlanes"
- OpMemberName %ExternalTextureParams 1 "yuvToRgbConversionMatrix"
- OpMemberName %ExternalTextureParams 2 "gammaDecodeParams"
+ OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly"
+ OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix"
+ OpMemberName %ExternalTextureParams 3 "gammaDecodeParams"
OpName %GammaTransferParams "GammaTransferParams"
OpMemberName %GammaTransferParams 0 "G"
OpMemberName %GammaTransferParams 1 "A"
@@ -27,8 +28,8 @@
OpMemberName %GammaTransferParams 5 "E"
OpMemberName %GammaTransferParams 6 "F"
OpMemberName %GammaTransferParams 7 "padding"
- OpMemberName %ExternalTextureParams 3 "gammaEncodeParams"
- OpMemberName %ExternalTextureParams 4 "gamutConversionMatrix"
+ OpMemberName %ExternalTextureParams 4 "gammaEncodeParams"
+ OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix"
OpName %ext_tex_params "ext_tex_params"
OpName %arg_0 "arg_0"
OpName %arg_1 "arg_1"
@@ -54,10 +55,11 @@
OpDecorate %ext_tex_plane_1 Binding 2
OpDecorate %ExternalTextureParams Block
OpMemberDecorate %ExternalTextureParams 0 Offset 0
- OpMemberDecorate %ExternalTextureParams 1 Offset 16
- OpMemberDecorate %ExternalTextureParams 1 ColMajor
- OpMemberDecorate %ExternalTextureParams 1 MatrixStride 16
- OpMemberDecorate %ExternalTextureParams 2 Offset 64
+ OpMemberDecorate %ExternalTextureParams 1 Offset 4
+ OpMemberDecorate %ExternalTextureParams 2 Offset 16
+ OpMemberDecorate %ExternalTextureParams 2 ColMajor
+ OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16
+ OpMemberDecorate %ExternalTextureParams 3 Offset 64
OpMemberDecorate %GammaTransferParams 0 Offset 0
OpMemberDecorate %GammaTransferParams 1 Offset 4
OpMemberDecorate %GammaTransferParams 2 Offset 8
@@ -66,10 +68,10 @@
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
+ OpMemberDecorate %ExternalTextureParams 4 Offset 96
+ OpMemberDecorate %ExternalTextureParams 5 Offset 128
+ OpMemberDecorate %ExternalTextureParams 5 ColMajor
+ OpMemberDecorate %ExternalTextureParams 5 MatrixStride 16
OpDecorate %ext_tex_params NonWritable
OpDecorate %ext_tex_params DescriptorSet 1
OpDecorate %ext_tex_params Binding 3
@@ -93,7 +95,7 @@
%GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
%v3float = OpTypeVector %float 3
%mat3v3float = OpTypeMatrix %v3float 3
-%ExternalTextureParams = OpTypeStruct %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
+%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams
%ext_tex_params = OpVariable %_ptr_Uniform_ExternalTextureParams Uniform
%arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant
@@ -110,11 +112,12 @@
%uint_1 = OpConstant %uint 1
%81 = OpTypeSampledImage %11
%float_1 = OpConstant %float 1
+ %97 = OpConstantNull %uint
%void = OpTypeVoid
- %110 = OpTypeFunction %void
- %118 = OpConstantNull %v2float
+ %115 = OpTypeFunction %void
+ %123 = OpConstantNull %v2float
%_ptr_Function_v4float = OpTypePointer Function %v4float
- %122 = OpTypeFunction %v4float
+ %127 = OpTypeFunction %v4float
%gammaCorrection = OpFunction %v3float None %24
%v = OpFunctionParameter %v3float
%params = OpFunctionParameter %GammaTransferParams
@@ -179,60 +182,67 @@
%90 = OpCompositeExtract %float %89 0
%91 = OpCompositeExtract %float %89 1
%93 = OpCompositeConstruct %v4float %86 %90 %91 %float_1
- %94 = OpCompositeExtract %mat3v4float %params_0 1
+ %94 = OpCompositeExtract %mat3v4float %params_0 2
%95 = OpVectorTimesMatrix %v3float %93 %94
OpStore %color %95
OpBranch %77
%77 = OpLabel
- %97 = OpLoad %v3float %color
- %98 = OpCompositeExtract %GammaTransferParams %params_0 2
- %96 = OpFunctionCall %v3float %gammaCorrection %97 %98
- OpStore %color %96
- %99 = OpCompositeExtract %mat3v3float %params_0 4
- %100 = OpLoad %v3float %color
- %101 = OpMatrixTimesVector %v3float %99 %100
+ %96 = OpCompositeExtract %uint %params_0 1
+ %98 = OpIEqual %bool %96 %97
+ OpSelectionMerge %99 None
+ OpBranchConditional %98 %100 %99
+ %100 = OpLabel
+ %102 = OpLoad %v3float %color
+ %103 = OpCompositeExtract %GammaTransferParams %params_0 3
+ %101 = OpFunctionCall %v3float %gammaCorrection %102 %103
OpStore %color %101
- %103 = OpLoad %v3float %color
- %104 = OpCompositeExtract %GammaTransferParams %params_0 3
- %102 = OpFunctionCall %v3float %gammaCorrection %103 %104
- OpStore %color %102
+ %104 = OpCompositeExtract %mat3v3float %params_0 5
%105 = OpLoad %v3float %color
- %106 = OpCompositeExtract %float %105 0
- %107 = OpCompositeExtract %float %105 1
- %108 = OpCompositeExtract %float %105 2
- %109 = OpCompositeConstruct %v4float %106 %107 %108 %float_1
- OpReturnValue %109
+ %106 = OpMatrixTimesVector %v3float %104 %105
+ OpStore %color %106
+ %108 = OpLoad %v3float %color
+ %109 = OpCompositeExtract %GammaTransferParams %params_0 4
+ %107 = OpFunctionCall %v3float %gammaCorrection %108 %109
+ OpStore %color %107
+ OpBranch %99
+ %99 = OpLabel
+ %110 = OpLoad %v3float %color
+ %111 = OpCompositeExtract %float %110 0
+ %112 = OpCompositeExtract %float %110 1
+ %113 = OpCompositeExtract %float %110 2
+ %114 = OpCompositeConstruct %v4float %111 %112 %113 %float_1
+ OpReturnValue %114
OpFunctionEnd
-%textureSampleLevel_979816 = OpFunction %void None %110
- %113 = OpLabel
+%textureSampleLevel_979816 = OpFunction %void None %115
+ %118 = OpLabel
%res = OpVariable %_ptr_Function_v4float Function %5
- %115 = OpLoad %11 %arg_0
- %116 = OpLoad %11 %ext_tex_plane_1
- %117 = OpLoad %23 %arg_1
- %119 = OpLoad %ExternalTextureParams %ext_tex_params
- %114 = OpFunctionCall %v4float %textureSampleExternal %115 %116 %117 %118 %119
- OpStore %res %114
+ %120 = OpLoad %11 %arg_0
+ %121 = OpLoad %11 %ext_tex_plane_1
+ %122 = OpLoad %23 %arg_1
+ %124 = OpLoad %ExternalTextureParams %ext_tex_params
+ %119 = OpFunctionCall %v4float %textureSampleExternal %120 %121 %122 %123 %124
+ OpStore %res %119
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %122
- %124 = OpLabel
- %125 = OpFunctionCall %void %textureSampleLevel_979816
+%vertex_main_inner = OpFunction %v4float None %127
+ %129 = OpLabel
+ %130 = OpFunctionCall %void %textureSampleLevel_979816
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %110
- %127 = OpLabel
- %128 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %128
+%vertex_main = OpFunction %void None %115
+ %132 = OpLabel
+ %133 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %133
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %110
- %130 = OpLabel
- %131 = OpFunctionCall %void %textureSampleLevel_979816
+%fragment_main = OpFunction %void None %115
+ %135 = OpLabel
+ %136 = OpFunctionCall %void %textureSampleLevel_979816
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %110
- %133 = OpLabel
- %134 = OpFunctionCall %void %textureSampleLevel_979816
+%compute_main = OpFunction %void None %115
+ %138 = OpLabel
+ %139 = OpFunctionCall %void %textureSampleLevel_979816
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/textureDimensions/ba1481.wgsl.expected.glsl b/test/tint/builtins/gen/var/textureDimensions/ba1481.wgsl.expected.glsl
index 25eab78..47564ae 100644
--- a/test/tint/builtins/gen/var/textureDimensions/ba1481.wgsl.expected.glsl
+++ b/test/tint/builtins/gen/var/textureDimensions/ba1481.wgsl.expected.glsl
@@ -13,6 +13,7 @@
struct ExternalTextureParams {
uint numPlanes;
+ uint doYuvToRgbConversionOnly;
mat3x4 yuvToRgbConversionMatrix;
GammaTransferParams gammaDecodeParams;
GammaTransferParams gammaEncodeParams;
@@ -21,6 +22,7 @@
layout(binding = 2) uniform ExternalTextureParams_1 {
uint numPlanes;
+ uint doYuvToRgbConversionOnly;
mat3x4 yuvToRgbConversionMatrix;
GammaTransferParams gammaDecodeParams;
GammaTransferParams gammaEncodeParams;
@@ -61,6 +63,7 @@
struct ExternalTextureParams {
uint numPlanes;
+ uint doYuvToRgbConversionOnly;
mat3x4 yuvToRgbConversionMatrix;
GammaTransferParams gammaDecodeParams;
GammaTransferParams gammaEncodeParams;
@@ -69,6 +72,7 @@
layout(binding = 2) uniform ExternalTextureParams_1 {
uint numPlanes;
+ uint doYuvToRgbConversionOnly;
mat3x4 yuvToRgbConversionMatrix;
GammaTransferParams gammaDecodeParams;
GammaTransferParams gammaEncodeParams;
@@ -103,6 +107,7 @@
struct ExternalTextureParams {
uint numPlanes;
+ uint doYuvToRgbConversionOnly;
mat3x4 yuvToRgbConversionMatrix;
GammaTransferParams gammaDecodeParams;
GammaTransferParams gammaEncodeParams;
@@ -111,6 +116,7 @@
layout(binding = 2) uniform ExternalTextureParams_1 {
uint numPlanes;
+ uint doYuvToRgbConversionOnly;
mat3x4 yuvToRgbConversionMatrix;
GammaTransferParams gammaDecodeParams;
GammaTransferParams gammaEncodeParams;
diff --git a/test/tint/builtins/gen/var/textureDimensions/ba1481.wgsl.expected.msl b/test/tint/builtins/gen/var/textureDimensions/ba1481.wgsl.expected.msl
index cf84f15..f659868 100644
--- a/test/tint/builtins/gen/var/textureDimensions/ba1481.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/textureDimensions/ba1481.wgsl.expected.msl
@@ -14,6 +14,7 @@
struct ExternalTextureParams {
uint numPlanes;
+ uint doYuvToRgbConversionOnly;
float3x4 yuvToRgbConversionMatrix;
GammaTransferParams gammaDecodeParams;
GammaTransferParams gammaEncodeParams;
diff --git a/test/tint/builtins/gen/var/textureDimensions/ba1481.wgsl.expected.spvasm b/test/tint/builtins/gen/var/textureDimensions/ba1481.wgsl.expected.spvasm
index c0f550a..a7eb76b 100644
--- a/test/tint/builtins/gen/var/textureDimensions/ba1481.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/textureDimensions/ba1481.wgsl.expected.spvasm
@@ -16,8 +16,9 @@
OpName %ext_tex_plane_1 "ext_tex_plane_1"
OpName %ExternalTextureParams "ExternalTextureParams"
OpMemberName %ExternalTextureParams 0 "numPlanes"
- OpMemberName %ExternalTextureParams 1 "yuvToRgbConversionMatrix"
- OpMemberName %ExternalTextureParams 2 "gammaDecodeParams"
+ OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly"
+ OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix"
+ OpMemberName %ExternalTextureParams 3 "gammaDecodeParams"
OpName %GammaTransferParams "GammaTransferParams"
OpMemberName %GammaTransferParams 0 "G"
OpMemberName %GammaTransferParams 1 "A"
@@ -27,8 +28,8 @@
OpMemberName %GammaTransferParams 5 "E"
OpMemberName %GammaTransferParams 6 "F"
OpMemberName %GammaTransferParams 7 "padding"
- OpMemberName %ExternalTextureParams 3 "gammaEncodeParams"
- OpMemberName %ExternalTextureParams 4 "gamutConversionMatrix"
+ OpMemberName %ExternalTextureParams 4 "gammaEncodeParams"
+ OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix"
OpName %ext_tex_params "ext_tex_params"
OpName %arg_0 "arg_0"
OpName %textureDimensions_ba1481 "textureDimensions_ba1481"
@@ -43,10 +44,11 @@
OpDecorate %ext_tex_plane_1 Binding 1
OpDecorate %ExternalTextureParams Block
OpMemberDecorate %ExternalTextureParams 0 Offset 0
- OpMemberDecorate %ExternalTextureParams 1 Offset 16
- OpMemberDecorate %ExternalTextureParams 1 ColMajor
- OpMemberDecorate %ExternalTextureParams 1 MatrixStride 16
- OpMemberDecorate %ExternalTextureParams 2 Offset 64
+ OpMemberDecorate %ExternalTextureParams 1 Offset 4
+ OpMemberDecorate %ExternalTextureParams 2 Offset 16
+ OpMemberDecorate %ExternalTextureParams 2 ColMajor
+ OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16
+ OpMemberDecorate %ExternalTextureParams 3 Offset 64
OpMemberDecorate %GammaTransferParams 0 Offset 0
OpMemberDecorate %GammaTransferParams 1 Offset 4
OpMemberDecorate %GammaTransferParams 2 Offset 8
@@ -55,10 +57,10 @@
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
+ OpMemberDecorate %ExternalTextureParams 4 Offset 96
+ OpMemberDecorate %ExternalTextureParams 5 Offset 128
+ OpMemberDecorate %ExternalTextureParams 5 ColMajor
+ OpMemberDecorate %ExternalTextureParams 5 MatrixStride 16
OpDecorate %ext_tex_params NonWritable
OpDecorate %ext_tex_params DescriptorSet 1
OpDecorate %ext_tex_params Binding 2
@@ -80,7 +82,7 @@
%GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
%v3float = OpTypeVector %float 3
%mat3v3float = OpTypeMatrix %v3float 3
-%ExternalTextureParams = OpTypeStruct %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
+%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams
%ext_tex_params = OpVariable %_ptr_Uniform_ExternalTextureParams Uniform
%arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant
diff --git a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.hlsl b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.hlsl
index 010b382..4661657 100644
--- a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.hlsl
+++ b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.hlsl
@@ -10,6 +10,7 @@
};
struct ExternalTextureParams {
uint numPlanes;
+ uint doYuvToRgbConversionOnly;
float3x4 yuvToRgbConversionMatrix;
GammaTransferParams gammaDecodeParams;
GammaTransferParams gammaEncodeParams;
@@ -36,9 +37,11 @@
} else {
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);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = mul(color, params.gamutConversionMatrix);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return float4(color, 1.0f);
}
@@ -71,7 +74,8 @@
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))};
+ const uint scalar_offset_15 = ((offset + 4u)) / 4;
+ const ExternalTextureParams tint_symbol_10 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], buffer[scalar_offset_15 / 4][scalar_offset_15 % 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;
}
diff --git a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.msl b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.msl
index bd83a8e..5f8b2c3 100644
--- a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.msl
@@ -14,7 +14,8 @@
struct ExternalTextureParams {
/* 0x0000 */ uint numPlanes;
- /* 0x0004 */ int8_t tint_pad[12];
+ /* 0x0004 */ uint doYuvToRgbConversionOnly;
+ /* 0x0008 */ int8_t tint_pad[8];
/* 0x0010 */ float3x4 yuvToRgbConversionMatrix;
/* 0x0040 */ GammaTransferParams gammaDecodeParams;
/* 0x0060 */ GammaTransferParams gammaEncodeParams;
@@ -35,9 +36,11 @@
} else {
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);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return float4(color, 1.0f);
}
diff --git a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.spvasm b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.spvasm
index 2c3a902..c70c6b1 100644
--- a/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/textureLoad/8acf41.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 132
+; Bound: 137
; Schema: 0
OpCapability Shader
%27 = OpExtInstImport "GLSL.std.450"
@@ -16,8 +16,9 @@
OpName %ext_tex_plane_1 "ext_tex_plane_1"
OpName %ExternalTextureParams "ExternalTextureParams"
OpMemberName %ExternalTextureParams 0 "numPlanes"
- OpMemberName %ExternalTextureParams 1 "yuvToRgbConversionMatrix"
- OpMemberName %ExternalTextureParams 2 "gammaDecodeParams"
+ OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly"
+ OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix"
+ OpMemberName %ExternalTextureParams 3 "gammaDecodeParams"
OpName %GammaTransferParams "GammaTransferParams"
OpMemberName %GammaTransferParams 0 "G"
OpMemberName %GammaTransferParams 1 "A"
@@ -27,8 +28,8 @@
OpMemberName %GammaTransferParams 5 "E"
OpMemberName %GammaTransferParams 6 "F"
OpMemberName %GammaTransferParams 7 "padding"
- OpMemberName %ExternalTextureParams 3 "gammaEncodeParams"
- OpMemberName %ExternalTextureParams 4 "gamutConversionMatrix"
+ OpMemberName %ExternalTextureParams 4 "gammaEncodeParams"
+ OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix"
OpName %ext_tex_params "ext_tex_params"
OpName %arg_0 "arg_0"
OpName %gammaCorrection "gammaCorrection"
@@ -53,10 +54,11 @@
OpDecorate %ext_tex_plane_1 Binding 1
OpDecorate %ExternalTextureParams Block
OpMemberDecorate %ExternalTextureParams 0 Offset 0
- OpMemberDecorate %ExternalTextureParams 1 Offset 16
- OpMemberDecorate %ExternalTextureParams 1 ColMajor
- OpMemberDecorate %ExternalTextureParams 1 MatrixStride 16
- OpMemberDecorate %ExternalTextureParams 2 Offset 64
+ OpMemberDecorate %ExternalTextureParams 1 Offset 4
+ OpMemberDecorate %ExternalTextureParams 2 Offset 16
+ OpMemberDecorate %ExternalTextureParams 2 ColMajor
+ OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16
+ OpMemberDecorate %ExternalTextureParams 3 Offset 64
OpMemberDecorate %GammaTransferParams 0 Offset 0
OpMemberDecorate %GammaTransferParams 1 Offset 4
OpMemberDecorate %GammaTransferParams 2 Offset 8
@@ -65,10 +67,10 @@
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
+ OpMemberDecorate %ExternalTextureParams 4 Offset 96
+ OpMemberDecorate %ExternalTextureParams 5 Offset 128
+ OpMemberDecorate %ExternalTextureParams 5 ColMajor
+ OpMemberDecorate %ExternalTextureParams 5 MatrixStride 16
OpDecorate %ext_tex_params NonWritable
OpDecorate %ext_tex_params DescriptorSet 1
OpDecorate %ext_tex_params Binding 2
@@ -90,7 +92,7 @@
%GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
%v3float = OpTypeVector %float 3
%mat3v3float = OpTypeMatrix %v3float 3
-%ExternalTextureParams = OpTypeStruct %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
+%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams
%ext_tex_params = OpVariable %_ptr_Uniform_ExternalTextureParams Uniform
%arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant
@@ -106,12 +108,13 @@
%78 = OpConstantNull %int
%v2float = OpTypeVector %float 2
%float_1 = OpConstant %float 1
+ %92 = OpConstantNull %uint
%void = OpTypeVoid
- %105 = OpTypeFunction %void
- %109 = OpConstantNull %v2int
+ %110 = OpTypeFunction %void
+ %114 = OpConstantNull %v2int
%_ptr_Function_v2int = OpTypePointer Function %v2int
%_ptr_Function_v4float = OpTypePointer Function %v4float
- %119 = OpTypeFunction %v4float
+ %124 = OpTypeFunction %v4float
%gammaCorrection = OpFunction %v3float None %21
%v = OpFunctionParameter %v3float
%params = OpFunctionParameter %GammaTransferParams
@@ -172,62 +175,69 @@
%85 = OpCompositeExtract %float %84 0
%86 = OpCompositeExtract %float %84 1
%88 = OpCompositeConstruct %v4float %81 %85 %86 %float_1
- %89 = OpCompositeExtract %mat3v4float %params_0 1
+ %89 = OpCompositeExtract %mat3v4float %params_0 2
%90 = OpVectorTimesMatrix %v3float %88 %89
OpStore %color %90
OpBranch %74
%74 = OpLabel
- %92 = OpLoad %v3float %color
- %93 = OpCompositeExtract %GammaTransferParams %params_0 2
- %91 = OpFunctionCall %v3float %gammaCorrection %92 %93
- OpStore %color %91
- %94 = OpCompositeExtract %mat3v3float %params_0 4
- %95 = OpLoad %v3float %color
- %96 = OpMatrixTimesVector %v3float %94 %95
+ %91 = OpCompositeExtract %uint %params_0 1
+ %93 = OpIEqual %bool %91 %92
+ OpSelectionMerge %94 None
+ OpBranchConditional %93 %95 %94
+ %95 = OpLabel
+ %97 = OpLoad %v3float %color
+ %98 = OpCompositeExtract %GammaTransferParams %params_0 3
+ %96 = OpFunctionCall %v3float %gammaCorrection %97 %98
OpStore %color %96
- %98 = OpLoad %v3float %color
- %99 = OpCompositeExtract %GammaTransferParams %params_0 3
- %97 = OpFunctionCall %v3float %gammaCorrection %98 %99
- OpStore %color %97
+ %99 = OpCompositeExtract %mat3v3float %params_0 5
%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
+ %101 = OpMatrixTimesVector %v3float %99 %100
+ OpStore %color %101
+ %103 = OpLoad %v3float %color
+ %104 = OpCompositeExtract %GammaTransferParams %params_0 4
+ %102 = OpFunctionCall %v3float %gammaCorrection %103 %104
+ OpStore %color %102
+ OpBranch %94
+ %94 = OpLabel
+ %105 = OpLoad %v3float %color
+ %106 = OpCompositeExtract %float %105 0
+ %107 = OpCompositeExtract %float %105 1
+ %108 = OpCompositeExtract %float %105 2
+ %109 = OpCompositeConstruct %v4float %106 %107 %108 %float_1
+ OpReturnValue %109
OpFunctionEnd
-%textureLoad_8acf41 = OpFunction %void None %105
- %108 = OpLabel
- %arg_1 = OpVariable %_ptr_Function_v2int Function %109
+%textureLoad_8acf41 = OpFunction %void None %110
+ %113 = OpLabel
+ %arg_1 = OpVariable %_ptr_Function_v2int Function %114
%res = OpVariable %_ptr_Function_v4float Function %5
- OpStore %arg_1 %109
- %113 = OpLoad %11 %arg_0
- %114 = OpLoad %11 %ext_tex_plane_1
- %115 = OpLoad %v2int %arg_1
- %116 = OpLoad %ExternalTextureParams %ext_tex_params
- %112 = OpFunctionCall %v4float %textureLoadExternal %113 %114 %115 %116
- OpStore %res %112
+ OpStore %arg_1 %114
+ %118 = OpLoad %11 %arg_0
+ %119 = OpLoad %11 %ext_tex_plane_1
+ %120 = OpLoad %v2int %arg_1
+ %121 = OpLoad %ExternalTextureParams %ext_tex_params
+ %117 = OpFunctionCall %v4float %textureLoadExternal %118 %119 %120 %121
+ OpStore %res %117
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %119
- %121 = OpLabel
- %122 = OpFunctionCall %void %textureLoad_8acf41
+%vertex_main_inner = OpFunction %v4float None %124
+ %126 = OpLabel
+ %127 = OpFunctionCall %void %textureLoad_8acf41
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %105
- %124 = OpLabel
- %125 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %125
+%vertex_main = OpFunction %void None %110
+ %129 = OpLabel
+ %130 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %130
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %105
- %127 = OpLabel
- %128 = OpFunctionCall %void %textureLoad_8acf41
+%fragment_main = OpFunction %void None %110
+ %132 = OpLabel
+ %133 = OpFunctionCall %void %textureLoad_8acf41
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %105
- %130 = OpLabel
- %131 = OpFunctionCall %void %textureLoad_8acf41
+%compute_main = OpFunction %void None %110
+ %135 = OpLabel
+ %136 = OpFunctionCall %void %textureLoad_8acf41
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.hlsl b/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.hlsl
index 5aae94c..20a6a98 100644
--- a/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.hlsl
+++ b/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.hlsl
@@ -10,6 +10,7 @@
};
struct ExternalTextureParams {
uint numPlanes;
+ uint doYuvToRgbConversionOnly;
float3x4 yuvToRgbConversionMatrix;
GammaTransferParams gammaDecodeParams;
GammaTransferParams gammaEncodeParams;
@@ -37,9 +38,11 @@
} else {
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);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = mul(color, params.gamutConversionMatrix);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return float4(color, 1.0f);
}
@@ -72,7 +75,8 @@
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))};
+ const uint scalar_offset_15 = ((offset + 4u)) / 4;
+ const ExternalTextureParams tint_symbol_10 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], buffer[scalar_offset_15 / 4][scalar_offset_15 % 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;
}
diff --git a/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.msl b/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.msl
index 2dabca5..a84758c 100644
--- a/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.msl
+++ b/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.msl
@@ -14,7 +14,8 @@
struct ExternalTextureParams {
/* 0x0000 */ uint numPlanes;
- /* 0x0004 */ int8_t tint_pad[12];
+ /* 0x0004 */ uint doYuvToRgbConversionOnly;
+ /* 0x0008 */ int8_t tint_pad[8];
/* 0x0010 */ float3x4 yuvToRgbConversionMatrix;
/* 0x0040 */ GammaTransferParams gammaDecodeParams;
/* 0x0060 */ GammaTransferParams gammaEncodeParams;
@@ -35,9 +36,11 @@
} 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 = gammaCorrection(color, params.gammaDecodeParams);
- color = (params.gamutConversionMatrix * color);
- color = gammaCorrection(color, params.gammaEncodeParams);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return float4(color, 1.0f);
}
diff --git a/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.spvasm b/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.spvasm
index 69123b5..ad6d2a9 100644
--- a/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.spvasm
+++ b/test/tint/builtins/gen/var/textureSampleLevel/979816.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 138
+; Bound: 143
; Schema: 0
OpCapability Shader
%30 = OpExtInstImport "GLSL.std.450"
@@ -16,8 +16,9 @@
OpName %ext_tex_plane_1 "ext_tex_plane_1"
OpName %ExternalTextureParams "ExternalTextureParams"
OpMemberName %ExternalTextureParams 0 "numPlanes"
- OpMemberName %ExternalTextureParams 1 "yuvToRgbConversionMatrix"
- OpMemberName %ExternalTextureParams 2 "gammaDecodeParams"
+ OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly"
+ OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix"
+ OpMemberName %ExternalTextureParams 3 "gammaDecodeParams"
OpName %GammaTransferParams "GammaTransferParams"
OpMemberName %GammaTransferParams 0 "G"
OpMemberName %GammaTransferParams 1 "A"
@@ -27,8 +28,8 @@
OpMemberName %GammaTransferParams 5 "E"
OpMemberName %GammaTransferParams 6 "F"
OpMemberName %GammaTransferParams 7 "padding"
- OpMemberName %ExternalTextureParams 3 "gammaEncodeParams"
- OpMemberName %ExternalTextureParams 4 "gamutConversionMatrix"
+ OpMemberName %ExternalTextureParams 4 "gammaEncodeParams"
+ OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix"
OpName %ext_tex_params "ext_tex_params"
OpName %arg_0 "arg_0"
OpName %arg_1 "arg_1"
@@ -55,10 +56,11 @@
OpDecorate %ext_tex_plane_1 Binding 2
OpDecorate %ExternalTextureParams Block
OpMemberDecorate %ExternalTextureParams 0 Offset 0
- OpMemberDecorate %ExternalTextureParams 1 Offset 16
- OpMemberDecorate %ExternalTextureParams 1 ColMajor
- OpMemberDecorate %ExternalTextureParams 1 MatrixStride 16
- OpMemberDecorate %ExternalTextureParams 2 Offset 64
+ OpMemberDecorate %ExternalTextureParams 1 Offset 4
+ OpMemberDecorate %ExternalTextureParams 2 Offset 16
+ OpMemberDecorate %ExternalTextureParams 2 ColMajor
+ OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16
+ OpMemberDecorate %ExternalTextureParams 3 Offset 64
OpMemberDecorate %GammaTransferParams 0 Offset 0
OpMemberDecorate %GammaTransferParams 1 Offset 4
OpMemberDecorate %GammaTransferParams 2 Offset 8
@@ -67,10 +69,10 @@
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
+ OpMemberDecorate %ExternalTextureParams 4 Offset 96
+ OpMemberDecorate %ExternalTextureParams 5 Offset 128
+ OpMemberDecorate %ExternalTextureParams 5 ColMajor
+ OpMemberDecorate %ExternalTextureParams 5 MatrixStride 16
OpDecorate %ext_tex_params NonWritable
OpDecorate %ext_tex_params DescriptorSet 1
OpDecorate %ext_tex_params Binding 3
@@ -94,7 +96,7 @@
%GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
%v3float = OpTypeVector %float 3
%mat3v3float = OpTypeMatrix %v3float 3
-%ExternalTextureParams = OpTypeStruct %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
+%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams
%ext_tex_params = OpVariable %_ptr_Uniform_ExternalTextureParams Uniform
%arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant
@@ -111,12 +113,13 @@
%uint_1 = OpConstant %uint 1
%81 = OpTypeSampledImage %11
%float_1 = OpConstant %float 1
+ %97 = OpConstantNull %uint
%void = OpTypeVoid
- %110 = OpTypeFunction %void
- %114 = OpConstantNull %v2float
+ %115 = OpTypeFunction %void
+ %119 = OpConstantNull %v2float
%_ptr_Function_v2float = OpTypePointer Function %v2float
%_ptr_Function_v4float = OpTypePointer Function %v4float
- %125 = OpTypeFunction %v4float
+ %130 = OpTypeFunction %v4float
%gammaCorrection = OpFunction %v3float None %24
%v = OpFunctionParameter %v3float
%params = OpFunctionParameter %GammaTransferParams
@@ -181,63 +184,70 @@
%90 = OpCompositeExtract %float %89 0
%91 = OpCompositeExtract %float %89 1
%93 = OpCompositeConstruct %v4float %86 %90 %91 %float_1
- %94 = OpCompositeExtract %mat3v4float %params_0 1
+ %94 = OpCompositeExtract %mat3v4float %params_0 2
%95 = OpVectorTimesMatrix %v3float %93 %94
OpStore %color %95
OpBranch %77
%77 = OpLabel
- %97 = OpLoad %v3float %color
- %98 = OpCompositeExtract %GammaTransferParams %params_0 2
- %96 = OpFunctionCall %v3float %gammaCorrection %97 %98
- OpStore %color %96
- %99 = OpCompositeExtract %mat3v3float %params_0 4
- %100 = OpLoad %v3float %color
- %101 = OpMatrixTimesVector %v3float %99 %100
+ %96 = OpCompositeExtract %uint %params_0 1
+ %98 = OpIEqual %bool %96 %97
+ OpSelectionMerge %99 None
+ OpBranchConditional %98 %100 %99
+ %100 = OpLabel
+ %102 = OpLoad %v3float %color
+ %103 = OpCompositeExtract %GammaTransferParams %params_0 3
+ %101 = OpFunctionCall %v3float %gammaCorrection %102 %103
OpStore %color %101
- %103 = OpLoad %v3float %color
- %104 = OpCompositeExtract %GammaTransferParams %params_0 3
- %102 = OpFunctionCall %v3float %gammaCorrection %103 %104
- OpStore %color %102
+ %104 = OpCompositeExtract %mat3v3float %params_0 5
%105 = OpLoad %v3float %color
- %106 = OpCompositeExtract %float %105 0
- %107 = OpCompositeExtract %float %105 1
- %108 = OpCompositeExtract %float %105 2
- %109 = OpCompositeConstruct %v4float %106 %107 %108 %float_1
- OpReturnValue %109
+ %106 = OpMatrixTimesVector %v3float %104 %105
+ OpStore %color %106
+ %108 = OpLoad %v3float %color
+ %109 = OpCompositeExtract %GammaTransferParams %params_0 4
+ %107 = OpFunctionCall %v3float %gammaCorrection %108 %109
+ OpStore %color %107
+ OpBranch %99
+ %99 = OpLabel
+ %110 = OpLoad %v3float %color
+ %111 = OpCompositeExtract %float %110 0
+ %112 = OpCompositeExtract %float %110 1
+ %113 = OpCompositeExtract %float %110 2
+ %114 = OpCompositeConstruct %v4float %111 %112 %113 %float_1
+ OpReturnValue %114
OpFunctionEnd
-%textureSampleLevel_979816 = OpFunction %void None %110
- %113 = OpLabel
- %arg_2 = OpVariable %_ptr_Function_v2float Function %114
+%textureSampleLevel_979816 = OpFunction %void None %115
+ %118 = OpLabel
+ %arg_2 = OpVariable %_ptr_Function_v2float Function %119
%res = OpVariable %_ptr_Function_v4float Function %5
- OpStore %arg_2 %114
- %118 = OpLoad %11 %arg_0
- %119 = OpLoad %11 %ext_tex_plane_1
- %120 = OpLoad %23 %arg_1
- %121 = OpLoad %v2float %arg_2
- %122 = OpLoad %ExternalTextureParams %ext_tex_params
- %117 = OpFunctionCall %v4float %textureSampleExternal %118 %119 %120 %121 %122
- OpStore %res %117
+ OpStore %arg_2 %119
+ %123 = OpLoad %11 %arg_0
+ %124 = OpLoad %11 %ext_tex_plane_1
+ %125 = OpLoad %23 %arg_1
+ %126 = OpLoad %v2float %arg_2
+ %127 = OpLoad %ExternalTextureParams %ext_tex_params
+ %122 = OpFunctionCall %v4float %textureSampleExternal %123 %124 %125 %126 %127
+ OpStore %res %122
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %125
- %127 = OpLabel
- %128 = OpFunctionCall %void %textureSampleLevel_979816
+%vertex_main_inner = OpFunction %v4float None %130
+ %132 = OpLabel
+ %133 = OpFunctionCall %void %textureSampleLevel_979816
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %110
- %130 = OpLabel
- %131 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %131
+%vertex_main = OpFunction %void None %115
+ %135 = OpLabel
+ %136 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %136
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %110
- %133 = OpLabel
- %134 = OpFunctionCall %void %textureSampleLevel_979816
+%fragment_main = OpFunction %void None %115
+ %138 = OpLabel
+ %139 = OpFunctionCall %void %textureSampleLevel_979816
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %110
- %136 = OpLabel
- %137 = OpFunctionCall %void %textureSampleLevel_979816
+%compute_main = OpFunction %void None %115
+ %141 = OpLabel
+ %142 = OpFunctionCall %void %textureSampleLevel_979816
OpReturn
OpFunctionEnd
diff --git a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.hlsl b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.hlsl
index b933cd1..b2f84d9 100644
--- a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.hlsl
+++ b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.hlsl
@@ -10,6 +10,7 @@
};
struct ExternalTextureParams {
uint numPlanes;
+ uint doYuvToRgbConversionOnly;
float3x4 yuvToRgbConversionMatrix;
GammaTransferParams gammaDecodeParams;
GammaTransferParams gammaEncodeParams;
@@ -36,9 +37,11 @@
} else {
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);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = mul(color, params.gamutConversionMatrix);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return float4(color, 1.0f);
}
@@ -75,7 +78,8 @@
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))};
+ const uint scalar_offset_15 = ((offset + 4u)) / 4;
+ const ExternalTextureParams tint_symbol_11 = {buffer[scalar_offset_14 / 4][scalar_offset_14 % 4], buffer[scalar_offset_15 / 4][scalar_offset_15 % 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;
}
diff --git a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.msl b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.msl
index 6089993..a7d71cc 100644
--- a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.msl
+++ b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.msl
@@ -14,7 +14,8 @@
struct ExternalTextureParams {
/* 0x0000 */ uint numPlanes;
- /* 0x0004 */ int8_t tint_pad[12];
+ /* 0x0004 */ uint doYuvToRgbConversionOnly;
+ /* 0x0008 */ int8_t tint_pad[8];
/* 0x0010 */ float3x4 yuvToRgbConversionMatrix;
/* 0x0040 */ GammaTransferParams gammaDecodeParams;
/* 0x0060 */ GammaTransferParams gammaEncodeParams;
@@ -35,9 +36,11 @@
} else {
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);
+ if ((params.doYuvToRgbConversionOnly == 0u)) {
+ color = gammaCorrection(color, params.gammaDecodeParams);
+ color = (params.gamutConversionMatrix * color);
+ color = gammaCorrection(color, params.gammaEncodeParams);
+ }
return float4(color, 1.0f);
}
diff --git a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.spvasm b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.spvasm
index 52b2ea9..a894d4c 100644
--- a/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.spvasm
+++ b/test/tint/builtins/textureLoad/texture_external_param.wgsl.expected.spvasm
@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
-; Bound: 137
+; Bound: 142
; Schema: 0
OpCapability Shader
%27 = OpExtInstImport "GLSL.std.450"
@@ -16,8 +16,9 @@
OpName %ext_tex_plane_1 "ext_tex_plane_1"
OpName %ExternalTextureParams "ExternalTextureParams"
OpMemberName %ExternalTextureParams 0 "numPlanes"
- OpMemberName %ExternalTextureParams 1 "yuvToRgbConversionMatrix"
- OpMemberName %ExternalTextureParams 2 "gammaDecodeParams"
+ OpMemberName %ExternalTextureParams 1 "doYuvToRgbConversionOnly"
+ OpMemberName %ExternalTextureParams 2 "yuvToRgbConversionMatrix"
+ OpMemberName %ExternalTextureParams 3 "gammaDecodeParams"
OpName %GammaTransferParams "GammaTransferParams"
OpMemberName %GammaTransferParams 0 "G"
OpMemberName %GammaTransferParams 1 "A"
@@ -27,8 +28,8 @@
OpMemberName %GammaTransferParams 5 "E"
OpMemberName %GammaTransferParams 6 "F"
OpMemberName %GammaTransferParams 7 "padding"
- OpMemberName %ExternalTextureParams 3 "gammaEncodeParams"
- OpMemberName %ExternalTextureParams 4 "gamutConversionMatrix"
+ OpMemberName %ExternalTextureParams 4 "gammaEncodeParams"
+ OpMemberName %ExternalTextureParams 5 "gamutConversionMatrix"
OpName %ext_tex_params "ext_tex_params"
OpName %arg_0 "arg_0"
OpName %gammaCorrection "gammaCorrection"
@@ -57,10 +58,11 @@
OpDecorate %ext_tex_plane_1 Binding 1
OpDecorate %ExternalTextureParams Block
OpMemberDecorate %ExternalTextureParams 0 Offset 0
- OpMemberDecorate %ExternalTextureParams 1 Offset 16
- OpMemberDecorate %ExternalTextureParams 1 ColMajor
- OpMemberDecorate %ExternalTextureParams 1 MatrixStride 16
- OpMemberDecorate %ExternalTextureParams 2 Offset 64
+ OpMemberDecorate %ExternalTextureParams 1 Offset 4
+ OpMemberDecorate %ExternalTextureParams 2 Offset 16
+ OpMemberDecorate %ExternalTextureParams 2 ColMajor
+ OpMemberDecorate %ExternalTextureParams 2 MatrixStride 16
+ OpMemberDecorate %ExternalTextureParams 3 Offset 64
OpMemberDecorate %GammaTransferParams 0 Offset 0
OpMemberDecorate %GammaTransferParams 1 Offset 4
OpMemberDecorate %GammaTransferParams 2 Offset 8
@@ -69,10 +71,10 @@
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
+ OpMemberDecorate %ExternalTextureParams 4 Offset 96
+ OpMemberDecorate %ExternalTextureParams 5 Offset 128
+ OpMemberDecorate %ExternalTextureParams 5 ColMajor
+ OpMemberDecorate %ExternalTextureParams 5 MatrixStride 16
OpDecorate %ext_tex_params NonWritable
OpDecorate %ext_tex_params DescriptorSet 1
OpDecorate %ext_tex_params Binding 2
@@ -94,7 +96,7 @@
%GammaTransferParams = OpTypeStruct %float %float %float %float %float %float %float %uint
%v3float = OpTypeVector %float 3
%mat3v3float = OpTypeMatrix %v3float 3
-%ExternalTextureParams = OpTypeStruct %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
+%ExternalTextureParams = OpTypeStruct %uint %uint %mat3v4float %GammaTransferParams %GammaTransferParams %mat3v3float
%_ptr_Uniform_ExternalTextureParams = OpTypePointer Uniform %ExternalTextureParams
%ext_tex_params = OpVariable %_ptr_Uniform_ExternalTextureParams Uniform
%arg_0 = OpVariable %_ptr_UniformConstant_11 UniformConstant
@@ -110,12 +112,13 @@
%78 = OpConstantNull %int
%v2float = OpTypeVector %float 2
%float_1 = OpConstant %float 1
- %105 = OpTypeFunction %v4float %11 %11 %ExternalTextureParams %v2int
+ %92 = OpConstantNull %uint
+ %110 = OpTypeFunction %v4float %11 %11 %ExternalTextureParams %v2int
%void = OpTypeVoid
- %113 = OpTypeFunction %void
- %121 = OpConstantNull %v2int
+ %118 = OpTypeFunction %void
+ %126 = OpConstantNull %v2int
%_ptr_Function_v4float = OpTypePointer Function %v4float
- %124 = OpTypeFunction %v4float
+ %129 = OpTypeFunction %v4float
%gammaCorrection = OpFunction %v3float None %21
%v = OpFunctionParameter %v3float
%params = OpFunctionParameter %GammaTransferParams
@@ -176,68 +179,75 @@
%85 = OpCompositeExtract %float %84 0
%86 = OpCompositeExtract %float %84 1
%88 = OpCompositeConstruct %v4float %81 %85 %86 %float_1
- %89 = OpCompositeExtract %mat3v4float %params_0 1
+ %89 = OpCompositeExtract %mat3v4float %params_0 2
%90 = OpVectorTimesMatrix %v3float %88 %89
OpStore %color %90
OpBranch %74
%74 = OpLabel
- %92 = OpLoad %v3float %color
- %93 = OpCompositeExtract %GammaTransferParams %params_0 2
- %91 = OpFunctionCall %v3float %gammaCorrection %92 %93
- OpStore %color %91
- %94 = OpCompositeExtract %mat3v3float %params_0 4
- %95 = OpLoad %v3float %color
- %96 = OpMatrixTimesVector %v3float %94 %95
+ %91 = OpCompositeExtract %uint %params_0 1
+ %93 = OpIEqual %bool %91 %92
+ OpSelectionMerge %94 None
+ OpBranchConditional %93 %95 %94
+ %95 = OpLabel
+ %97 = OpLoad %v3float %color
+ %98 = OpCompositeExtract %GammaTransferParams %params_0 3
+ %96 = OpFunctionCall %v3float %gammaCorrection %97 %98
OpStore %color %96
- %98 = OpLoad %v3float %color
- %99 = OpCompositeExtract %GammaTransferParams %params_0 3
- %97 = OpFunctionCall %v3float %gammaCorrection %98 %99
- OpStore %color %97
+ %99 = OpCompositeExtract %mat3v3float %params_0 5
%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
+ %101 = OpMatrixTimesVector %v3float %99 %100
+ OpStore %color %101
+ %103 = OpLoad %v3float %color
+ %104 = OpCompositeExtract %GammaTransferParams %params_0 4
+ %102 = OpFunctionCall %v3float %gammaCorrection %103 %104
+ OpStore %color %102
+ OpBranch %94
+ %94 = OpLabel
+ %105 = OpLoad %v3float %color
+ %106 = OpCompositeExtract %float %105 0
+ %107 = OpCompositeExtract %float %105 1
+ %108 = OpCompositeExtract %float %105 2
+ %109 = OpCompositeConstruct %v4float %106 %107 %108 %float_1
+ OpReturnValue %109
OpFunctionEnd
-%textureLoad2d = OpFunction %v4float None %105
+%textureLoad2d = OpFunction %v4float None %110
%texture = OpFunctionParameter %11
%ext_tex_plane_1_1 = OpFunctionParameter %11
%ext_tex_params_1 = OpFunctionParameter %ExternalTextureParams
%coords = OpFunctionParameter %v2int
- %111 = OpLabel
- %112 = OpFunctionCall %v4float %textureLoadExternal %texture %ext_tex_plane_1_1 %coords %ext_tex_params_1
- OpReturnValue %112
- OpFunctionEnd
-%doTextureLoad = OpFunction %void None %113
%116 = OpLabel
+ %117 = OpFunctionCall %v4float %textureLoadExternal %texture %ext_tex_plane_1_1 %coords %ext_tex_params_1
+ OpReturnValue %117
+ OpFunctionEnd
+%doTextureLoad = OpFunction %void None %118
+ %121 = OpLabel
%res = OpVariable %_ptr_Function_v4float Function %5
- %118 = OpLoad %11 %arg_0
- %119 = OpLoad %11 %ext_tex_plane_1
- %120 = OpLoad %ExternalTextureParams %ext_tex_params
- %117 = OpFunctionCall %v4float %textureLoad2d %118 %119 %120 %121
- OpStore %res %117
+ %123 = OpLoad %11 %arg_0
+ %124 = OpLoad %11 %ext_tex_plane_1
+ %125 = OpLoad %ExternalTextureParams %ext_tex_params
+ %122 = OpFunctionCall %v4float %textureLoad2d %123 %124 %125 %126
+ OpStore %res %122
OpReturn
OpFunctionEnd
-%vertex_main_inner = OpFunction %v4float None %124
- %126 = OpLabel
- %127 = OpFunctionCall %void %doTextureLoad
+%vertex_main_inner = OpFunction %v4float None %129
+ %131 = OpLabel
+ %132 = OpFunctionCall %void %doTextureLoad
OpReturnValue %5
OpFunctionEnd
-%vertex_main = OpFunction %void None %113
- %129 = OpLabel
- %130 = OpFunctionCall %v4float %vertex_main_inner
- OpStore %value %130
+%vertex_main = OpFunction %void None %118
+ %134 = OpLabel
+ %135 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %135
OpStore %vertex_point_size %float_1
OpReturn
OpFunctionEnd
-%fragment_main = OpFunction %void None %113
- %132 = OpLabel
- %133 = OpFunctionCall %void %doTextureLoad
+%fragment_main = OpFunction %void None %118
+ %137 = OpLabel
+ %138 = OpFunctionCall %void %doTextureLoad
OpReturn
OpFunctionEnd
-%compute_main = OpFunction %void None %113
- %135 = OpLabel
- %136 = OpFunctionCall %void %doTextureLoad
+%compute_main = OpFunction %void None %118
+ %140 = OpLabel
+ %141 = OpFunctionCall %void %doTextureLoad
OpReturn
OpFunctionEnd