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>
This commit is contained in:
parent
5a951cd6c7
commit
1c75921db9
|
@ -2045,9 +2045,11 @@ bool GeneratorImpl::EmitDP4aCall(std::ostream& out,
|
|||
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 @@ bool GeneratorImpl::EmitDP4aCall(std::ostream& out,
|
|||
return false;
|
||||
}
|
||||
line(b) << "return " << functionName << "(" << params[0] << ", " << params[1]
|
||||
<< ", 0);";
|
||||
<< ", accumulator);";
|
||||
|
||||
return true;
|
||||
});
|
||||
|
|
|
@ -741,7 +741,8 @@ TEST_F(HlslGeneratorImplTest_Builtin, Dot4I8Packed) {
|
|||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
EXPECT_EQ(gen.result(), R"(int tint_dot4I8Packed(uint param_0, uint param_1) {
|
||||
return dot4add_i8packed(param_0, param_1, 0);
|
||||
int accumulator = 0;
|
||||
return dot4add_i8packed(param_0, param_1, accumulator);
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
|
@ -769,7 +770,8 @@ TEST_F(HlslGeneratorImplTest_Builtin, Dot4U8Packed) {
|
|||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
EXPECT_EQ(gen.result(), R"(uint tint_dot4U8Packed(uint param_0, uint param_1) {
|
||||
return dot4add_u8packed(param_0, param_1, 0);
|
||||
uint accumulator = 0u;
|
||||
return dot4add_u8packed(param_0, param_1, accumulator);
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
|
|
Loading…
Reference in New Issue