transform/VertexPulling: Implement remaining work

Implement missing formats.
Implement vector width conversions.
Implement unaligned loads.

Bug: dawn:805
Change-Id: I89724b3027c637c99999c8ecdbf0d8ca4f571afc
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56062
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Ben Clayton
2021-06-29 12:37:45 +00:00
committed by Tint LUCI CQ
parent f2ec7f38e5
commit d960328f07
7 changed files with 1293 additions and 230 deletions

View File

@@ -17,6 +17,7 @@
#include <sstream>
#include <string>
#include <type_traits>
namespace tint {
namespace utils {
@@ -38,6 +39,18 @@ inline bool IsPowerOfTwo(T value) {
return (value & (value - 1)) == 0;
}
/// @param value the input value
/// @returns the largest power of two that `value` is a multiple of
template <typename T>
inline std::enable_if_t<std::is_unsigned<T>::value, T> MaxAlignOf(T value) {
T pot = 1;
while (value && ((value & 1u) == 0)) {
pot <<= 1;
value >>= 1;
}
return pot;
}
} // namespace utils
} // namespace tint

View File

@@ -58,6 +58,26 @@ TEST(MathTests, IsPowerOfTwo) {
EXPECT_EQ(IsPowerOfTwo(9), false);
}
TEST(MathTests, MaxAlignOf) {
EXPECT_EQ(MaxAlignOf(0u), 1u);
EXPECT_EQ(MaxAlignOf(1u), 1u);
EXPECT_EQ(MaxAlignOf(2u), 2u);
EXPECT_EQ(MaxAlignOf(3u), 1u);
EXPECT_EQ(MaxAlignOf(4u), 4u);
EXPECT_EQ(MaxAlignOf(5u), 1u);
EXPECT_EQ(MaxAlignOf(6u), 2u);
EXPECT_EQ(MaxAlignOf(7u), 1u);
EXPECT_EQ(MaxAlignOf(8u), 8u);
EXPECT_EQ(MaxAlignOf(9u), 1u);
EXPECT_EQ(MaxAlignOf(10u), 2u);
EXPECT_EQ(MaxAlignOf(11u), 1u);
EXPECT_EQ(MaxAlignOf(12u), 4u);
EXPECT_EQ(MaxAlignOf(13u), 1u);
EXPECT_EQ(MaxAlignOf(14u), 2u);
EXPECT_EQ(MaxAlignOf(15u), 1u);
EXPECT_EQ(MaxAlignOf(16u), 16u);
}
} // namespace
} // namespace utils
} // namespace tint