From 0f21c2327ea018becec6948e60104645d3b7df26 Mon Sep 17 00:00:00 2001 From: Ethan Nicholas Date: Mon, 23 Jul 2018 09:25:40 -0400 Subject: fixed a bug with SPIR-V ternaries When both the true and false values are constants, we use OpSelect to choose between them instead of branching. However, it turns out that this fails when the values are vectors, because then OpSelect does componentwise selection and expects the input condition to be a vector as well. Bug: skia: Change-Id: Ia30aadc590ac1d1760c7df933595c2c867c472cd Reviewed-on: https://skia-review.googlesource.com/142885 Reviewed-by: Chris Dalton Commit-Queue: Ethan Nicholas --- src/sksl/SkSLSPIRVCodeGenerator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sksl/SkSLSPIRVCodeGenerator.cpp b/src/sksl/SkSLSPIRVCodeGenerator.cpp index 3357faaa6e..a97a7ceaf9 100644 --- a/src/sksl/SkSLSPIRVCodeGenerator.cpp +++ b/src/sksl/SkSLSPIRVCodeGenerator.cpp @@ -2278,7 +2278,7 @@ SpvId SPIRVCodeGenerator::writeLogicalOr(const BinaryExpression& o, OutputStream SpvId SPIRVCodeGenerator::writeTernaryExpression(const TernaryExpression& t, OutputStream& out) { SpvId test = this->writeExpression(*t.fTest, out); - if (t.fIfTrue->isConstant() && t.fIfFalse->isConstant()) { + if (t.fIfTrue->fType.columns() == 1 && t.fIfTrue->isConstant() && t.fIfFalse->isConstant()) { // both true and false are constants, can just use OpSelect SpvId result = this->nextId(); SpvId trueId = this->writeExpression(*t.fIfTrue, out); -- cgit v1.2.3