Commit c74ec1a5 by Olli Etuaho Committed by Commit Bot

Record gl_in array size in a symbol in ParseContext

Instead of referring to the gl_in symbol in the symbol table, create a gl_in symbol with the right array size once the array size is known. This makes the type of TIntermSymbol nodes pointing to gl_in consistent with the variable type. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I31673d33526a91f8d069ee8d7d2f181a49665fd0 Reviewed-on: https://chromium-review.googlesource.com/857004Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 0690e1aa
...@@ -235,7 +235,7 @@ TParseContext::TParseContext(TSymbolTable &symt, ...@@ -235,7 +235,7 @@ TParseContext::TParseContext(TSymbolTable &symt,
mGeometryShaderMaxVertices(-1), mGeometryShaderMaxVertices(-1),
mMaxGeometryShaderInvocations(resources.MaxGeometryShaderInvocations), mMaxGeometryShaderInvocations(resources.MaxGeometryShaderInvocations),
mMaxGeometryShaderMaxVertices(resources.MaxGeometryOutputVertices), mMaxGeometryShaderMaxVertices(resources.MaxGeometryOutputVertices),
mGeometryShaderInputArraySize(0u) mGlInVariableWithArraySize(nullptr)
{ {
} }
...@@ -1896,10 +1896,8 @@ TIntermTyped *TParseContext::parseVariableIdentifier(const TSourceLoc &location, ...@@ -1896,10 +1896,8 @@ TIntermTyped *TParseContext::parseVariableIdentifier(const TSourceLoc &location,
else if ((mGeometryShaderInputPrimitiveType != EptUndefined) && else if ((mGeometryShaderInputPrimitiveType != EptUndefined) &&
(variableType.getQualifier() == EvqPerVertexIn)) (variableType.getQualifier() == EvqPerVertexIn))
{ {
ASSERT(mGeometryShaderInputArraySize > 0u); ASSERT(mGlInVariableWithArraySize != nullptr);
node = new TIntermSymbol(mGlInVariableWithArraySize);
node = new TIntermSymbol(variable);
node->getTypePointer()->sizeOutermostUnsizedArray(mGeometryShaderInputArraySize);
} }
else else
{ {
...@@ -2375,8 +2373,9 @@ void TParseContext::checkGeometryShaderInputAndSetArraySize(const TSourceLoc &lo ...@@ -2375,8 +2373,9 @@ void TParseContext::checkGeometryShaderInputAndSetArraySize(const TSourceLoc &lo
// input primitive declaration. // input primitive declaration.
if (mGeometryShaderInputPrimitiveType != EptUndefined) if (mGeometryShaderInputPrimitiveType != EptUndefined)
{ {
ASSERT(mGeometryShaderInputArraySize > 0u); ASSERT(mGlInVariableWithArraySize != nullptr);
type->sizeOutermostUnsizedArray(mGeometryShaderInputArraySize); type->sizeOutermostUnsizedArray(
mGlInVariableWithArraySize->getType().getOutermostArraySize());
} }
else else
{ {
...@@ -2846,11 +2845,17 @@ bool TParseContext::checkPrimitiveTypeMatchesTypeQualifier(const TTypeQualifier ...@@ -2846,11 +2845,17 @@ bool TParseContext::checkPrimitiveTypeMatchesTypeQualifier(const TTypeQualifier
void TParseContext::setGeometryShaderInputArraySize(unsigned int inputArraySize, void TParseContext::setGeometryShaderInputArraySize(unsigned int inputArraySize,
const TSourceLoc &line) const TSourceLoc &line)
{ {
if (mGeometryShaderInputArraySize == 0u) if (mGlInVariableWithArraySize == nullptr)
{ {
mGeometryShaderInputArraySize = inputArraySize; TSymbol *glPerVertex = symbolTable.findBuiltIn("gl_PerVertex", 310);
TInterfaceBlock *glPerVertexBlock = static_cast<TInterfaceBlock *>(glPerVertex);
TType glInType(glPerVertexBlock, EvqPerVertexIn, TLayoutQualifier::Create());
glInType.makeArray(inputArraySize);
mGlInVariableWithArraySize =
new TVariable(&symbolTable, NewPoolTString("gl_in"), glInType, SymbolType::BuiltIn,
TExtension::EXT_geometry_shader);
} }
else if (mGeometryShaderInputArraySize != inputArraySize) else if (mGlInVariableWithArraySize->getType().getOutermostArraySize() != inputArraySize)
{ {
error(line, error(line,
"Array size or input primitive declaration doesn't match the size of earlier sized " "Array size or input primitive declaration doesn't match the size of earlier sized "
......
...@@ -648,8 +648,9 @@ class TParseContext : angle::NonCopyable ...@@ -648,8 +648,9 @@ class TParseContext : angle::NonCopyable
int mMaxGeometryShaderInvocations; int mMaxGeometryShaderInvocations;
int mMaxGeometryShaderMaxVertices; int mMaxGeometryShaderMaxVertices;
// Track if all input array sizes are same and matches the latter input primitive declaration. // Store gl_in variable with its array size once the array size can be determined. The array
unsigned int mGeometryShaderInputArraySize; // size can also be checked against latter input primitive type declaration.
const TVariable *mGlInVariableWithArraySize;
}; };
int PaParseStrings(size_t count, int PaParseStrings(size_t count,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment