Comments in header
| 3630 | |
| 3631 | // Comments in header |
| 3632 | Id Builder::createRvalueSwizzle(Decoration precision, Id typeId, Id source, const std::vector<unsigned>& channels) |
| 3633 | { |
| 3634 | if (channels.size() == 1) |
| 3635 | return setPrecision(createCompositeExtract(source, typeId, channels.front()), precision); |
| 3636 | |
| 3637 | if (generatingOpCodeForSpecConst) { |
| 3638 | std::vector<Id> operands(2); |
| 3639 | operands[0] = operands[1] = source; |
| 3640 | return setPrecision(createSpecConstantOp(Op::OpVectorShuffle, typeId, operands, channels), precision); |
| 3641 | } |
| 3642 | Instruction* swizzle = new Instruction(getUniqueId(), typeId, Op::OpVectorShuffle); |
| 3643 | assert(isVector(source)); |
| 3644 | swizzle->reserveOperands(channels.size() + 2); |
| 3645 | swizzle->addIdOperand(source); |
| 3646 | swizzle->addIdOperand(source); |
| 3647 | for (int i = 0; i < (int)channels.size(); ++i) |
| 3648 | swizzle->addImmediateOperand(channels[i]); |
| 3649 | addInstruction(std::unique_ptr<Instruction>(swizzle)); |
| 3650 | |
| 3651 | return setPrecision(swizzle->getResultId(), precision); |
| 3652 | } |
| 3653 | |
| 3654 | // Comments in header |
| 3655 | Id Builder::createLvalueSwizzle(Id typeId, Id target, Id source, const std::vector<unsigned>& channels) |
no test coverage detected