Implement GL_NV_cooperative_matrix
This commit is contained in:
parent
ec484527b6
commit
4605e2ed2b
37 changed files with 5630 additions and 4211 deletions
49
glslang/MachineIndependent/Intermediate.cpp
Executable file → Normal file
49
glslang/MachineIndependent/Intermediate.cpp
Executable file → Normal file
|
|
@ -725,6 +725,11 @@ TIntermTyped* TIntermediate::createConversion(TBasicType convertTo, TIntermTyped
|
|||
return newNode;
|
||||
}
|
||||
|
||||
TIntermTyped* TIntermediate::addConversion(TBasicType convertTo, TIntermTyped* node) const
|
||||
{
|
||||
return createConversion(convertTo, node);
|
||||
}
|
||||
|
||||
// For converting a pair of operands to a binary operation to compatible
|
||||
// types with each other, relative to the operation in 'op'.
|
||||
// This does not cover assignment operations, which is asymmetric in that the
|
||||
|
|
@ -751,6 +756,10 @@ TIntermediate::addConversion(TOperator op, TIntermTyped* node0, TIntermTyped* no
|
|||
// If differing arrays, then no conversions.
|
||||
if (node0->getType().isArray() || node1->getType().isArray())
|
||||
return std::make_tuple(nullptr, nullptr);
|
||||
|
||||
// No implicit conversions for operations involving cooperative matrices
|
||||
if (node0->getType().isCoopMat() || node1->getType().isCoopMat())
|
||||
return std::make_tuple(node0, node1);
|
||||
}
|
||||
|
||||
auto promoteTo = std::make_tuple(EbtNumTypes, EbtNumTypes);
|
||||
|
|
@ -983,6 +992,7 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
|
||||
case EOpSequence:
|
||||
case EOpConstructStruct:
|
||||
case EOpConstructCooperativeMatrix:
|
||||
|
||||
if (type.getBasicType() == EbtReference || node->getType().getBasicType() == EbtReference) {
|
||||
// types must match to assign a reference
|
||||
|
|
@ -998,7 +1008,7 @@ TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TInt
|
|||
if (canImplicitlyPromote(node->getBasicType(), type.getBasicType(), op))
|
||||
promoteTo = type.getBasicType();
|
||||
else
|
||||
return nullptr;
|
||||
return nullptr;
|
||||
break;
|
||||
|
||||
// For GLSL, there are no conversions needed; the shift amount just needs to be an
|
||||
|
|
@ -1847,6 +1857,9 @@ TOperator TIntermediate::mapTypeToConstructorOp(const TType& type) const
|
|||
if (type.getQualifier().nonUniform)
|
||||
return EOpConstructNonuniform;
|
||||
|
||||
if (type.isCoopMat())
|
||||
return EOpConstructCooperativeMatrix;
|
||||
|
||||
switch (type.getBasicType()) {
|
||||
case EbtStruct:
|
||||
op = EOpConstructStruct;
|
||||
|
|
@ -3319,6 +3332,40 @@ bool TIntermediate::promoteBinary(TIntermBinary& node)
|
|||
break;
|
||||
}
|
||||
|
||||
if (left->getType().isCoopMat() || right->getType().isCoopMat()) {
|
||||
if (left->getType().isCoopMat() && right->getType().isCoopMat() &&
|
||||
*left->getType().getTypeParameters() != *right->getType().getTypeParameters()) {
|
||||
return false;
|
||||
}
|
||||
switch (op) {
|
||||
case EOpMul:
|
||||
case EOpMulAssign:
|
||||
if (left->getType().isCoopMat() && right->getType().isCoopMat()) {
|
||||
return false;
|
||||
}
|
||||
if (op == EOpMulAssign && right->getType().isCoopMat()) {
|
||||
return false;
|
||||
}
|
||||
node.setOp(op == EOpMulAssign ? EOpMatrixTimesScalarAssign : EOpMatrixTimesScalar);
|
||||
if (right->getType().isCoopMat()) {
|
||||
node.setType(right->getType());
|
||||
}
|
||||
return true;
|
||||
case EOpAdd:
|
||||
case EOpSub:
|
||||
case EOpDiv:
|
||||
case EOpAssign:
|
||||
// These require both to be cooperative matrices
|
||||
if (!left->getType().isCoopMat() || !right->getType().isCoopMat()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Finish handling the case, for all ops, where both operands are scalars.
|
||||
if (left->isScalar() && right->isScalar())
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue