HLSL: Add support for printf().

Translate printf() to what GL_EXT_debug_printf has done. HLSL could
define non-constant string variable and we don't have such features
in SPIR-V, so just support constant string variable.
This commit is contained in:
Rex Xu 2020-10-23 22:54:35 +08:00
parent 3b334b2b8e
commit f6e0fe8600
9 changed files with 216 additions and 5 deletions

View file

@ -7628,7 +7628,17 @@ const TFunction* HlslParseContext::findFunction(const TSourceLoc& loc, TFunction
bool tie = false;
// send to the generic selector
const TFunction* bestMatch = selectFunction(candidateList, call, convertible, better, tie);
const TFunction* bestMatch = nullptr;
// printf has var args and is in the symbol table as "printf()",
// mangled to "printf("
if (call.getName() == "printf") {
TSymbol* symbol = symbolTable.find("printf(", &builtIn);
if (symbol)
return symbol->getAsFunction();
}
bestMatch = selectFunction(candidateList, call, convertible, better, tie);
if (bestMatch == nullptr) {
// If there is nothing selected by allowing only up-conversions (to a larger linearize() value),