mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-10 14:08:04 +00:00
tint/hlsl: don't use min16float to implement quantizeToF16
min16float is not required to convert its input to an 16-bit float. Instead, use f32tof16, and f16tof32. This is also required to be able to enable the IEEE strictness option on FXC, otherwise FXC emits an error X4028: expression has a minimum precision type and cannot be marked precise Bug: tint:1887 Change-Id: I2268c9336b8e873b36e6532984838054fe4dedbd Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/125920 Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
73f2405304
commit
51249b83e6
@@ -2106,12 +2106,13 @@ bool GeneratorImpl::EmitSignCall(utils::StringStream& out,
|
||||
bool GeneratorImpl::EmitQuantizeToF16Call(utils::StringStream& out,
|
||||
const ast::CallExpression* expr,
|
||||
const sem::Builtin* builtin) {
|
||||
// Emulate by casting to min16float and back again.
|
||||
// Cast to f16 and back
|
||||
std::string width;
|
||||
if (auto* vec = builtin->ReturnType()->As<type::Vector>()) {
|
||||
width = std::to_string(vec->Width());
|
||||
}
|
||||
out << "float" << width << "(min16float" << width << "(";
|
||||
out << "f16tof32(f32tof16"
|
||||
<< "(";
|
||||
if (!EmitExpression(out, expr->args[0])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ TEST_F(HlslGeneratorImplTest_Import, HlslImportData_QuantizeToF16_Scalar) {
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
|
||||
EXPECT_EQ(out.str(), std::string("float(min16float(v))"));
|
||||
EXPECT_EQ(out.str(), std::string("f16tof32(f32tof16(v))"));
|
||||
}
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Import, HlslImportData_QuantizeToF16_Vector) {
|
||||
@@ -288,7 +288,7 @@ TEST_F(HlslGeneratorImplTest_Import, HlslImportData_QuantizeToF16_Vector) {
|
||||
|
||||
utils::StringStream out;
|
||||
ASSERT_TRUE(gen.EmitCall(out, expr)) << gen.error();
|
||||
EXPECT_EQ(out.str(), std::string("float3(min16float3(v))"));
|
||||
EXPECT_EQ(out.str(), std::string("f16tof32(f32tof16(v))"));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user