From a738fb5d585ab18ad93ee16cfc97e00dc7474f13 Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Thu, 14 Jan 2021 12:11:48 -0600 Subject: [PATCH] restore select() in bool->int Change-Id: Ia3ac338bef376aa1649569b9ebd3f7feb23ffd52 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/353936 Reviewed-by: Brian Osman Reviewed-by: John Stiles Commit-Queue: Mike Klein --- src/sksl/SkSLVMGenerator.cpp | 2 +- tests/sksl/runtime/golden/ConversionConstructors.skvm | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sksl/SkSLVMGenerator.cpp b/src/sksl/SkSLVMGenerator.cpp index 7d5072f9dc..bca880671f 100644 --- a/src/sksl/SkSLVMGenerator.cpp +++ b/src/sksl/SkSLVMGenerator.cpp @@ -749,7 +749,7 @@ Value SkVMGenerator::writeConstructor(const Constructor& c) { } else if (srcKind == Type::NumberKind::kBoolean) { // bool -> int for (size_t i = 0; i < src.slots(); ++i) { - dst[i] = i32(src[i]) & 1; + dst[i] = skvm::select(i32(src[i]), 1, 0); } return dst; } diff --git a/tests/sksl/runtime/golden/ConversionConstructors.skvm b/tests/sksl/runtime/golden/ConversionConstructors.skvm index 66bde1b67d..fe63b55a47 100644 --- a/tests/sksl/runtime/golden/ConversionConstructors.skvm +++ b/tests/sksl/runtime/golden/ConversionConstructors.skvm @@ -12,9 +12,9 @@ 10 r3 = eq_i32 r1 r3 11 r3 = bit_xor r4 r3 12 r4 = splat 1 (1.4012985e-45) -13 r4 = bit_and r2 r4 +13 r2 = bit_and r4 r2 14 r0 = trunc r0 -15 r0 = select r3 r4 r0 +15 r0 = select r3 r2 r0 16 r0 = to_f32 r0 17 r0 = mul_f32 r7 r0 loop: