Commit 173f1c94 by Jamie Madill Committed by Commit Bot

Translator: Collect gl_in as a varying.

This unifies the variable handling for IO blocks. Previously the gl_in block we treated as an "in block" similar to an interface block. Bug: angleproject:5423 Change-Id: Idf2db4c209055fa9ffca567dab39c89464eba156 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2571966Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 51a0e95d
...@@ -51,10 +51,6 @@ enum class BlockType ...@@ -51,10 +51,6 @@ enum class BlockType
{ {
BLOCK_UNIFORM, BLOCK_UNIFORM,
BLOCK_BUFFER, BLOCK_BUFFER,
// TODO: Remove gl_in from interface blocks and place it in varyings with the rest of shader I/O
// blocks, then remove GetInBlocks and getInBlocks everywhere. http://anglebug.com/5423
BLOCK_IN
}; };
// Base class for all variables defined in shaders, including Varyings, Uniforms, etc // Base class for all variables defined in shaders, including Varyings, Uniforms, etc
......
...@@ -1097,6 +1097,8 @@ inline bool IsShaderIoBlock(TQualifier qualifier) ...@@ -1097,6 +1097,8 @@ inline bool IsShaderIoBlock(TQualifier qualifier)
{ {
switch (qualifier) switch (qualifier)
{ {
case EvqPerVertexIn:
case EvqPerVertexOut:
case EvqVertexOut: case EvqVertexOut:
case EvqTessControlIn: case EvqTessControlIn:
case EvqTessControlOut: case EvqTessControlOut:
......
...@@ -46,8 +46,6 @@ BlockType GetBlockType(TQualifier qualifier) ...@@ -46,8 +46,6 @@ BlockType GetBlockType(TQualifier qualifier)
return BlockType::BLOCK_UNIFORM; return BlockType::BLOCK_UNIFORM;
case EvqBuffer: case EvqBuffer:
return BlockType::BLOCK_BUFFER; return BlockType::BLOCK_BUFFER;
case EvqPerVertexIn:
return BlockType::BLOCK_IN;
default: default:
UNREACHABLE(); UNREACHABLE();
return BlockType::BLOCK_UNIFORM; return BlockType::BLOCK_UNIFORM;
...@@ -123,7 +121,6 @@ class CollectVariablesTraverser : public TIntermTraverser ...@@ -123,7 +121,6 @@ class CollectVariablesTraverser : public TIntermTraverser
std::vector<ShaderVariable> *sharedVariables, std::vector<ShaderVariable> *sharedVariables,
std::vector<InterfaceBlock> *uniformBlocks, std::vector<InterfaceBlock> *uniformBlocks,
std::vector<InterfaceBlock> *shaderStorageBlocks, std::vector<InterfaceBlock> *shaderStorageBlocks,
std::vector<InterfaceBlock> *inBlocks,
ShHashFunction64 hashFunction, ShHashFunction64 hashFunction,
TSymbolTable *symbolTable, TSymbolTable *symbolTable,
GLenum shaderType, GLenum shaderType,
...@@ -166,7 +163,6 @@ class CollectVariablesTraverser : public TIntermTraverser ...@@ -166,7 +163,6 @@ class CollectVariablesTraverser : public TIntermTraverser
std::vector<ShaderVariable> *varyings); std::vector<ShaderVariable> *varyings);
void recordBuiltInFragmentOutputUsed(const TVariable &variable, bool *addedFlag); void recordBuiltInFragmentOutputUsed(const TVariable &variable, bool *addedFlag);
void recordBuiltInAttributeUsed(const TVariable &variable, bool *addedFlag); void recordBuiltInAttributeUsed(const TVariable &variable, bool *addedFlag);
InterfaceBlock *recordGLInUsed(const TType &glInType);
InterfaceBlock *findNamedInterfaceBlock(const ImmutableString &name) const; InterfaceBlock *findNamedInterfaceBlock(const ImmutableString &name) const;
std::vector<ShaderVariable> *mAttribs; std::vector<ShaderVariable> *mAttribs;
...@@ -177,7 +173,6 @@ class CollectVariablesTraverser : public TIntermTraverser ...@@ -177,7 +173,6 @@ class CollectVariablesTraverser : public TIntermTraverser
std::vector<ShaderVariable> *mSharedVariables; std::vector<ShaderVariable> *mSharedVariables;
std::vector<InterfaceBlock> *mUniformBlocks; std::vector<InterfaceBlock> *mUniformBlocks;
std::vector<InterfaceBlock> *mShaderStorageBlocks; std::vector<InterfaceBlock> *mShaderStorageBlocks;
std::vector<InterfaceBlock> *mInBlocks;
std::map<std::string, ShaderVariable *> mInterfaceBlockFields; std::map<std::string, ShaderVariable *> mInterfaceBlockFields;
...@@ -248,7 +243,6 @@ CollectVariablesTraverser::CollectVariablesTraverser( ...@@ -248,7 +243,6 @@ CollectVariablesTraverser::CollectVariablesTraverser(
std::vector<sh::ShaderVariable> *sharedVariables, std::vector<sh::ShaderVariable> *sharedVariables,
std::vector<sh::InterfaceBlock> *uniformBlocks, std::vector<sh::InterfaceBlock> *uniformBlocks,
std::vector<sh::InterfaceBlock> *shaderStorageBlocks, std::vector<sh::InterfaceBlock> *shaderStorageBlocks,
std::vector<sh::InterfaceBlock> *inBlocks,
ShHashFunction64 hashFunction, ShHashFunction64 hashFunction,
TSymbolTable *symbolTable, TSymbolTable *symbolTable,
GLenum shaderType, GLenum shaderType,
...@@ -262,7 +256,6 @@ CollectVariablesTraverser::CollectVariablesTraverser( ...@@ -262,7 +256,6 @@ CollectVariablesTraverser::CollectVariablesTraverser(
mSharedVariables(sharedVariables), mSharedVariables(sharedVariables),
mUniformBlocks(uniformBlocks), mUniformBlocks(uniformBlocks),
mShaderStorageBlocks(shaderStorageBlocks), mShaderStorageBlocks(shaderStorageBlocks),
mInBlocks(inBlocks),
mDepthRangeAdded(false), mDepthRangeAdded(false),
mNumSamplesAdded(false), mNumSamplesAdded(false),
mNumWorkGroupsAdded(false), mNumWorkGroupsAdded(false),
...@@ -317,7 +310,10 @@ void CollectVariablesTraverser::setBuiltInInfoFromSymbol(const TVariable &variab ...@@ -317,7 +310,10 @@ void CollectVariablesTraverser::setBuiltInInfoFromSymbol(const TVariable &variab
info->name = variable.name().data(); info->name = variable.name().data();
info->mappedName = variable.name().data(); info->mappedName = variable.name().data();
setFieldOrVariableProperties(type, true, false, info); bool isShaderIOBlock =
IsShaderIoBlock(type.getQualifier()) && type.getInterfaceBlock() != nullptr;
setFieldOrVariableProperties(type, true, isShaderIOBlock, info);
} }
void CollectVariablesTraverser::recordBuiltInVaryingUsed(const TVariable &variable, void CollectVariablesTraverser::recordBuiltInVaryingUsed(const TVariable &variable,
...@@ -364,24 +360,6 @@ void CollectVariablesTraverser::recordBuiltInAttributeUsed(const TVariable &vari ...@@ -364,24 +360,6 @@ void CollectVariablesTraverser::recordBuiltInAttributeUsed(const TVariable &vari
} }
} }
InterfaceBlock *CollectVariablesTraverser::recordGLInUsed(const TType &glInType)
{
if (!mPerVertexInAdded)
{
ASSERT(glInType.getQualifier() == EvqPerVertexIn);
InterfaceBlock info;
recordInterfaceBlock("gl_in", glInType, &info);
mPerVertexInAdded = true;
mInBlocks->push_back(info);
return &mInBlocks->back();
}
else
{
return FindVariable(ImmutableString("gl_PerVertex"), mInBlocks);
}
}
bool CollectVariablesTraverser::visitGlobalQualifierDeclaration( bool CollectVariablesTraverser::visitGlobalQualifierDeclaration(
Visit visit, Visit visit,
TIntermGlobalQualifierDeclaration *node) TIntermGlobalQualifierDeclaration *node)
...@@ -724,10 +702,8 @@ void CollectVariablesTraverser::setFieldOrVariableProperties(const TType &type, ...@@ -724,10 +702,8 @@ void CollectVariablesTraverser::setFieldOrVariableProperties(const TType &type,
variableOut->fields.push_back(fieldVariable); variableOut->fields.push_back(fieldVariable);
} }
} }
else if (interfaceBlock && interfaceBlock->symbolType() != SymbolType::BuiltIn) else if (interfaceBlock && isShaderIOBlock)
{ {
ASSERT(isShaderIOBlock);
variableOut->type = GL_NONE; variableOut->type = GL_NONE;
if (interfaceBlock->symbolType() != SymbolType::Empty) if (interfaceBlock->symbolType() != SymbolType::Empty)
{ {
...@@ -1119,31 +1095,28 @@ bool CollectVariablesTraverser::visitBinary(Visit, TIntermBinary *binaryNode) ...@@ -1119,31 +1095,28 @@ bool CollectVariablesTraverser::visitBinary(Visit, TIntermBinary *binaryNode)
bool traverseIndexExpression = false; bool traverseIndexExpression = false;
TIntermBinary *interfaceIndexingNode = blockNode->getAsBinaryNode(); TIntermBinary *interfaceIndexingNode = blockNode->getAsBinaryNode();
TIntermTyped *interfaceNode = blockNode;
if (interfaceIndexingNode) if (interfaceIndexingNode)
{ {
interfaceNode = interfaceIndexingNode->getLeft()->getAsTyped(); ASSERT(interfaceIndexingNode->getOp() == EOpIndexDirect ||
ASSERT(interfaceNode); interfaceIndexingNode->getOp() == EOpIndexIndirect);
const TType &interfaceType = interfaceNode->getType();
if (interfaceType.getQualifier() == EvqPerVertexIn)
{
namedBlock = recordGLInUsed(interfaceType);
ASSERT(namedBlock);
}
// We need to continue traversing to collect useful variables in the index expression
// of the interface block array or gl_in in the case of the if above.
traverseIndexExpression = true; traverseIndexExpression = true;
blockNode = interfaceIndexingNode->getLeft();
} }
const TType &interfaceNodeType = interfaceNode->getType(); const TType &interfaceNodeType = blockNode->getType();
const TInterfaceBlock *interfaceBlock = interfaceNodeType.getInterfaceBlock(); const TInterfaceBlock *interfaceBlock = interfaceNodeType.getInterfaceBlock();
const TQualifier qualifier = interfaceNodeType.getQualifier(); const TQualifier qualifier = interfaceNodeType.getQualifier();
// If it's a shader I/O block, look in varyings // If it's a shader I/O block, look in varyings
ShaderVariable *ioBlockVar = nullptr; ShaderVariable *ioBlockVar = nullptr;
if (IsVaryingIn(qualifier)) if (qualifier == EvqPerVertexIn)
{
TIntermSymbol *symbolNode = blockNode->getAsSymbolNode();
ASSERT(symbolNode);
recordBuiltInVaryingUsed(symbolNode->variable(), &mPerVertexInAdded, mInputVaryings);
ioBlockVar = FindShaderIOBlockVariable(interfaceBlock->name(), mInputVaryings);
}
else if (IsVaryingIn(qualifier))
{ {
ioBlockVar = FindShaderIOBlockVariable(interfaceBlock->name(), mInputVaryings); ioBlockVar = FindShaderIOBlockVariable(interfaceBlock->name(), mInputVaryings);
} }
...@@ -1196,7 +1169,6 @@ void CollectVariables(TIntermBlock *root, ...@@ -1196,7 +1169,6 @@ void CollectVariables(TIntermBlock *root,
std::vector<ShaderVariable> *sharedVariables, std::vector<ShaderVariable> *sharedVariables,
std::vector<InterfaceBlock> *uniformBlocks, std::vector<InterfaceBlock> *uniformBlocks,
std::vector<InterfaceBlock> *shaderStorageBlocks, std::vector<InterfaceBlock> *shaderStorageBlocks,
std::vector<InterfaceBlock> *inBlocks,
ShHashFunction64 hashFunction, ShHashFunction64 hashFunction,
TSymbolTable *symbolTable, TSymbolTable *symbolTable,
GLenum shaderType, GLenum shaderType,
...@@ -1204,8 +1176,8 @@ void CollectVariables(TIntermBlock *root, ...@@ -1204,8 +1176,8 @@ void CollectVariables(TIntermBlock *root,
{ {
CollectVariablesTraverser collect(attributes, outputVariables, uniforms, inputVaryings, CollectVariablesTraverser collect(attributes, outputVariables, uniforms, inputVaryings,
outputVaryings, sharedVariables, uniformBlocks, outputVaryings, sharedVariables, uniformBlocks,
shaderStorageBlocks, inBlocks, hashFunction, symbolTable, shaderStorageBlocks, hashFunction, symbolTable, shaderType,
shaderType, extensionBehavior); extensionBehavior);
root->traverse(&collect); root->traverse(&collect);
} }
......
...@@ -27,7 +27,6 @@ void CollectVariables(TIntermBlock *root, ...@@ -27,7 +27,6 @@ void CollectVariables(TIntermBlock *root,
std::vector<ShaderVariable> *sharedVariables, std::vector<ShaderVariable> *sharedVariables,
std::vector<InterfaceBlock> *uniformBlocks, std::vector<InterfaceBlock> *uniformBlocks,
std::vector<InterfaceBlock> *shaderStorageBlocks, std::vector<InterfaceBlock> *shaderStorageBlocks,
std::vector<InterfaceBlock> *inBlocks,
ShHashFunction64 hashFunction, ShHashFunction64 hashFunction,
TSymbolTable *symbolTable, TSymbolTable *symbolTable,
GLenum shaderType, GLenum shaderType,
......
...@@ -806,8 +806,8 @@ bool TCompiler::checkAndSimplifyAST(TIntermBlock *root, ...@@ -806,8 +806,8 @@ bool TCompiler::checkAndSimplifyAST(TIntermBlock *root,
ASSERT(!mVariablesCollected); ASSERT(!mVariablesCollected);
CollectVariables(root, &mAttributes, &mOutputVariables, &mUniforms, &mInputVaryings, CollectVariables(root, &mAttributes, &mOutputVariables, &mUniforms, &mInputVaryings,
&mOutputVaryings, &mSharedVariables, &mUniformBlocks, &mOutputVaryings, &mSharedVariables, &mUniformBlocks,
&mShaderStorageBlocks, &mInBlocks, mResources.HashFunction, &mSymbolTable, &mShaderStorageBlocks, mResources.HashFunction, &mSymbolTable, mShaderType,
mShaderType, mExtensionBehavior); mExtensionBehavior);
collectInterfaceBlocks(); collectInterfaceBlocks();
mVariablesCollected = true; mVariablesCollected = true;
if (compileOptions & SH_USE_UNUSED_STANDARD_SHARED_BLOCKS) if (compileOptions & SH_USE_UNUSED_STANDARD_SHARED_BLOCKS)
...@@ -1156,12 +1156,10 @@ void TCompiler::setResourceString() ...@@ -1156,12 +1156,10 @@ void TCompiler::setResourceString()
void TCompiler::collectInterfaceBlocks() void TCompiler::collectInterfaceBlocks()
{ {
ASSERT(mInterfaceBlocks.empty()); ASSERT(mInterfaceBlocks.empty());
mInterfaceBlocks.reserve(mUniformBlocks.size() + mShaderStorageBlocks.size() + mInterfaceBlocks.reserve(mUniformBlocks.size() + mShaderStorageBlocks.size());
mInBlocks.size());
mInterfaceBlocks.insert(mInterfaceBlocks.end(), mUniformBlocks.begin(), mUniformBlocks.end()); mInterfaceBlocks.insert(mInterfaceBlocks.end(), mUniformBlocks.begin(), mUniformBlocks.end());
mInterfaceBlocks.insert(mInterfaceBlocks.end(), mShaderStorageBlocks.begin(), mInterfaceBlocks.insert(mInterfaceBlocks.end(), mShaderStorageBlocks.begin(),
mShaderStorageBlocks.end()); mShaderStorageBlocks.end());
mInterfaceBlocks.insert(mInterfaceBlocks.end(), mInBlocks.begin(), mInBlocks.end());
} }
bool TCompiler::emulatePrecisionIfNeeded(TIntermBlock *root, bool TCompiler::emulatePrecisionIfNeeded(TIntermBlock *root,
...@@ -1201,7 +1199,6 @@ void TCompiler::clearResults() ...@@ -1201,7 +1199,6 @@ void TCompiler::clearResults()
mInterfaceBlocks.clear(); mInterfaceBlocks.clear();
mUniformBlocks.clear(); mUniformBlocks.clear();
mShaderStorageBlocks.clear(); mShaderStorageBlocks.clear();
mInBlocks.clear();
mVariablesCollected = false; mVariablesCollected = false;
mGLPositionInitialized = false; mGLPositionInitialized = false;
...@@ -1249,7 +1246,7 @@ bool TCompiler::checkCallDepth() ...@@ -1249,7 +1246,7 @@ bool TCompiler::checkCallDepth()
int depth = 0; int depth = 0;
const CallDAG::Record &record = mCallDag.getRecordFromIndex(i); const CallDAG::Record &record = mCallDag.getRecordFromIndex(i);
for (const int &calleeIndex : record.callees) for (int calleeIndex : record.callees)
{ {
depth = std::max(depth, depths[calleeIndex] + 1); depth = std::max(depth, depths[calleeIndex] + 1);
} }
......
...@@ -123,7 +123,6 @@ class TCompiler : public TShHandleBase ...@@ -123,7 +123,6 @@ class TCompiler : public TShHandleBase
{ {
return mShaderStorageBlocks; return mShaderStorageBlocks;
} }
const std::vector<sh::InterfaceBlock> &getInBlocks() const { return mInBlocks; }
ShHashFunction64 getHashFunction() const { return mResources.HashFunction; } ShHashFunction64 getHashFunction() const { return mResources.HashFunction; }
NameMap &getNameMap() { return mNameMap; } NameMap &getNameMap() { return mNameMap; }
...@@ -195,7 +194,6 @@ class TCompiler : public TShHandleBase ...@@ -195,7 +194,6 @@ class TCompiler : public TShHandleBase
std::vector<sh::InterfaceBlock> mInterfaceBlocks; std::vector<sh::InterfaceBlock> mInterfaceBlocks;
std::vector<sh::InterfaceBlock> mUniformBlocks; std::vector<sh::InterfaceBlock> mUniformBlocks;
std::vector<sh::InterfaceBlock> mShaderStorageBlocks; std::vector<sh::InterfaceBlock> mShaderStorageBlocks;
std::vector<sh::InterfaceBlock> mInBlocks;
// Specialization constant usage bits // Specialization constant usage bits
SpecConstUsageBits mSpecConstUsageBits; SpecConstUsageBits mSpecConstUsageBits;
......
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