fixed SPIR-V indexing a swizzle
Bug: skia:8543
Change-Id: I5d22de1b84fca9839215fff102dcac4b3a8063f1
Reviewed-on: https://skia-review.googlesource.com/c/181842
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/sksl/SkSLSPIRVCodeGenerator.cpp b/src/sksl/SkSLSPIRVCodeGenerator.cpp
index 4efc1fb..9bc134e 100644
--- a/src/sksl/SkSLSPIRVCodeGenerator.cpp
+++ b/src/sksl/SkSLSPIRVCodeGenerator.cpp
@@ -1499,8 +1499,11 @@
chain.push_back(this->writeIntLiteral(index));
break;
}
- default:
- chain.push_back(this->getLValue(expr, out)->getPointer());
+ default: {
+ SpvId id = this->getLValue(expr, out)->getPointer();
+ SkASSERT(id != 0);
+ chain.push_back(id);
+ }
}
return chain;
}
@@ -1792,6 +1795,14 @@
}
SpvId SPIRVCodeGenerator::writeIndexExpression(const IndexExpression& expr, OutputStream& out) {
+ if (expr.fBase->fType.kind() == Type::Kind::kVector_Kind) {
+ SpvId base = this->writeExpression(*expr.fBase, out);
+ SpvId index = this->writeExpression(*expr.fIndex, out);
+ SpvId result = this->nextId();
+ this->writeInstruction(SpvOpVectorExtractDynamic, this->getType(expr.fType), result, base,
+ index, out);
+ return result;
+ }
return getLValue(expr, out)->load(out);
}