| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkSLSPIRVCodeGenerator.h" | 8 #include "SkSLSPIRVCodeGenerator.h" |
| 9 | 9 |
| 10 #include "string.h" | 10 #include "string.h" |
| (...skipping 2511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2522 SpvId body = this->nextId(); | 2522 SpvId body = this->nextId(); |
| 2523 SpvId next = this->nextId(); | 2523 SpvId next = this->nextId(); |
| 2524 fContinueTarget.push(next); | 2524 fContinueTarget.push(next); |
| 2525 SpvId end = this->nextId(); | 2525 SpvId end = this->nextId(); |
| 2526 fBreakTarget.push(end); | 2526 fBreakTarget.push(end); |
| 2527 this->writeInstruction(SpvOpBranch, header, out); | 2527 this->writeInstruction(SpvOpBranch, header, out); |
| 2528 this->writeLabel(header, out); | 2528 this->writeLabel(header, out); |
| 2529 this->writeInstruction(SpvOpLoopMerge, end, next, SpvLoopControlMaskNone, ou
t); | 2529 this->writeInstruction(SpvOpLoopMerge, end, next, SpvLoopControlMaskNone, ou
t); |
| 2530 this->writeInstruction(SpvOpBranch, start, out); | 2530 this->writeInstruction(SpvOpBranch, start, out); |
| 2531 this->writeLabel(start, out); | 2531 this->writeLabel(start, out); |
| 2532 SpvId test = this->writeExpression(*f.fTest, out); | 2532 if (f.fTest) { |
| 2533 this->writeInstruction(SpvOpBranchConditional, test, body, end, out); | 2533 SpvId test = this->writeExpression(*f.fTest, out); |
| 2534 this->writeInstruction(SpvOpBranchConditional, test, body, end, out); |
| 2535 } |
| 2534 this->writeLabel(body, out); | 2536 this->writeLabel(body, out); |
| 2535 this->writeStatement(*f.fStatement, out); | 2537 this->writeStatement(*f.fStatement, out); |
| 2536 if (fCurrentBlock) { | 2538 if (fCurrentBlock) { |
| 2537 this->writeInstruction(SpvOpBranch, next, out); | 2539 this->writeInstruction(SpvOpBranch, next, out); |
| 2538 } | 2540 } |
| 2539 this->writeLabel(next, out); | 2541 this->writeLabel(next, out); |
| 2540 if (f.fNext) { | 2542 if (f.fNext) { |
| 2541 this->writeExpression(*f.fNext, out); | 2543 this->writeExpression(*f.fNext, out); |
| 2542 } | 2544 } |
| 2543 this->writeInstruction(SpvOpBranch, header, out); | 2545 this->writeInstruction(SpvOpBranch, header, out); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2646 this->writeWord(SpvVersion, out); | 2648 this->writeWord(SpvVersion, out); |
| 2647 this->writeWord(SKSL_MAGIC, out); | 2649 this->writeWord(SKSL_MAGIC, out); |
| 2648 std::stringstream buffer; | 2650 std::stringstream buffer; |
| 2649 this->writeInstructions(program, buffer); | 2651 this->writeInstructions(program, buffer); |
| 2650 this->writeWord(fIdCount, out); | 2652 this->writeWord(fIdCount, out); |
| 2651 this->writeWord(0, out); // reserved, always zero | 2653 this->writeWord(0, out); // reserved, always zero |
| 2652 out << buffer.str(); | 2654 out << buffer.str(); |
| 2653 } | 2655 } |
| 2654 | 2656 |
| 2655 } | 2657 } |
| OLD | NEW |