Reduce shader complexity for external textures
Do more math on the CPU to avoid per-fragment ALU operations.
Use a mat3x2 instead of mat2x3 to avoid padding.
Fixed: dawn:1614
Change-Id: Ib0e0f7d44ed9aa16eaca712f6553214fad141feb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/116060
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Brandon1 Jones <brandon1.jones@intel.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/transform/multiplanar_external_texture.cc b/src/tint/transform/multiplanar_external_texture.cc
index f8c927b1..f5770fb 100644
--- a/src/tint/transform/multiplanar_external_texture.cc
+++ b/src/tint/transform/multiplanar_external_texture.cc
@@ -263,7 +263,7 @@
b.Member("gammaDecodeParams", b.ty.type_name("GammaTransferParams")),
b.Member("gammaEncodeParams", b.ty.type_name("GammaTransferParams")),
b.Member("gamutConversionMatrix", b.ty.mat3x3<f32>()),
- b.Member("coordTransformationMatrix", b.ty.mat2x3<f32>())};
+ b.Member("coordTransformationMatrix", b.ty.mat3x2<f32>())};
params_struct_sym = b.Symbols().New("ExternalTextureParams");
@@ -316,12 +316,9 @@
const ast::CallExpression* plane_1_call = nullptr;
switch (call_type) {
case sem::BuiltinType::kTextureSampleBaseClampToEdge:
- // TODO(dawn:1614): Change this statement to incorporate the "- 0.5" into the
- // matrix.
- stmts.Push(
- b.Decl(b.Let("modifiedCoords",
- b.Mul(b.vec3<f32>(b.Sub("coord", f32(0.5)), f32(1.0f)),
- b.MemberAccessor("params", "coordTransformationMatrix")))));
+ stmts.Push(b.Decl(b.Let(
+ "modifiedCoords", b.Mul(b.MemberAccessor("params", "coordTransformationMatrix"),
+ b.vec3<f32>("coord", 1_a)))));
stmts.Push(b.Decl(b.Let(
"plane0_dims",