HLSL: Handle "fake" entry points, by undoing their built-in variable declarations.

This commit is contained in:
John Kessenich
2016-09-02 20:23:27 -06:00
parent 9e079535a0
commit 07350f3382
6 changed files with 138 additions and 1 deletions

View File

@@ -755,6 +755,8 @@ TIntermAggregate* HlslParseContext::handleFunctionDefinition(const TSourceLoc& l
inEntrypoint = (function.getName() == intermediate.getEntryPoint().c_str());
if (inEntrypoint)
remapEntrypointIO(function);
else
remapNonEntrypointIO(function);
//
// New symbol table scope for body of function plus its arguments
@@ -864,6 +866,21 @@ void HlslParseContext::remapEntrypointIO(TFunction& function)
}
}
// An HLSL function that looks like an entry point, but is not,
// declares entry point IO built-ins, but these have to be undone.
void HlslParseContext::remapNonEntrypointIO(TFunction& function)
{
const auto remapBuiltInType = [&](TType& type) { type.getQualifier().builtIn = EbvNone; };
// return value
if (function.getType().getBasicType() != EbtVoid)
remapBuiltInType(function.getWritableType());
// parameters
for (int i = 0; i < function.getParamCount(); i++)
remapBuiltInType(*function[i].type);
}
// Handle function returns, including type conversions to the function return type
// if necessary.
TIntermNode* HlslParseContext::handleReturnValue(const TSourceLoc& loc, TIntermTyped* value)