Commit 283c2194 by Olli Etuaho Committed by Commit Bot

Support arrays of arrays in UseInterfaceBlockFields

This can be tested more fully once parsing arrays of arrays will be supported. BUG=angleproject:2125 Change-Id: I89c8f33b8cca5d6f5aa3f20aab23dccac53a956f Reviewed-on: https://chromium-review.googlesource.com/733128Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent e7c2857d
...@@ -22,35 +22,33 @@ namespace sh ...@@ -22,35 +22,33 @@ namespace sh
namespace namespace
{ {
void AddFieldUseStatements(const ShaderVariable &var, void AddNodeUseStatements(TIntermTyped *node, TIntermSequence *sequence)
TIntermSequence *sequence,
const TSymbolTable &symbolTable)
{ {
TString name = TString(var.name.c_str()); if (node->isArray())
if (var.isArray())
{
size_t pos = name.find_last_of('[');
if (pos != TString::npos)
{
name = name.substr(0, pos);
}
}
TIntermSymbol *symbol = ReferenceGlobalVariable(name, symbolTable);
if (var.isArray())
{ {
for (unsigned int i = 0u; i < var.arraySize; ++i) for (unsigned int i = 0u; i < node->getOutermostArraySize(); ++i)
{ {
TIntermBinary *element = TIntermBinary *element =
new TIntermBinary(EOpIndexDirect, symbol->deepCopy(), CreateIndexNode(i)); new TIntermBinary(EOpIndexDirect, node->deepCopy(), CreateIndexNode(i));
sequence->insert(sequence->begin(), element); AddNodeUseStatements(element, sequence);
} }
} }
else else
{ {
sequence->insert(sequence->begin(), symbol); sequence->insert(sequence->begin(), node);
} }
} }
void AddFieldUseStatements(const ShaderVariable &var,
TIntermSequence *sequence,
const TSymbolTable &symbolTable)
{
TString name = TString(var.name.c_str());
ASSERT(name.find_last_of('[') == TString::npos);
TIntermSymbol *symbol = ReferenceGlobalVariable(name, symbolTable);
AddNodeUseStatements(symbol, sequence);
}
void InsertUseCode(const InterfaceBlock &block, TIntermTyped *blockNode, TIntermSequence *sequence) void InsertUseCode(const InterfaceBlock &block, TIntermTyped *blockNode, TIntermSequence *sequence)
{ {
for (unsigned int i = 0; i < block.fields.size(); ++i) for (unsigned int i = 0; i < block.fields.size(); ++i)
......
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