tint: fix translation of DP4a on HLSL
This patch adds a workaround on a DXC error in the translation of DP4a
functions that the third parameter "acc" of both dot4add_i8packed() and
dot4add_u8packed() can only be a variable, or a compile error will be
generated.
Bug: tint:1497
Test: tint_unittests
Change-Id: I263d27fb18bd354e0c9110f60cbc98860cf7afe5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/90027
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/tint/writer/hlsl/generator_impl.cc b/src/tint/writer/hlsl/generator_impl.cc
index fb4efb6..b7020f6 100644
--- a/src/tint/writer/hlsl/generator_impl.cc
+++ b/src/tint/writer/hlsl/generator_impl.cc
@@ -2045,9 +2045,11 @@
std::string functionName;
switch (builtin->Type()) {
case sem::BuiltinType::kDot4I8Packed:
+ line(b) << "int accumulator = 0;";
functionName = "dot4add_i8packed";
break;
case sem::BuiltinType::kDot4U8Packed:
+ line(b) << "uint accumulator = 0u;";
functionName = "dot4add_u8packed";
break;
default:
@@ -2056,7 +2058,7 @@
return false;
}
line(b) << "return " << functionName << "(" << params[0] << ", " << params[1]
- << ", 0);";
+ << ", accumulator);";
return true;
});