SkVM round test

Change-Id: I4226393275a11be3babe21b7f8461767c5b55f23
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274127
Commit-Queue: Herb Derby <herb@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
Herb Derby 2020-02-28 11:59:10 -06:00 committed by Skia Commit-Bot
parent e96207a9e3
commit fb4ff8d6cc

View File

@ -736,6 +736,25 @@ DEF_TEST(SkVM_floor, r) {
});
}
DEF_TEST(SkVM_round, r) {
skvm::Builder b;
{
skvm::Arg src = b.varying<float>();
skvm::Arg dst = b.varying<int>();
b.store32(dst, b.round(b.bit_cast(b.load32(src))));
}
test_jit_and_interpreter(r, b.done(), [&](const skvm::Program& program) {
float buf[] = { 0.0f, 0.2f, 0.6f, 1.0f, 1.4f, 2.0f };
int dst[SK_ARRAY_COUNT(buf)];
int want[] = {0, 0, 1, 1, 1, 2 };
program.eval(SK_ARRAY_COUNT(buf), buf, dst);
for (int i = 0; i < (int)SK_ARRAY_COUNT(dst); i++) {
REPORTER_ASSERT(r, dst[i] == want[i]);
}
});
}
DEF_TEST(SkVM_hoist, r) {
// This program uses enough constants that it will fail to JIT if we hoist them.
// The JIT will try again without hoisting, and that'll just need 2 registers.