|
@@ -562,56 +562,12 @@ bool TIntermediate::isConversionAllowed(TOperator op, TIntermTyped* node) const
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// 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.
|
|
|
|
|
-TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped* node) const
|
|
|
|
|
|
|
+bool TIntermediate::buildConvertOp(TBasicType dst, TBasicType src, TOperator& newOp) const
|
|
|
{
|
|
{
|
|
|
- //
|
|
|
|
|
- // Add a new newNode for the conversion.
|
|
|
|
|
- //
|
|
|
|
|
- TIntermUnary* newNode = nullptr;
|
|
|
|
|
-
|
|
|
|
|
- TOperator newOp = EOpNull;
|
|
|
|
|
-
|
|
|
|
|
- bool convertToIntTypes = (convertTo == EbtInt8 || convertTo == EbtUint8 ||
|
|
|
|
|
- convertTo == EbtInt16 || convertTo == EbtUint16 ||
|
|
|
|
|
- convertTo == EbtInt || convertTo == EbtUint ||
|
|
|
|
|
- convertTo == EbtInt64 || convertTo == EbtUint64);
|
|
|
|
|
-
|
|
|
|
|
- bool convertFromIntTypes = (node->getBasicType() == EbtInt8 || node->getBasicType() == EbtUint8 ||
|
|
|
|
|
- node->getBasicType() == EbtInt16 || node->getBasicType() == EbtUint16 ||
|
|
|
|
|
- node->getBasicType() == EbtInt || node->getBasicType() == EbtUint ||
|
|
|
|
|
- node->getBasicType() == EbtInt64 || node->getBasicType() == EbtUint64);
|
|
|
|
|
-
|
|
|
|
|
- bool convertToFloatTypes = (convertTo == EbtFloat16 || convertTo == EbtFloat || convertTo == EbtDouble);
|
|
|
|
|
-
|
|
|
|
|
- bool convertFromFloatTypes = (node->getBasicType() == EbtFloat16 ||
|
|
|
|
|
- node->getBasicType() == EbtFloat ||
|
|
|
|
|
- node->getBasicType() == EbtDouble);
|
|
|
|
|
-
|
|
|
|
|
- if (! getArithemeticInt8Enabled()) {
|
|
|
|
|
- if (((convertTo == EbtInt8 || convertTo == EbtUint8) && ! convertFromIntTypes) ||
|
|
|
|
|
- ((node->getBasicType() == EbtInt8 || node->getBasicType() == EbtUint8) && ! convertToIntTypes))
|
|
|
|
|
- return nullptr;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (! getArithemeticInt16Enabled()) {
|
|
|
|
|
- if (((convertTo == EbtInt16 || convertTo == EbtUint16) && ! convertFromIntTypes) ||
|
|
|
|
|
- ((node->getBasicType() == EbtInt16 || node->getBasicType() == EbtUint16) && ! convertToIntTypes))
|
|
|
|
|
- return nullptr;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (! getArithemeticFloat16Enabled()) {
|
|
|
|
|
- if ((convertTo == EbtFloat16 && ! convertFromFloatTypes) ||
|
|
|
|
|
- (node->getBasicType() == EbtFloat16 && ! convertToFloatTypes))
|
|
|
|
|
- return nullptr;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- switch (convertTo) {
|
|
|
|
|
|
|
+ switch (dst) {
|
|
|
#ifndef GLSLANG_WEB
|
|
#ifndef GLSLANG_WEB
|
|
|
case EbtDouble:
|
|
case EbtDouble:
|
|
|
- switch (node->getBasicType()) {
|
|
|
|
|
|
|
+ switch (src) {
|
|
|
case EbtUint: newOp = EOpConvUintToDouble; break;
|
|
case EbtUint: newOp = EOpConvUintToDouble; break;
|
|
|
case EbtBool: newOp = EOpConvBoolToDouble; break;
|
|
case EbtBool: newOp = EOpConvBoolToDouble; break;
|
|
|
case EbtFloat: newOp = EOpConvFloatToDouble; break;
|
|
case EbtFloat: newOp = EOpConvFloatToDouble; break;
|
|
@@ -624,12 +580,12 @@ TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped
|
|
|
case EbtInt64: newOp = EOpConvInt64ToDouble; break;
|
|
case EbtInt64: newOp = EOpConvInt64ToDouble; break;
|
|
|
case EbtUint64: newOp = EOpConvUint64ToDouble; break;
|
|
case EbtUint64: newOp = EOpConvUint64ToDouble; break;
|
|
|
default:
|
|
default:
|
|
|
- return nullptr;
|
|
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
#endif
|
|
#endif
|
|
|
case EbtFloat:
|
|
case EbtFloat:
|
|
|
- switch (node->getBasicType()) {
|
|
|
|
|
|
|
+ switch (src) {
|
|
|
case EbtInt: newOp = EOpConvIntToFloat; break;
|
|
case EbtInt: newOp = EOpConvIntToFloat; break;
|
|
|
case EbtUint: newOp = EOpConvUintToFloat; break;
|
|
case EbtUint: newOp = EOpConvUintToFloat; break;
|
|
|
case EbtBool: newOp = EOpConvBoolToFloat; break;
|
|
case EbtBool: newOp = EOpConvBoolToFloat; break;
|
|
@@ -644,12 +600,12 @@ TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped
|
|
|
case EbtUint64: newOp = EOpConvUint64ToFloat; break;
|
|
case EbtUint64: newOp = EOpConvUint64ToFloat; break;
|
|
|
#endif
|
|
#endif
|
|
|
default:
|
|
default:
|
|
|
- return nullptr;
|
|
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
#ifndef GLSLANG_WEB
|
|
#ifndef GLSLANG_WEB
|
|
|
case EbtFloat16:
|
|
case EbtFloat16:
|
|
|
- switch (node->getBasicType()) {
|
|
|
|
|
|
|
+ switch (src) {
|
|
|
case EbtInt8: newOp = EOpConvInt8ToFloat16; break;
|
|
case EbtInt8: newOp = EOpConvInt8ToFloat16; break;
|
|
|
case EbtUint8: newOp = EOpConvUint8ToFloat16; break;
|
|
case EbtUint8: newOp = EOpConvUint8ToFloat16; break;
|
|
|
case EbtInt16: newOp = EOpConvInt16ToFloat16; break;
|
|
case EbtInt16: newOp = EOpConvInt16ToFloat16; break;
|
|
@@ -662,12 +618,12 @@ TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped
|
|
|
case EbtInt64: newOp = EOpConvInt64ToFloat16; break;
|
|
case EbtInt64: newOp = EOpConvInt64ToFloat16; break;
|
|
|
case EbtUint64: newOp = EOpConvUint64ToFloat16; break;
|
|
case EbtUint64: newOp = EOpConvUint64ToFloat16; break;
|
|
|
default:
|
|
default:
|
|
|
- return nullptr;
|
|
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
#endif
|
|
#endif
|
|
|
case EbtBool:
|
|
case EbtBool:
|
|
|
- switch (node->getBasicType()) {
|
|
|
|
|
|
|
+ switch (src) {
|
|
|
case EbtInt: newOp = EOpConvIntToBool; break;
|
|
case EbtInt: newOp = EOpConvIntToBool; break;
|
|
|
case EbtUint: newOp = EOpConvUintToBool; break;
|
|
case EbtUint: newOp = EOpConvUintToBool; break;
|
|
|
case EbtFloat: newOp = EOpConvFloatToBool; break;
|
|
case EbtFloat: newOp = EOpConvFloatToBool; break;
|
|
@@ -682,12 +638,12 @@ TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped
|
|
|
case EbtUint64: newOp = EOpConvUint64ToBool; break;
|
|
case EbtUint64: newOp = EOpConvUint64ToBool; break;
|
|
|
#endif
|
|
#endif
|
|
|
default:
|
|
default:
|
|
|
- return nullptr;
|
|
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
#ifndef GLSLANG_WEB
|
|
#ifndef GLSLANG_WEB
|
|
|
case EbtInt8:
|
|
case EbtInt8:
|
|
|
- switch (node->getBasicType()) {
|
|
|
|
|
|
|
+ switch (src) {
|
|
|
case EbtUint8: newOp = EOpConvUint8ToInt8; break;
|
|
case EbtUint8: newOp = EOpConvUint8ToInt8; break;
|
|
|
case EbtInt16: newOp = EOpConvInt16ToInt8; break;
|
|
case EbtInt16: newOp = EOpConvInt16ToInt8; break;
|
|
|
case EbtUint16: newOp = EOpConvUint16ToInt8; break;
|
|
case EbtUint16: newOp = EOpConvUint16ToInt8; break;
|
|
@@ -700,11 +656,11 @@ TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped
|
|
|
case EbtDouble: newOp = EOpConvDoubleToInt8; break;
|
|
case EbtDouble: newOp = EOpConvDoubleToInt8; break;
|
|
|
case EbtFloat16: newOp = EOpConvFloat16ToInt8; break;
|
|
case EbtFloat16: newOp = EOpConvFloat16ToInt8; break;
|
|
|
default:
|
|
default:
|
|
|
- return nullptr;
|
|
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
case EbtUint8:
|
|
case EbtUint8:
|
|
|
- switch (node->getBasicType()) {
|
|
|
|
|
|
|
+ switch (src) {
|
|
|
case EbtInt8: newOp = EOpConvInt8ToUint8; break;
|
|
case EbtInt8: newOp = EOpConvInt8ToUint8; break;
|
|
|
case EbtInt16: newOp = EOpConvInt16ToUint8; break;
|
|
case EbtInt16: newOp = EOpConvInt16ToUint8; break;
|
|
|
case EbtUint16: newOp = EOpConvUint16ToUint8; break;
|
|
case EbtUint16: newOp = EOpConvUint16ToUint8; break;
|
|
@@ -717,12 +673,12 @@ TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped
|
|
|
case EbtDouble: newOp = EOpConvDoubleToUint8; break;
|
|
case EbtDouble: newOp = EOpConvDoubleToUint8; break;
|
|
|
case EbtFloat16: newOp = EOpConvFloat16ToUint8; break;
|
|
case EbtFloat16: newOp = EOpConvFloat16ToUint8; break;
|
|
|
default:
|
|
default:
|
|
|
- return nullptr;
|
|
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case EbtInt16:
|
|
case EbtInt16:
|
|
|
- switch (node->getBasicType()) {
|
|
|
|
|
|
|
+ switch (src) {
|
|
|
case EbtUint8: newOp = EOpConvUint8ToInt16; break;
|
|
case EbtUint8: newOp = EOpConvUint8ToInt16; break;
|
|
|
case EbtInt8: newOp = EOpConvInt8ToInt16; break;
|
|
case EbtInt8: newOp = EOpConvInt8ToInt16; break;
|
|
|
case EbtUint16: newOp = EOpConvUint16ToInt16; break;
|
|
case EbtUint16: newOp = EOpConvUint16ToInt16; break;
|
|
@@ -735,11 +691,11 @@ TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped
|
|
|
case EbtDouble: newOp = EOpConvDoubleToInt16; break;
|
|
case EbtDouble: newOp = EOpConvDoubleToInt16; break;
|
|
|
case EbtFloat16: newOp = EOpConvFloat16ToInt16; break;
|
|
case EbtFloat16: newOp = EOpConvFloat16ToInt16; break;
|
|
|
default:
|
|
default:
|
|
|
- return nullptr;
|
|
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
case EbtUint16:
|
|
case EbtUint16:
|
|
|
- switch (node->getBasicType()) {
|
|
|
|
|
|
|
+ switch (src) {
|
|
|
case EbtInt8: newOp = EOpConvInt8ToUint16; break;
|
|
case EbtInt8: newOp = EOpConvInt8ToUint16; break;
|
|
|
case EbtUint8: newOp = EOpConvUint8ToUint16; break;
|
|
case EbtUint8: newOp = EOpConvUint8ToUint16; break;
|
|
|
case EbtInt16: newOp = EOpConvInt16ToUint16; break;
|
|
case EbtInt16: newOp = EOpConvInt16ToUint16; break;
|
|
@@ -752,13 +708,13 @@ TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped
|
|
|
case EbtDouble: newOp = EOpConvDoubleToUint16; break;
|
|
case EbtDouble: newOp = EOpConvDoubleToUint16; break;
|
|
|
case EbtFloat16: newOp = EOpConvFloat16ToUint16; break;
|
|
case EbtFloat16: newOp = EOpConvFloat16ToUint16; break;
|
|
|
default:
|
|
default:
|
|
|
- return nullptr;
|
|
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
case EbtInt:
|
|
case EbtInt:
|
|
|
- switch (node->getBasicType()) {
|
|
|
|
|
|
|
+ switch (src) {
|
|
|
case EbtUint: newOp = EOpConvUintToInt; break;
|
|
case EbtUint: newOp = EOpConvUintToInt; break;
|
|
|
case EbtBool: newOp = EOpConvBoolToInt; break;
|
|
case EbtBool: newOp = EOpConvBoolToInt; break;
|
|
|
case EbtFloat: newOp = EOpConvFloatToInt; break;
|
|
case EbtFloat: newOp = EOpConvFloatToInt; break;
|
|
@@ -773,11 +729,11 @@ TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped
|
|
|
case EbtUint64: newOp = EOpConvUint64ToInt; break;
|
|
case EbtUint64: newOp = EOpConvUint64ToInt; break;
|
|
|
#endif
|
|
#endif
|
|
|
default:
|
|
default:
|
|
|
- return nullptr;
|
|
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
case EbtUint:
|
|
case EbtUint:
|
|
|
- switch (node->getBasicType()) {
|
|
|
|
|
|
|
+ switch (src) {
|
|
|
case EbtInt: newOp = EOpConvIntToUint; break;
|
|
case EbtInt: newOp = EOpConvIntToUint; break;
|
|
|
case EbtBool: newOp = EOpConvBoolToUint; break;
|
|
case EbtBool: newOp = EOpConvBoolToUint; break;
|
|
|
case EbtFloat: newOp = EOpConvFloatToUint; break;
|
|
case EbtFloat: newOp = EOpConvFloatToUint; break;
|
|
@@ -792,12 +748,12 @@ TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped
|
|
|
case EbtUint64: newOp = EOpConvUint64ToUint; break;
|
|
case EbtUint64: newOp = EOpConvUint64ToUint; break;
|
|
|
#endif
|
|
#endif
|
|
|
default:
|
|
default:
|
|
|
- return nullptr;
|
|
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
#ifndef GLSLANG_WEB
|
|
#ifndef GLSLANG_WEB
|
|
|
case EbtInt64:
|
|
case EbtInt64:
|
|
|
- switch (node->getBasicType()) {
|
|
|
|
|
|
|
+ switch (src) {
|
|
|
case EbtInt8: newOp = EOpConvInt8ToInt64; break;
|
|
case EbtInt8: newOp = EOpConvInt8ToInt64; break;
|
|
|
case EbtUint8: newOp = EOpConvUint8ToInt64; break;
|
|
case EbtUint8: newOp = EOpConvUint8ToInt64; break;
|
|
|
case EbtInt16: newOp = EOpConvInt16ToInt64; break;
|
|
case EbtInt16: newOp = EOpConvInt16ToInt64; break;
|
|
@@ -810,11 +766,11 @@ TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped
|
|
|
case EbtFloat16: newOp = EOpConvFloat16ToInt64; break;
|
|
case EbtFloat16: newOp = EOpConvFloat16ToInt64; break;
|
|
|
case EbtUint64: newOp = EOpConvUint64ToInt64; break;
|
|
case EbtUint64: newOp = EOpConvUint64ToInt64; break;
|
|
|
default:
|
|
default:
|
|
|
- return nullptr;
|
|
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
case EbtUint64:
|
|
case EbtUint64:
|
|
|
- switch (node->getBasicType()) {
|
|
|
|
|
|
|
+ switch (src) {
|
|
|
case EbtInt8: newOp = EOpConvInt8ToUint64; break;
|
|
case EbtInt8: newOp = EOpConvInt8ToUint64; break;
|
|
|
case EbtUint8: newOp = EOpConvUint8ToUint64; break;
|
|
case EbtUint8: newOp = EOpConvUint8ToUint64; break;
|
|
|
case EbtInt16: newOp = EOpConvInt16ToUint64; break;
|
|
case EbtInt16: newOp = EOpConvInt16ToUint64; break;
|
|
@@ -827,11 +783,63 @@ TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped
|
|
|
case EbtFloat16: newOp = EOpConvFloat16ToUint64; break;
|
|
case EbtFloat16: newOp = EOpConvFloat16ToUint64; break;
|
|
|
case EbtInt64: newOp = EOpConvInt64ToUint64; break;
|
|
case EbtInt64: newOp = EOpConvInt64ToUint64; break;
|
|
|
default:
|
|
default:
|
|
|
- return nullptr;
|
|
|
|
|
|
|
+ return false;
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
#endif
|
|
#endif
|
|
|
default:
|
|
default:
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 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.
|
|
|
|
|
+TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped* node) const
|
|
|
|
|
+{
|
|
|
|
|
+ //
|
|
|
|
|
+ // Add a new newNode for the conversion.
|
|
|
|
|
+ //
|
|
|
|
|
+ TIntermUnary* newNode = nullptr;
|
|
|
|
|
+
|
|
|
|
|
+ TOperator newOp = EOpNull;
|
|
|
|
|
+
|
|
|
|
|
+ bool convertToIntTypes = (convertTo == EbtInt8 || convertTo == EbtUint8 ||
|
|
|
|
|
+ convertTo == EbtInt16 || convertTo == EbtUint16 ||
|
|
|
|
|
+ convertTo == EbtInt || convertTo == EbtUint ||
|
|
|
|
|
+ convertTo == EbtInt64 || convertTo == EbtUint64);
|
|
|
|
|
+
|
|
|
|
|
+ bool convertFromIntTypes = (node->getBasicType() == EbtInt8 || node->getBasicType() == EbtUint8 ||
|
|
|
|
|
+ node->getBasicType() == EbtInt16 || node->getBasicType() == EbtUint16 ||
|
|
|
|
|
+ node->getBasicType() == EbtInt || node->getBasicType() == EbtUint ||
|
|
|
|
|
+ node->getBasicType() == EbtInt64 || node->getBasicType() == EbtUint64);
|
|
|
|
|
+
|
|
|
|
|
+ bool convertToFloatTypes = (convertTo == EbtFloat16 || convertTo == EbtFloat || convertTo == EbtDouble);
|
|
|
|
|
+
|
|
|
|
|
+ bool convertFromFloatTypes = (node->getBasicType() == EbtFloat16 ||
|
|
|
|
|
+ node->getBasicType() == EbtFloat ||
|
|
|
|
|
+ node->getBasicType() == EbtDouble);
|
|
|
|
|
+
|
|
|
|
|
+ if (! getArithemeticInt8Enabled()) {
|
|
|
|
|
+ if (((convertTo == EbtInt8 || convertTo == EbtUint8) && ! convertFromIntTypes) ||
|
|
|
|
|
+ ((node->getBasicType() == EbtInt8 || node->getBasicType() == EbtUint8) && ! convertToIntTypes))
|
|
|
|
|
+ return nullptr;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (! getArithemeticInt16Enabled()) {
|
|
|
|
|
+ if (((convertTo == EbtInt16 || convertTo == EbtUint16) && ! convertFromIntTypes) ||
|
|
|
|
|
+ ((node->getBasicType() == EbtInt16 || node->getBasicType() == EbtUint16) && ! convertToIntTypes))
|
|
|
|
|
+ return nullptr;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (! getArithemeticFloat16Enabled()) {
|
|
|
|
|
+ if ((convertTo == EbtFloat16 && ! convertFromFloatTypes) ||
|
|
|
|
|
+ (node->getBasicType() == EbtFloat16 && ! convertToFloatTypes))
|
|
|
|
|
+ return nullptr;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!buildConvertOp(convertTo, node->getBasicType(), newOp)) {
|
|
|
return nullptr;
|
|
return nullptr;
|
|
|
}
|
|
}
|
|
|
|
|
|