MCPcopy Create free account
hub / github.com/KhronosGroup/glslang / createRvalueSwizzle

Method createRvalueSwizzle

SPIRV/SpvBuilder.cpp:3632–3652  ·  view source on GitHub ↗

Comments in header

Source from the content-addressed store, hash-verified

3630
3631// Comments in header
3632Id 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
3655Id Builder::createLvalueSwizzle(Id typeId, Id target, Id source, const std::vector<unsigned>& channels)

Callers 1

createInvertedSwizzleMethod · 0.80

Calls 5

reserveOperandsMethod · 0.80
addIdOperandMethod · 0.80
addImmediateOperandMethod · 0.80
getResultIdMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected