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.
| 598 | // It is about basic type, not about shape. |
| 599 | // The policy comes from the shader or the calling code. |
| 600 | TIntermTyped* 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(); |
no test coverage detected