HLSL: Map parameter qualifiers from generic to function-specific and entry-point specific.

This commit is contained in:
John Kessenich
2016-06-17 15:50:47 -06:00
parent c3387d33ee
commit 5aa59e2044
28 changed files with 3680 additions and 3676 deletions

View File

@@ -785,6 +785,8 @@ bool HlslGrammar::acceptParameterDeclaration(TFunction& function)
acceptPostDecls(*type);
parseContext.paramFix(*type);
TParameter param = { idToken.string, type };
function.addParameter(param);

View File

@@ -717,6 +717,11 @@ TIntermAggregate* HlslParseContext::handleFunctionDefinition(const TSourceLoc& l
functionReturnsValue = false;
inEntrypoint = (function.getName() == intermediate.getEntryPoint().c_str());
if (inEntrypoint) {
// parameters are actually shader-level inputs
for (int i = 0; i < function.getParamCount(); i++)
function[i].type->getQualifier().storage = EvqVaryingIn;
}
//
// New symbol table scope for body of function plus its arguments
@@ -2356,42 +2361,21 @@ void HlslParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& n
intermediate.addSymbolLinkageNode(linkage, *block);
}
void HlslParseContext::paramCheckFix(const TSourceLoc& loc, const TStorageQualifier& qualifier, TType& type)
void HlslParseContext::paramFix(TType& type)
{
switch (qualifier) {
switch (type.getQualifier().storage) {
case EvqConst:
case EvqConstReadOnly:
type.getQualifier().storage = EvqConstReadOnly;
break;
case EvqIn:
case EvqOut:
case EvqInOut:
type.getQualifier().storage = qualifier;
break;
case EvqGlobal:
case EvqTemporary:
type.getQualifier().storage = EvqIn;
break;
default:
type.getQualifier().storage = EvqIn;
error(loc, "storage qualifier not allowed on function parameter", GetStorageQualifierString(qualifier), "");
break;
}
}
void HlslParseContext::paramCheckFix(const TSourceLoc& loc, const TQualifier& qualifier, TType& type)
{
if (qualifier.isMemory()) {
type.getQualifier().volatil = qualifier.volatil;
type.getQualifier().coherent = qualifier.coherent;
type.getQualifier().readonly = qualifier.readonly;
type.getQualifier().writeonly = qualifier.writeonly;
type.getQualifier().restrict = qualifier.restrict;
}
paramCheckFix(loc, qualifier.storage, type);
}
void HlslParseContext::specializationCheck(const TSourceLoc& loc, const TType& type, const char* op)
{
if (type.containsSpecializationSize())

View File

@@ -116,8 +116,7 @@ public:
int computeSamplerTypeIndex(TSampler&);
TSymbol* redeclareBuiltinVariable(const TSourceLoc&, const TString&, const TQualifier&, const TShaderQualifiers&, bool& newDeclaration);
void redeclareBuiltinBlock(const TSourceLoc&, TTypeList& typeList, const TString& blockName, const TString* instanceName, TArraySizes* arraySizes);
void paramCheckFix(const TSourceLoc&, const TStorageQualifier&, TType& type);
void paramCheckFix(const TSourceLoc&, const TQualifier&, TType& type);
void paramFix(TType& type);
void specializationCheck(const TSourceLoc&, const TType&, const char* op);
void setLayoutQualifier(const TSourceLoc&, TPublicType&, TString&);