Function finding algorithm for desktop version 400 and above. "When function calls are resolved, an exact type match for all the arguments is sought. If an exact match is found, all other functions are ignored, and the exact match is used. If no exact match is found, then the implicit conversions in section 4.1.10 Implicit Conversions will be applied to find a match. Mismatched types on input par
| 8472 | // conversion is considered better than the other." |
| 8473 | // |
| 8474 | const TFunction* TParseContext::findFunction400(const TSourceLoc& loc, const TFunction& call, bool& builtIn) |
| 8475 | { |
| 8476 | // first, look for an exact match |
| 8477 | TSymbol* symbol = symbolTable.find(call.getMangledName(), &builtIn); |
| 8478 | if (symbol) |
| 8479 | return symbol->getAsFunction(); |
| 8480 | |
| 8481 | // no exact match, use the generic selector, parameterized by the GLSL rules |
| 8482 | |
| 8483 | // create list of candidates to send |
| 8484 | TVector<const TFunction*> candidateList; |
| 8485 | symbolTable.findFunctionNameList(call.getMangledName(), candidateList, builtIn); |
| 8486 | |
| 8487 | // can 'from' convert to 'to'? |
| 8488 | const auto convertible = [this,builtIn](const TType& from, const TType& to, TOperator op, int param) -> bool { |
| 8489 | if (from == to) |
| 8490 | return true; |
| 8491 | if (from.coopMatParameterOK(to)) |
| 8492 | return true; |
| 8493 | if (from.tensorParameterOK(to)) |
| 8494 | return true; |
| 8495 | if (from.getBasicType() == EbtFunction && to.getBasicType() == EbtFunction) |
| 8496 | return true; |
| 8497 | if (from.coopVecParameterOK(to)) |
| 8498 | return true; |
| 8499 | // Allow a sized array to be passed through an unsized array parameter, for coopMatLoad/Store functions |
| 8500 | if (builtIn && from.isArray() && to.isUnsizedArray()) { |
| 8501 | TType fromElementType(from, 0); |
| 8502 | TType toElementType(to, 0); |
| 8503 | // Load/store tensor functions allow any element type for the pointer |
| 8504 | if ((op == EOpCooperativeMatrixLoadTensorNV || op == EOpCooperativeMatrixStoreTensorNV) && |
| 8505 | param == 1) { |
| 8506 | return true; |
| 8507 | } |
| 8508 | if (fromElementType == toElementType) |
| 8509 | return true; |
| 8510 | } |
| 8511 | if (TType::vectorAndLongVectorMatch(from, to)) |
| 8512 | return true; |
| 8513 | if (from.isArray() || to.isArray() || ! from.sameElementShape(to)) |
| 8514 | return false; |
| 8515 | if (from.isCoopMat() && to.isCoopMat()) |
| 8516 | return from.sameCoopMatBaseType(to); |
| 8517 | if (from.isCoopVecNV() && to.isCoopVecNV()) |
| 8518 | return from.sameCoopVecBaseType(to); |
| 8519 | if (from.isLongVector() && to.isLongVector()) |
| 8520 | return from.sameLongVectorBaseType(to); |
| 8521 | if (from.isTensorARM() && to.isTensorARM()) |
| 8522 | return from.sameTensorBaseTypeARM(to); |
| 8523 | return intermediate.canImplicitlyPromote(from.getBasicType(), to.getBasicType()); |
| 8524 | }; |
| 8525 | |
| 8526 | // Is 'to2' a better conversion than 'to1'? |
| 8527 | // Ties should not be considered as better. |
| 8528 | // Assumes 'convertible' already said true. |
| 8529 | const auto better = [&](const TType& from, const TType& to1, const TType& to2) -> bool { |
| 8530 | // 1. exact match |
| 8531 | bool to2Matches = from == to2 || (from.isLongVector() && to2.getBasicType() == EbtLongVector); |
nothing calls this directly
no test coverage detected