ByteCode: Avoid using "extended" loads when possible
If the address is known statically, prefer to use multiple fixed loads, so that we can translate these kinds of programs to SkVM. Change-Id: I0e0f126f5a1538fdc54a9c953f67b93a37a500c5 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/297803 Auto-Submit: Brian Osman <brianosman@google.com> Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Mike Klein <mtklein@google.com>
This commit is contained in:
parent
91cc9799fb
commit
02f8b077d5
@ -1020,22 +1020,23 @@ void ByteCodeGenerator::writeVariableExpression(const Expression& expr) {
|
||||
if (count == 0) {
|
||||
return;
|
||||
}
|
||||
if (location.isOnStack() || count > 4) {
|
||||
if (!location.isOnStack()) {
|
||||
this->write(ByteCodeInstruction::kPushImmediate);
|
||||
this->write32(location.fSlot);
|
||||
}
|
||||
if (location.isOnStack()) {
|
||||
this->write(location.selectLoad(ByteCodeInstruction::kLoadExtended,
|
||||
ByteCodeInstruction::kLoadExtendedGlobal,
|
||||
ByteCodeInstruction::kLoadExtendedUniform),
|
||||
count);
|
||||
this->write8(count);
|
||||
} else {
|
||||
this->write(vector_instruction(location.selectLoad(ByteCodeInstruction::kLoad,
|
||||
ByteCodeInstruction::kLoadGlobal,
|
||||
ByteCodeInstruction::kLoadUniform),
|
||||
count));
|
||||
this->write8(location.fSlot);
|
||||
while (count) {
|
||||
int loadCount = std::min(count, 4);
|
||||
this->write(vector_instruction(location.selectLoad(ByteCodeInstruction::kLoad,
|
||||
ByteCodeInstruction::kLoadGlobal,
|
||||
ByteCodeInstruction::kLoadUniform),
|
||||
loadCount));
|
||||
this->write8(location.fSlot);
|
||||
count -= loadCount;
|
||||
location.fSlot += loadCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user