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

Method createConversion

glslang/MachineIndependent/Intermediate.cpp:600–680  ·  view source on GitHub ↗

This is 'mechanism' here, it does any conversion told. It is about basic type, not about shape. The policy comes from the shader or the calling code.

Source from the content-addressed store, hash-verified

598// It is about basic type, not about shape.
599// The policy comes from the shader or the calling code.
600TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped* node) const
601{
602 //
603 // Add a new newNode for the conversion.
604 //
605
606 bool convertToIntTypes = (convertTo == EbtInt8 || convertTo == EbtUint8 ||
607 convertTo == EbtInt16 || convertTo == EbtUint16 ||
608 convertTo == EbtInt || convertTo == EbtUint ||
609 convertTo == EbtInt64 || convertTo == EbtUint64);
610
611 bool convertFromIntTypes = (node->getBasicType() == EbtInt8 || node->getBasicType() == EbtUint8 ||
612 node->getBasicType() == EbtInt16 || node->getBasicType() == EbtUint16 ||
613 node->getBasicType() == EbtInt || node->getBasicType() == EbtUint ||
614 node->getBasicType() == EbtInt64 || node->getBasicType() == EbtUint64);
615
616 bool convertToFloatTypes = (convertTo == EbtFloat16 || convertTo == EbtBFloat16 || convertTo == EbtFloat || convertTo == EbtDouble ||
617 convertTo == EbtFloatE5M2 || convertTo == EbtFloatE4M3);
618
619 bool convertFromFloatTypes = (node->getBasicType() == EbtFloat16 ||
620 node->getBasicType() == EbtBFloat16 ||
621 node->getBasicType() == EbtFloat ||
622 node->getBasicType() == EbtDouble ||
623 node->getBasicType() == EbtFloatE5M2 ||
624 node->getBasicType() == EbtFloatE4M3);
625
626 if (((convertTo == EbtInt8 || convertTo == EbtUint8) && ! convertFromIntTypes) ||
627 ((node->getBasicType() == EbtInt8 || node->getBasicType() == EbtUint8) && ! convertToIntTypes)) {
628 if (! getArithemeticInt8Enabled()) {
629 return nullptr;
630 }
631 }
632
633 if (((convertTo == EbtInt16 || convertTo == EbtUint16) && ! convertFromIntTypes) ||
634 ((node->getBasicType() == EbtInt16 || node->getBasicType() == EbtUint16) && ! convertToIntTypes)) {
635 if (! getArithemeticInt16Enabled()) {
636 return nullptr;
637 }
638 }
639
640 if ((convertTo == EbtFloat16 && ! convertFromFloatTypes) ||
641 (node->getBasicType() == EbtFloat16 && ! convertToFloatTypes)) {
642 if (! getArithemeticFloat16Enabled()) {
643 return nullptr;
644 }
645 }
646
647 TIntermUnary* newNode = nullptr;
648 TOperator newOp = EOpNull;
649 if (!buildConvertOp(convertTo, node->getBasicType(), newOp)) {
650 return nullptr;
651 }
652
653 TType newType(convertTo, EvqTemporary, node->getVectorSize(), node->getMatrixCols(), node->getMatrixRows());
654 if (node->getType().isLongVector()) {
655 newType.shallowCopy(node->getType());
656 newType.setBasicType(convertTo);
657 newType.makeTemporary();

Callers 1

constructBuiltInMethod · 0.45

Calls 14

getTypeMethod · 0.80
shallowCopyMethod · 0.80
foldMethod · 0.80
makeSpecConstantMethod · 0.80
getBasicTypeMethod · 0.45
getVectorSizeMethod · 0.45
getMatrixColsMethod · 0.45
getMatrixRowsMethod · 0.45
isLongVectorMethod · 0.45
setBasicTypeMethod · 0.45
makeTemporaryMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected