Implement the extension GL_ARB_gpu_shader_int64
- Add new keyword int64_t/uint64_t/i64vec/u64vec. - Support 64-bit integer literals (dec/hex/oct). - Support built-in operators for 64-bit integer type. - Add implicit and explicit type conversion for 64-bit integer type. - Add new built-in functions defined in this extension.
This commit is contained in:
parent
010e93fe62
commit
8ff43de891
33 changed files with 5047 additions and 3009 deletions
|
|
@ -247,6 +247,8 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child, TSo
|
|||
switch (op) {
|
||||
case EOpConstructInt: newType = EbtInt; break;
|
||||
case EOpConstructUint: newType = EbtUint; break;
|
||||
case EOpConstructInt64: newType = EbtInt64; break;
|
||||
case EOpConstructUint64: newType = EbtUint64; break;
|
||||
case EOpConstructBool: newType = EbtBool; break;
|
||||
case EOpConstructFloat: newType = EbtFloat; break;
|
||||
case EOpConstructDouble: newType = EbtDouble; break;
|
||||
|
|
@ -269,6 +271,8 @@ TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child, TSo
|
|||
switch (op) {
|
||||
case EOpConstructInt:
|
||||
case EOpConstructUint:
|
||||
case EOpConstructInt64:
|
||||
case EOpConstructUint64:
|
||||
case EOpConstructBool:
|
||||
case EOpConstructFloat:
|
||||
case EOpConstructDouble:
|
||||
|
|
@ -472,6 +476,12 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
case EOpConstructUint:
|
||||
promoteTo = EbtUint;
|
||||
break;
|
||||
case EOpConstructInt64:
|
||||
promoteTo = EbtInt64;
|
||||
break;
|
||||
case EOpConstructUint64:
|
||||
promoteTo = EbtUint64;
|
||||
break;
|
||||
|
||||
//
|
||||
// List all the binary ops that can implicitly convert one operand to the other's type;
|
||||
|
|
@ -498,6 +508,9 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
case EOpAnd:
|
||||
case EOpInclusiveOr:
|
||||
case EOpExclusiveOr:
|
||||
case EOpAndAssign:
|
||||
case EOpInclusiveOrAssign:
|
||||
case EOpExclusiveOrAssign:
|
||||
|
||||
case EOpFunctionCall:
|
||||
case EOpReturn:
|
||||
|
|
@ -531,9 +544,13 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
case EOpLeftShiftAssign:
|
||||
case EOpRightShiftAssign:
|
||||
if ((type.getBasicType() == EbtInt ||
|
||||
type.getBasicType() == EbtUint) &&
|
||||
type.getBasicType() == EbtUint ||
|
||||
type.getBasicType() == EbtInt64 ||
|
||||
type.getBasicType() == EbtUint64) &&
|
||||
(node->getType().getBasicType() == EbtInt ||
|
||||
node->getType().getBasicType() == EbtUint))
|
||||
node->getType().getBasicType() == EbtUint ||
|
||||
node->getType().getBasicType() == EbtInt64 ||
|
||||
node->getType().getBasicType() == EbtUint64))
|
||||
|
||||
return node;
|
||||
else
|
||||
|
|
@ -567,6 +584,8 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
case EbtUint: newOp = EOpConvUintToDouble; break;
|
||||
case EbtBool: newOp = EOpConvBoolToDouble; break;
|
||||
case EbtFloat: newOp = EOpConvFloatToDouble; break;
|
||||
case EbtInt64: newOp = EOpConvInt64ToDouble; break;
|
||||
case EbtUint64: newOp = EOpConvUint64ToDouble; break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -577,6 +596,8 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
case EbtUint: newOp = EOpConvUintToFloat; break;
|
||||
case EbtBool: newOp = EOpConvBoolToFloat; break;
|
||||
case EbtDouble: newOp = EOpConvDoubleToFloat; break;
|
||||
case EbtInt64: newOp = EOpConvInt64ToFloat; break;
|
||||
case EbtUint64: newOp = EOpConvUint64ToFloat; break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -587,6 +608,8 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
case EbtUint: newOp = EOpConvUintToBool; break;
|
||||
case EbtFloat: newOp = EOpConvFloatToBool; break;
|
||||
case EbtDouble: newOp = EOpConvDoubleToBool; break;
|
||||
case EbtInt64: newOp = EOpConvInt64ToBool; break;
|
||||
case EbtUint64: newOp = EOpConvUint64ToBool; break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -597,6 +620,8 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
case EbtBool: newOp = EOpConvBoolToInt; break;
|
||||
case EbtFloat: newOp = EOpConvFloatToInt; break;
|
||||
case EbtDouble: newOp = EOpConvDoubleToInt; break;
|
||||
case EbtInt64: newOp = EOpConvInt64ToInt; break;
|
||||
case EbtUint64: newOp = EOpConvUint64ToInt; break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -607,6 +632,32 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
case EbtBool: newOp = EOpConvBoolToUint; break;
|
||||
case EbtFloat: newOp = EOpConvFloatToUint; break;
|
||||
case EbtDouble: newOp = EOpConvDoubleToUint; break;
|
||||
case EbtInt64: newOp = EOpConvInt64ToUint; break;
|
||||
case EbtUint64: newOp = EOpConvUint64ToUint; break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case EbtInt64:
|
||||
switch (node->getBasicType()) {
|
||||
case EbtInt: newOp = EOpConvIntToInt64; break;
|
||||
case EbtUint: newOp = EOpConvUintToInt64; break;
|
||||
case EbtBool: newOp = EOpConvBoolToInt64; break;
|
||||
case EbtFloat: newOp = EOpConvFloatToInt64; break;
|
||||
case EbtDouble: newOp = EOpConvDoubleToInt64; break;
|
||||
case EbtUint64: newOp = EOpConvUint64ToInt64; break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case EbtUint64:
|
||||
switch (node->getBasicType()) {
|
||||
case EbtInt: newOp = EOpConvIntToUint64; break;
|
||||
case EbtUint: newOp = EOpConvUintToUint64; break;
|
||||
case EbtBool: newOp = EOpConvBoolToUint64; break;
|
||||
case EbtFloat: newOp = EOpConvFloatToUint64; break;
|
||||
case EbtDouble: newOp = EOpConvDoubleToUint64; break;
|
||||
case EbtInt64: newOp = EOpConvInt64ToUint64; break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -643,6 +694,8 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to) const
|
|||
switch (from) {
|
||||
case EbtInt:
|
||||
case EbtUint:
|
||||
case EbtInt64:
|
||||
case EbtUint64:
|
||||
case EbtFloat:
|
||||
case EbtDouble:
|
||||
return true;
|
||||
|
|
@ -674,6 +727,24 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to) const
|
|||
default:
|
||||
return false;
|
||||
}
|
||||
case EbtUint64:
|
||||
switch (from) {
|
||||
case EbtInt:
|
||||
case EbtUint:
|
||||
case EbtInt64:
|
||||
case EbtUint64:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
case EbtInt64:
|
||||
switch (from) {
|
||||
case EbtInt:
|
||||
case EbtInt64:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
@ -873,6 +944,22 @@ TIntermConstantUnion* TIntermediate::addConstantUnion(unsigned int u, const TSou
|
|||
return addConstantUnion(unionArray, TType(EbtUint, EvqConst), loc, literal);
|
||||
}
|
||||
|
||||
TIntermConstantUnion* TIntermediate::addConstantUnion(long long i64, const TSourceLoc& loc, bool literal) const
|
||||
{
|
||||
TConstUnionArray unionArray(1);
|
||||
unionArray[0].setI64Const(i64);
|
||||
|
||||
return addConstantUnion(unionArray, TType(EbtInt64, EvqConst), loc, literal);
|
||||
}
|
||||
|
||||
TIntermConstantUnion* TIntermediate::addConstantUnion(unsigned long long u64, const TSourceLoc& loc, bool literal) const
|
||||
{
|
||||
TConstUnionArray unionArray(1);
|
||||
unionArray[0].setU64Const(u64);
|
||||
|
||||
return addConstantUnion(unionArray, TType(EbtUint64, EvqConst), loc, literal);
|
||||
}
|
||||
|
||||
TIntermConstantUnion* TIntermediate::addConstantUnion(bool b, const TSourceLoc& loc, bool literal) const
|
||||
{
|
||||
TConstUnionArray unionArray(1);
|
||||
|
|
@ -1212,7 +1299,9 @@ bool TIntermUnary::promote()
|
|||
break;
|
||||
case EOpBitwiseNot:
|
||||
if (operand->getBasicType() != EbtInt &&
|
||||
operand->getBasicType() != EbtUint)
|
||||
operand->getBasicType() != EbtUint &&
|
||||
operand->getBasicType() != EbtInt64 &&
|
||||
operand->getBasicType() != EbtUint64)
|
||||
|
||||
return false;
|
||||
break;
|
||||
|
|
@ -1223,6 +1312,8 @@ bool TIntermUnary::promote()
|
|||
case EOpPreDecrement:
|
||||
if (operand->getBasicType() != EbtInt &&
|
||||
operand->getBasicType() != EbtUint &&
|
||||
operand->getBasicType() != EbtInt64 &&
|
||||
operand->getBasicType() != EbtUint64 &&
|
||||
operand->getBasicType() != EbtFloat &&
|
||||
operand->getBasicType() != EbtDouble)
|
||||
|
||||
|
|
@ -1340,8 +1431,10 @@ bool TIntermBinary::promote()
|
|||
case EOpInclusiveOrAssign:
|
||||
case EOpExclusiveOrAssign:
|
||||
// Check for integer-only operands.
|
||||
if (( left->getBasicType() != EbtInt && left->getBasicType() != EbtUint) ||
|
||||
(right->getBasicType() != EbtInt && right->getBasicType() != EbtUint))
|
||||
if ((left->getBasicType() != EbtInt && left->getBasicType() != EbtUint &&
|
||||
left->getBasicType() != EbtInt64 && left->getBasicType() != EbtUint64) ||
|
||||
(right->getBasicType() != EbtInt && right->getBasicType() != EbtUint &&
|
||||
right->getBasicType() != EbtInt64 && right->getBasicType() != EbtUint64))
|
||||
return false;
|
||||
if (left->isMatrix() || right->isMatrix())
|
||||
return false;
|
||||
|
|
@ -1643,6 +1736,12 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
|
|||
case EbtUint:
|
||||
leftUnionArray[i].setDConst(static_cast<double>(rightUnionArray[i].getUConst()));
|
||||
break;
|
||||
case EbtInt64:
|
||||
leftUnionArray[i].setDConst(static_cast<double>(rightUnionArray[i].getI64Const()));
|
||||
break;
|
||||
case EbtUint64:
|
||||
leftUnionArray[i].setDConst(static_cast<double>(rightUnionArray[i].getU64Const()));
|
||||
break;
|
||||
case EbtBool:
|
||||
leftUnionArray[i].setDConst(static_cast<double>(rightUnionArray[i].getBConst()));
|
||||
break;
|
||||
|
|
@ -1664,6 +1763,12 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
|
|||
case EbtUint:
|
||||
leftUnionArray[i].setDConst(static_cast<double>(rightUnionArray[i].getUConst()));
|
||||
break;
|
||||
case EbtInt64:
|
||||
leftUnionArray[i].setDConst(static_cast<double>(rightUnionArray[i].getI64Const()));
|
||||
break;
|
||||
case EbtUint64:
|
||||
leftUnionArray[i].setDConst(static_cast<double>(rightUnionArray[i].getU64Const()));
|
||||
break;
|
||||
case EbtBool:
|
||||
leftUnionArray[i].setDConst(static_cast<double>(rightUnionArray[i].getBConst()));
|
||||
break;
|
||||
|
|
@ -1683,6 +1788,12 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
|
|||
case EbtUint:
|
||||
leftUnionArray[i].setIConst(static_cast<int>(rightUnionArray[i].getUConst()));
|
||||
break;
|
||||
case EbtInt64:
|
||||
leftUnionArray[i].setIConst(static_cast<int>(rightUnionArray[i].getI64Const()));
|
||||
break;
|
||||
case EbtUint64:
|
||||
leftUnionArray[i].setIConst(static_cast<int>(rightUnionArray[i].getU64Const()));
|
||||
break;
|
||||
case EbtBool:
|
||||
leftUnionArray[i].setIConst(static_cast<int>(rightUnionArray[i].getBConst()));
|
||||
break;
|
||||
|
|
@ -1702,6 +1813,12 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
|
|||
case EbtUint:
|
||||
leftUnionArray[i] = rightUnionArray[i];
|
||||
break;
|
||||
case EbtInt64:
|
||||
leftUnionArray[i].setUConst(static_cast<unsigned int>(rightUnionArray[i].getI64Const()));
|
||||
break;
|
||||
case EbtUint64:
|
||||
leftUnionArray[i].setUConst(static_cast<unsigned int>(rightUnionArray[i].getU64Const()));
|
||||
break;
|
||||
case EbtBool:
|
||||
leftUnionArray[i].setUConst(static_cast<unsigned int>(rightUnionArray[i].getBConst()));
|
||||
break;
|
||||
|
|
@ -1721,6 +1838,12 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
|
|||
case EbtUint:
|
||||
leftUnionArray[i].setBConst(rightUnionArray[i].getUConst() != 0);
|
||||
break;
|
||||
case EbtInt64:
|
||||
leftUnionArray[i].setBConst(rightUnionArray[i].getI64Const() != 0);
|
||||
break;
|
||||
case EbtUint64:
|
||||
leftUnionArray[i].setBConst(rightUnionArray[i].getU64Const() != 0);
|
||||
break;
|
||||
case EbtBool:
|
||||
leftUnionArray[i] = rightUnionArray[i];
|
||||
break;
|
||||
|
|
@ -1732,6 +1855,56 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
|
|||
return node;
|
||||
}
|
||||
break;
|
||||
case EbtInt64:
|
||||
switch (node->getType().getBasicType()) {
|
||||
case EbtInt:
|
||||
leftUnionArray[i].setI64Const(static_cast<long long>(rightUnionArray[i].getIConst()));
|
||||
break;
|
||||
case EbtUint:
|
||||
leftUnionArray[i].setI64Const(static_cast<long long>(rightUnionArray[i].getUConst()));
|
||||
break;
|
||||
case EbtInt64:
|
||||
leftUnionArray[i] = rightUnionArray[i];
|
||||
break;
|
||||
case EbtUint64:
|
||||
leftUnionArray[i].setI64Const(static_cast<long long>(rightUnionArray[i].getU64Const()));
|
||||
break;
|
||||
case EbtBool:
|
||||
leftUnionArray[i].setI64Const(static_cast<long long>(rightUnionArray[i].getBConst()));
|
||||
break;
|
||||
case EbtFloat:
|
||||
case EbtDouble:
|
||||
leftUnionArray[i].setI64Const(static_cast<long long>(rightUnionArray[i].getDConst()));
|
||||
break;
|
||||
default:
|
||||
return node;
|
||||
}
|
||||
break;
|
||||
case EbtUint64:
|
||||
switch (node->getType().getBasicType()) {
|
||||
case EbtInt:
|
||||
leftUnionArray[i].setU64Const(static_cast<unsigned long long>(rightUnionArray[i].getIConst()));
|
||||
break;
|
||||
case EbtUint:
|
||||
leftUnionArray[i].setU64Const(static_cast<unsigned long long>(rightUnionArray[i].getUConst()));
|
||||
break;
|
||||
case EbtInt64:
|
||||
leftUnionArray[i].setU64Const(static_cast<unsigned long long>(rightUnionArray[i].getI64Const()));
|
||||
break;
|
||||
case EbtUint64:
|
||||
leftUnionArray[i] = rightUnionArray[i];
|
||||
break;
|
||||
case EbtBool:
|
||||
leftUnionArray[i].setU64Const(static_cast<unsigned long long>(rightUnionArray[i].getBConst()));
|
||||
break;
|
||||
case EbtFloat:
|
||||
case EbtDouble:
|
||||
leftUnionArray[i].setU64Const(static_cast<unsigned long long>(rightUnionArray[i].getDConst()));
|
||||
break;
|
||||
default:
|
||||
return node;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return node;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue