Enable _Float16 "half-float" Functionality Only When Available. (flutter/engine#49851)
# Description: We're cross-compiling impeller for Android, but x86 Android targets don't have half float (`_Float16`) _ support. This change disables half float support in `impeller/geometry/half.h` for platforms where the `_Float16` builtin is lacking. As can be seen in `half.h`, `Float16` support is enabled for all non-windows platforms, which doesn't not allow our use case. # Issues I can't seem to find a way to file an issue describing this, but - [] I added new tests to check the change I am making or feature I am adding, or the PR is [test-exempt]. See [testing the engine] for instructions on writing and running engine tests. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
@@ -1773,10 +1773,8 @@ TEST(GeometryTest, Gradient) {
|
||||
}
|
||||
|
||||
TEST(GeometryTest, HalfConversions) {
|
||||
#ifdef FML_OS_WIN
|
||||
GTEST_SKIP() << "Half-precision floats (IEEE 754) are not portable and "
|
||||
"unavailable on Windows.";
|
||||
#else
|
||||
#if defined(FML_OS_MACOSX) || defined(FML_OS_IOS) || \
|
||||
defined(FML_OS_IOS_SIMULATOR)
|
||||
ASSERT_EQ(ScalarToHalf(0.0), 0.0f16);
|
||||
ASSERT_EQ(ScalarToHalf(0.05), 0.05f16);
|
||||
ASSERT_EQ(ScalarToHalf(2.43), 2.43f16);
|
||||
@@ -1803,7 +1801,10 @@ TEST(GeometryTest, HalfConversions) {
|
||||
ASSERT_EQ(Half(0.5f), Half(0.5f16));
|
||||
ASSERT_EQ(Half(0.5), Half(0.5f16));
|
||||
ASSERT_EQ(Half(5), Half(5.0f16));
|
||||
#endif // FML_OS_WIN
|
||||
#else
|
||||
GTEST_SKIP() << "Half-precision floats (IEEE 754) are not portable and "
|
||||
"only used on Apple platforms.";
|
||||
#endif // FML_OS_MACOSX || FML_OS_IOS || FML_OS_IOS_SIMULATOR
|
||||
}
|
||||
|
||||
} // namespace testing
|
||||
|
||||
@@ -16,10 +16,11 @@
|
||||
|
||||
// NOLINTBEGIN(google-explicit-constructor)
|
||||
|
||||
#ifdef FML_OS_WIN
|
||||
using InternalHalf = uint16_t;
|
||||
#else
|
||||
#if defined(FML_OS_MACOSX) || defined(FML_OS_IOS) || \
|
||||
defined(FML_OS_IOS_SIMULATOR)
|
||||
using InternalHalf = _Float16;
|
||||
#else
|
||||
using InternalHalf = uint16_t;
|
||||
#endif
|
||||
|
||||
namespace impeller {
|
||||
|
||||
Reference in New Issue
Block a user