Implement extension GL_AMD_gpu_shader_int16
- Add int16 types (int16_t, uint16_t, i16vec, u16vec). - Add int16 support to GLSL operators. - Add int16 type conversions (to int16, from int16). - Add int16 built-in functions.
This commit is contained in:
parent
4d5bcd3162
commit
cabbb788b4
28 changed files with 8560 additions and 5521 deletions
|
|
@ -308,6 +308,10 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child, TSo
|
|||
case EOpConstructUint: newType = EbtUint; break;
|
||||
case EOpConstructInt64: newType = EbtInt64; break;
|
||||
case EOpConstructUint64: newType = EbtUint64; break;
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case EOpConstructInt16: newType = EbtInt16; break;
|
||||
case EOpConstructUint16: newType = EbtUint16; break;
|
||||
#endif
|
||||
case EOpConstructBool: newType = EbtBool; break;
|
||||
case EOpConstructFloat: newType = EbtFloat; break;
|
||||
case EOpConstructDouble: newType = EbtDouble; break;
|
||||
|
|
@ -336,6 +340,10 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child, TSo
|
|||
case EOpConstructUint:
|
||||
case EOpConstructInt64:
|
||||
case EOpConstructUint64:
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case EOpConstructInt16:
|
||||
case EOpConstructUint16:
|
||||
#endif
|
||||
case EOpConstructBool:
|
||||
case EOpConstructFloat:
|
||||
case EOpConstructDouble:
|
||||
|
|
@ -528,6 +536,14 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
case EOpConstructUint64:
|
||||
promoteTo = EbtUint64;
|
||||
break;
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case EOpConstructInt16:
|
||||
promoteTo = EbtInt16;
|
||||
break;
|
||||
case EOpConstructUint16:
|
||||
promoteTo = EbtUint16;
|
||||
break;
|
||||
#endif
|
||||
|
||||
//
|
||||
// List all the binary ops that can implicitly convert one operand to the other's type;
|
||||
|
|
@ -616,10 +632,18 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
case EOpRightShiftAssign:
|
||||
if ((type.getBasicType() == EbtInt ||
|
||||
type.getBasicType() == EbtUint ||
|
||||
#ifdef AMD_EXTENSIONS
|
||||
type.getBasicType() == EbtInt16 ||
|
||||
type.getBasicType() == EbtUint16 ||
|
||||
#endif
|
||||
type.getBasicType() == EbtInt64 ||
|
||||
type.getBasicType() == EbtUint64) &&
|
||||
(node->getType().getBasicType() == EbtInt ||
|
||||
node->getType().getBasicType() == EbtUint ||
|
||||
#ifdef AMD_EXTENSIONS
|
||||
node->getType().getBasicType() == EbtInt16 ||
|
||||
node->getType().getBasicType() == EbtUint16 ||
|
||||
#endif
|
||||
node->getType().getBasicType() == EbtInt64 ||
|
||||
node->getType().getBasicType() == EbtUint64))
|
||||
|
||||
|
|
@ -663,6 +687,10 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
#endif
|
||||
case EbtInt64: newOp = EOpConvInt64ToDouble; break;
|
||||
case EbtUint64: newOp = EOpConvUint64ToDouble; break;
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case EbtInt16: newOp = EOpConvInt16ToDouble; break;
|
||||
case EbtUint16: newOp = EOpConvUint16ToDouble; break;
|
||||
#endif
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -678,6 +706,10 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
#endif
|
||||
case EbtInt64: newOp = EOpConvInt64ToFloat; break;
|
||||
case EbtUint64: newOp = EOpConvUint64ToFloat; break;
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case EbtInt16: newOp = EOpConvInt16ToFloat; break;
|
||||
case EbtUint16: newOp = EOpConvUint16ToFloat; break;
|
||||
#endif
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -692,6 +724,8 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
case EbtDouble: newOp = EOpConvDoubleToFloat16; break;
|
||||
case EbtInt64: newOp = EOpConvInt64ToFloat16; break;
|
||||
case EbtUint64: newOp = EOpConvUint64ToFloat16; break;
|
||||
case EbtInt16: newOp = EOpConvInt16ToFloat16; break;
|
||||
case EbtUint16: newOp = EOpConvUint16ToFloat16; break;
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -708,6 +742,10 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
#endif
|
||||
case EbtInt64: newOp = EOpConvInt64ToBool; break;
|
||||
case EbtUint64: newOp = EOpConvUint64ToBool; break;
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case EbtInt16: newOp = EOpConvInt16ToBool; break;
|
||||
case EbtUint16: newOp = EOpConvUint16ToBool; break;
|
||||
#endif
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -723,6 +761,10 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
#endif
|
||||
case EbtInt64: newOp = EOpConvInt64ToInt; break;
|
||||
case EbtUint64: newOp = EOpConvUint64ToInt; break;
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case EbtInt16: newOp = EOpConvInt16ToInt; break;
|
||||
case EbtUint16: newOp = EOpConvUint16ToInt; break;
|
||||
#endif
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -738,6 +780,10 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
#endif
|
||||
case EbtInt64: newOp = EOpConvInt64ToUint; break;
|
||||
case EbtUint64: newOp = EOpConvUint64ToUint; break;
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case EbtInt16: newOp = EOpConvInt16ToUint; break;
|
||||
case EbtUint16: newOp = EOpConvUint16ToUint; break;
|
||||
#endif
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -753,6 +799,10 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
case EbtFloat16: newOp = EOpConvFloat16ToInt64; break;
|
||||
#endif
|
||||
case EbtUint64: newOp = EOpConvUint64ToInt64; break;
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case EbtInt16: newOp = EOpConvInt16ToInt64; break;
|
||||
case EbtUint16: newOp = EOpConvUint16ToInt64; break;
|
||||
#endif
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -768,10 +818,46 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
case EbtFloat16: newOp = EOpConvFloat16ToUint64; break;
|
||||
#endif
|
||||
case EbtInt64: newOp = EOpConvInt64ToUint64; break;
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case EbtInt16: newOp = EOpConvInt16ToUint64; break;
|
||||
case EbtUint16: newOp = EOpConvUint16ToUint64; break;
|
||||
#endif
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
break;
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case EbtInt16:
|
||||
switch (node->getBasicType()) {
|
||||
case EbtInt: newOp = EOpConvIntToInt16; break;
|
||||
case EbtUint: newOp = EOpConvUintToInt16; break;
|
||||
case EbtBool: newOp = EOpConvBoolToInt16; break;
|
||||
case EbtFloat: newOp = EOpConvFloatToInt16; break;
|
||||
case EbtDouble: newOp = EOpConvDoubleToInt16; break;
|
||||
case EbtFloat16: newOp = EOpConvFloat16ToInt16; break;
|
||||
case EbtInt64: newOp = EOpConvInt64ToInt16; break;
|
||||
case EbtUint64: newOp = EOpConvUint64ToInt16; break;
|
||||
case EbtUint16: newOp = EOpConvUint16ToInt16; break;
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
break;
|
||||
case EbtUint16:
|
||||
switch (node->getBasicType()) {
|
||||
case EbtInt: newOp = EOpConvIntToUint16; break;
|
||||
case EbtUint: newOp = EOpConvUintToUint16; break;
|
||||
case EbtBool: newOp = EOpConvBoolToUint16; break;
|
||||
case EbtFloat: newOp = EOpConvFloatToUint16; break;
|
||||
case EbtDouble: newOp = EOpConvDoubleToUint16; break;
|
||||
case EbtFloat16: newOp = EOpConvFloat16ToUint16; break;
|
||||
case EbtInt64: newOp = EOpConvInt64ToUint16; break;
|
||||
case EbtUint64: newOp = EOpConvUint64ToUint16; break;
|
||||
case EbtInt16: newOp = EOpConvInt16ToUint16; break;
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -1020,6 +1106,10 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
|
|||
case EbtUint:
|
||||
case EbtInt64:
|
||||
case EbtUint64:
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case EbtInt16:
|
||||
case EbtUint16:
|
||||
#endif
|
||||
case EbtFloat:
|
||||
case EbtDouble:
|
||||
#ifdef AMD_EXTENSIONS
|
||||
|
|
@ -1033,6 +1123,10 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
|
|||
switch (from) {
|
||||
case EbtInt:
|
||||
case EbtUint:
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case EbtInt16:
|
||||
case EbtUint16:
|
||||
#endif
|
||||
case EbtFloat:
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case EbtFloat16:
|
||||
|
|
@ -1048,6 +1142,10 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
|
|||
case EbtInt:
|
||||
return version >= 400 || (source == EShSourceHlsl);
|
||||
case EbtUint:
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case EbtInt16:
|
||||
case EbtUint16:
|
||||
#endif
|
||||
return true;
|
||||
case EbtBool:
|
||||
return (source == EShSourceHlsl);
|
||||
|
|
@ -1057,6 +1155,9 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
|
|||
case EbtInt:
|
||||
switch (from) {
|
||||
case EbtInt:
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case EbtInt16:
|
||||
#endif
|
||||
return true;
|
||||
case EbtBool:
|
||||
return (source == EShSourceHlsl);
|
||||
|
|
@ -1069,6 +1170,10 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
|
|||
case EbtUint:
|
||||
case EbtInt64:
|
||||
case EbtUint64:
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case EbtInt16:
|
||||
case EbtUint16:
|
||||
#endif
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
|
@ -1077,10 +1182,32 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
|
|||
switch (from) {
|
||||
case EbtInt:
|
||||
case EbtInt64:
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case EbtInt16:
|
||||
#endif
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case EbtFloat16:
|
||||
switch (from) {
|
||||
case EbtInt16:
|
||||
case EbtUint16:
|
||||
case EbtFloat16:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
case EbtUint16:
|
||||
switch (from) {
|
||||
case EbtInt16:
|
||||
case EbtUint16:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1313,6 +1440,26 @@ TOperator TIntermediate::mapTypeToConstructorOp(const TType& type) const
|
|||
default: break; // some compilers want this
|
||||
}
|
||||
break;
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case EbtInt16:
|
||||
switch(type.getVectorSize()) {
|
||||
case 1: op = EOpConstructInt16; break;
|
||||
case 2: op = EOpConstructI16Vec2; break;
|
||||
case 3: op = EOpConstructI16Vec3; break;
|
||||
case 4: op = EOpConstructI16Vec4; break;
|
||||
default: break; // some compilers want this
|
||||
}
|
||||
break;
|
||||
case EbtUint16:
|
||||
switch(type.getVectorSize()) {
|
||||
case 1: op = EOpConstructUint16; break;
|
||||
case 2: op = EOpConstructU16Vec2; break;
|
||||
case 3: op = EOpConstructU16Vec3; break;
|
||||
case 4: op = EOpConstructU16Vec4; break;
|
||||
default: break; // some compilers want this
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case EbtBool:
|
||||
if (type.getMatrixCols()) {
|
||||
switch (type.getMatrixCols()) {
|
||||
|
|
@ -1620,6 +1767,24 @@ TIntermConstantUnion* TIntermediate::addConstantUnion(unsigned long long u64, co
|
|||
return addConstantUnion(unionArray, TType(EbtUint64, EvqConst), loc, literal);
|
||||
}
|
||||
|
||||
#ifdef AMD_EXTENSIONS
|
||||
TIntermConstantUnion* TIntermediate::addConstantUnion(short i16, const TSourceLoc& loc, bool literal) const
|
||||
{
|
||||
TConstUnionArray unionArray(1);
|
||||
unionArray[0].setIConst(i16);
|
||||
|
||||
return addConstantUnion(unionArray, TType(EbtInt16, EvqConst), loc, literal);
|
||||
}
|
||||
|
||||
TIntermConstantUnion* TIntermediate::addConstantUnion(unsigned short u16, const TSourceLoc& loc, bool literal) const
|
||||
{
|
||||
TConstUnionArray unionArray(1);
|
||||
unionArray[0].setUConst(u16);
|
||||
|
||||
return addConstantUnion(unionArray, TType(EbtUint16, EvqConst), loc, literal);
|
||||
}
|
||||
#endif
|
||||
|
||||
TIntermConstantUnion* TIntermediate::addConstantUnion(bool b, const TSourceLoc& loc, bool literal) const
|
||||
{
|
||||
TConstUnionArray unionArray(1);
|
||||
|
|
@ -1979,6 +2144,30 @@ bool TIntermediate::isSpecializationOperation(const TIntermOperator& node) const
|
|||
case EOpConvUintToInt64:
|
||||
case EOpConvUint64ToInt:
|
||||
case EOpConvIntToUint64:
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case EOpConvInt16ToBool:
|
||||
case EOpConvBoolToInt16:
|
||||
case EOpConvInt16ToInt:
|
||||
case EOpConvIntToInt16:
|
||||
case EOpConvInt16ToUint:
|
||||
case EOpConvUintToInt16:
|
||||
case EOpConvInt16ToInt64:
|
||||
case EOpConvInt64ToInt16:
|
||||
case EOpConvInt16ToUint64:
|
||||
case EOpConvUint64ToInt16:
|
||||
case EOpConvUint16ToBool:
|
||||
case EOpConvBoolToUint16:
|
||||
case EOpConvUint16ToInt:
|
||||
case EOpConvIntToUint16:
|
||||
case EOpConvUint16ToUint:
|
||||
case EOpConvUintToUint16:
|
||||
case EOpConvUint16ToInt64:
|
||||
case EOpConvInt64ToUint16:
|
||||
case EOpConvUint16ToUint64:
|
||||
case EOpConvUint64ToUint16:
|
||||
case EOpConvInt16ToUint16:
|
||||
case EOpConvUint16ToInt16:
|
||||
#endif
|
||||
|
||||
// unary operations
|
||||
case EOpNegative:
|
||||
|
|
@ -2107,6 +2296,10 @@ bool TIntermediate::promoteUnary(TIntermUnary& node)
|
|||
case EOpBitwiseNot:
|
||||
if (operand->getBasicType() != EbtInt &&
|
||||
operand->getBasicType() != EbtUint &&
|
||||
#ifdef AMD_EXTENSIONS
|
||||
operand->getBasicType() != EbtInt16 &&
|
||||
operand->getBasicType() != EbtUint16 &&
|
||||
#endif
|
||||
operand->getBasicType() != EbtInt64 &&
|
||||
operand->getBasicType() != EbtUint64)
|
||||
|
||||
|
|
@ -2121,6 +2314,10 @@ bool TIntermediate::promoteUnary(TIntermUnary& node)
|
|||
operand->getBasicType() != EbtUint &&
|
||||
operand->getBasicType() != EbtInt64 &&
|
||||
operand->getBasicType() != EbtUint64 &&
|
||||
#ifdef AMD_EXTENSIONS
|
||||
operand->getBasicType() != EbtInt16 &&
|
||||
operand->getBasicType() != EbtUint16 &&
|
||||
#endif
|
||||
operand->getBasicType() != EbtFloat &&
|
||||
#ifdef AMD_EXTENSIONS
|
||||
operand->getBasicType() != EbtFloat16 &&
|
||||
|
|
@ -2327,8 +2524,14 @@ bool TIntermediate::promoteBinary(TIntermBinary& node)
|
|||
|
||||
// Check for integer-only operands.
|
||||
if ((left->getBasicType() != EbtInt && left->getBasicType() != EbtUint &&
|
||||
left->getBasicType() != EbtInt64 && left->getBasicType() != EbtUint64) ||
|
||||
#ifdef AMD_EXTENSIONS
|
||||
left->getBasicType() != EbtInt16 && left->getBasicType() != EbtUint16 &&
|
||||
#endif
|
||||
left->getBasicType() != EbtInt64 && left->getBasicType() != EbtUint64) ||
|
||||
(right->getBasicType() != EbtInt && right->getBasicType() != EbtUint &&
|
||||
#ifdef AMD_EXTENSIONS
|
||||
right->getBasicType() != EbtInt16 && right->getBasicType() != EbtUint16 &&
|
||||
#endif
|
||||
right->getBasicType() != EbtInt64 && right->getBasicType() != EbtUint64))
|
||||
return false;
|
||||
if (left->isMatrix() || right->isMatrix())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue