Remove swizzling-load instructions from SkSL ByteCode
These were peephole optimizations that help the interpreter a bit, but
I'd like to favor code size and ease of translation to SkVM now.
We can now run: sample(child, p.yx) on the CPU backend, for example.
Change-Id: I90f2f649d95d5c4c50e470988590491e3b56ba34
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/297465
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
diff --git a/src/sksl/SkSLByteCodeGenerator.cpp b/src/sksl/SkSLByteCodeGenerator.cpp
index b05fe2b..7983e7e 100644
--- a/src/sksl/SkSLByteCodeGenerator.cpp
+++ b/src/sksl/SkSLByteCodeGenerator.cpp
@@ -364,9 +364,6 @@
return 4;
case ByteCodeInstruction::kDupN:
- case ByteCodeInstruction::kLoadSwizzle:
- case ByteCodeInstruction::kLoadSwizzleGlobal:
- case ByteCodeInstruction::kLoadSwizzleUniform:
return count;
// Pushes 'count' values, minus one for the 'address' that's consumed first
@@ -1428,29 +1425,12 @@
return;
}
- switch (s.fBase->fKind) {
- case Expression::kVariableReference_Kind: {
- Location location = this->getLocation(*s.fBase);
- this->write(location.selectLoad(ByteCodeInstruction::kLoadSwizzle,
- ByteCodeInstruction::kLoadSwizzleGlobal,
- ByteCodeInstruction::kLoadSwizzleUniform),
- s.fComponents.size());
- this->write8(location.fSlot);
- this->write8(s.fComponents.size());
- for (int c : s.fComponents) {
- this->write8(c);
- }
- break;
- }
- default:
- this->writeExpression(*s.fBase);
- this->write(ByteCodeInstruction::kSwizzle,
- s.fComponents.size() - s.fBase->fType.columns());
- this->write8(s.fBase->fType.columns());
- this->write8(s.fComponents.size());
- for (int c : s.fComponents) {
- this->write8(c);
- }
+ this->writeExpression(*s.fBase);
+ this->write(ByteCodeInstruction::kSwizzle, s.fComponents.size() - s.fBase->fType.columns());
+ this->write8(s.fBase->fType.columns());
+ this->write8(s.fComponents.size());
+ for (int c : s.fComponents) {
+ this->write8(c);
}
}