Desktop array size limit checking for gl_ClipDistance[] and gl_TexCoord[].

git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@24397 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
John Kessenich 2013-12-06 23:57:42 +00:00
parent 64bcb105c9
commit 5f15d4224a
8 changed files with 40 additions and 8 deletions

View file

@ -1410,6 +1410,8 @@ void TParseContext::reservedPpErrorCheck(TSourceLoc loc, const char* identifier,
//
// See if this version/profile allows use of the line-continuation character '\'.
//
// Returns true if a line continuation should be done.
//
bool TParseContext::lineContinuationCheck(TSourceLoc loc, bool endOfComment)
{
const char* message = "line continuation";
@ -1433,6 +1435,8 @@ bool TParseContext::lineContinuationCheck(TSourceLoc loc, bool endOfComment)
profileRequires(loc, EEsProfile, 300, 0, message);
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 420, 0, message);
}
return lineContinuationAllowed;
}
bool TParseContext::builtInName(const TString& identifier)
@ -1988,6 +1992,11 @@ void TParseContext::declareArray(TSourceLoc loc, TString& identifier, const TTyp
return;
}
if (identifier.compare("gl_TexCoord") == 0)
limitCheck(loc, type.getArraySize(), "gl_MaxTextureCoords", "gl_TexCoord array size");
else if (identifier.compare("gl_ClipDistance") == 0)
limitCheck(loc, type.getArraySize(), "gl_MaxClipDistances", "gl_ClipDistance array size");
newType.shareArraySizes(type);
if (language == EShLangGeometry && type.getQualifier().storage == EvqVaryingIn)
@ -2442,6 +2451,18 @@ void TParseContext::inductiveLoopCheck(TSourceLoc loc, TIntermNode* init, TInter
inductiveLoopBodyCheck(loop->getBody(), loopIndex, symbolTable);
}
// See if the provide value is less than the symbol indicated by limit,
// which should be a constant in the symbol table.
void TParseContext::limitCheck(TSourceLoc loc, int value, const char* limit, const char* feature)
{
TSymbol* symbol = symbolTable.find(limit);
assert(symbol->getAsVariable());
const TConstUnionArray& constArray = symbol->getAsVariable()->getConstArray();
assert(! constArray.empty());
if (value >= constArray[0].getIConst())
error(loc, "must be less than", feature, "%s (%d)", limit, constArray[0].getIConst());
}
//
// Do any additional error checking, etc., once we know the parsing is done.
//