MCPcopy Create free account
hub / github.com/KhronosGroup/glslang / findFunctionExplicitTypes

Method findFunctionExplicitTypes

glslang/MachineIndependent/ParseHelper.cpp:8594–8694  ·  view source on GitHub ↗

"To determine whether the conversion for a single argument in one match is better than that for another match, the conversion is assigned of the three ranks ordered from best to worst: 1. Exact match: no conversion. 2. Promotion: integral or floating-point promotion. 3. Conversion: integral conversion, floating-point conversion, floating-integral conversion. A conversion C1 is better than a conver

Source from the content-addressed store, hash-verified

8592// A conversion C1 is better than a conversion C2 if the rank of C1 is
8593// better than the rank of C2."
8594const TFunction* TParseContext::findFunctionExplicitTypes(const TSourceLoc& loc, const TFunction& call, bool& builtIn)
8595{
8596 // first, look for an exact match
8597 TSymbol* symbol = symbolTable.find(call.getMangledName(), &builtIn);
8598 if (symbol)
8599 return symbol->getAsFunction();
8600
8601 // no exact match, use the generic selector, parameterized by the GLSL rules
8602
8603 // create list of candidates to send
8604 TVector<const TFunction*> candidateList;
8605 symbolTable.findFunctionNameList(call.getMangledName(), candidateList, builtIn);
8606
8607 // can 'from' convert to 'to'?
8608 const auto convertible = [this,builtIn](const TType& from, const TType& to, TOperator op, int param) -> bool {
8609 if (from == to)
8610 return true;
8611 if (from.coopMatParameterOK(to))
8612 return true;
8613 if (from.tensorParameterOK(to))
8614 return true;
8615 if (from.getBasicType() == EbtFunction && to.getBasicType() == EbtFunction)
8616 return true;
8617 if (from.coopVecParameterOK(to))
8618 return true;
8619 // Allow a sized array to be passed through an unsized array parameter, for coopMatLoad/Store functions
8620 if (builtIn && from.isArray() && to.isUnsizedArray()) {
8621 TType fromElementType(from, 0);
8622 TType toElementType(to, 0);
8623 // Load/store tensor functions allow any element type for the pointer
8624 if ((op == EOpCooperativeMatrixLoadTensorNV || op == EOpCooperativeMatrixStoreTensorNV) &&
8625 param == 1) {
8626 return true;
8627 }
8628 if (fromElementType == toElementType)
8629 return true;
8630 }
8631 if (TType::vectorAndLongVectorMatch(from, to))
8632 return true;
8633 if (from.isArray() || to.isArray() || ! from.sameElementShape(to))
8634 return false;
8635 if (from.isCoopMat() && to.isCoopMat())
8636 return from.sameCoopMatBaseType(to);
8637 if (from.isCoopVecNV() && to.isCoopVecNV())
8638 return from.sameCoopVecBaseType(to);
8639 if (from.isLongVector() && to.isLongVector())
8640 return from.sameLongVectorBaseType(to);
8641 if (from.isTensorARM() && to.isTensorARM())
8642 return from.sameTensorBaseTypeARM(to);
8643 return intermediate.canImplicitlyPromote(from.getBasicType(), to.getBasicType());
8644 };
8645
8646 // Is 'to2' a better conversion than 'to1'?
8647 // Ties should not be considered as better.
8648 // Assumes 'convertible' already said true.
8649 const auto better = [this](const TType& from, const TType& to1, const TType& to2) -> bool {
8650 // 1. exact match
8651 bool to2Matches = from == to2 || (from.isLongVector() && to2.getBasicType() == EbtLongVector);

Callers

nothing calls this directly

Calls 15

errorFunction · 0.85
coopMatParameterOKMethod · 0.80
tensorParameterOKMethod · 0.80
coopVecParameterOKMethod · 0.80
isUnsizedArrayMethod · 0.80
sameElementShapeMethod · 0.80
isCoopMatMethod · 0.80
sameCoopMatBaseTypeMethod · 0.80
isCoopVecNVMethod · 0.80
sameCoopVecBaseTypeMethod · 0.80
sameTensorBaseTypeARMMethod · 0.80

Tested by

no test coverage detected