Hash :
378c3a51
Author :
Date :
2017-12-04T11:32:13
Clean up storing interface blocks in the symbol table Merge TInterfaceBlock with TInterfaceBlockName, so that there are no duplicate data structures for interface blocks. This is similar to the refactoring that was already done to structs. BUG=angleproject:2267 TEST=angle_unittests Change-Id: I67d2af6ccbe5344bddf9c99030d118fe532fbbd8 Reviewed-on: https://chromium-review.googlesource.com/805819 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
//
// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// FlagStd140Structs.cpp: Find structs in std140 blocks, where the padding added in the translator
// conflicts with the "natural" unpadded type.
#include "compiler/translator/FlagStd140Structs.h"
#include "compiler/translator/IntermTraverse.h"
#include "compiler/translator/SymbolTable.h"
namespace sh
{
namespace
{
class FlagStd140StructsTraverser : public TIntermTraverser
{
public:
FlagStd140StructsTraverser() : TIntermTraverser(true, false, false) {}
const std::vector<MappedStruct> getMappedStructs() const { return mMappedStructs; }
protected:
bool visitDeclaration(Visit visit, TIntermDeclaration *node) override;
private:
void mapBlockStructMembers(TIntermSymbol *blockDeclarator, TInterfaceBlock *block);
std::vector<MappedStruct> mMappedStructs;
};
void FlagStd140StructsTraverser::mapBlockStructMembers(TIntermSymbol *blockDeclarator,
TInterfaceBlock *block)
{
for (auto *field : block->fields())
{
if (field->type()->getBasicType() == EbtStruct)
{
MappedStruct mappedStruct;
mappedStruct.blockDeclarator = blockDeclarator;
mappedStruct.field = field;
mMappedStructs.push_back(mappedStruct);
}
}
}
bool FlagStd140StructsTraverser::visitDeclaration(Visit visit, TIntermDeclaration *node)
{
TIntermTyped *declarator = node->getSequence()->back()->getAsTyped();
if (declarator->getBasicType() == EbtInterfaceBlock)
{
TInterfaceBlock *block = declarator->getType().getInterfaceBlock();
if (block->blockStorage() == EbsStd140)
{
mapBlockStructMembers(declarator->getAsSymbolNode(), block);
}
}
return false;
}
} // anonymous namespace
std::vector<MappedStruct> FlagStd140Structs(TIntermNode *node)
{
FlagStd140StructsTraverser flaggingTraversal;
node->traverse(&flaggingTraversal);
return flaggingTraversal.getMappedStructs();
}
} // namespace sh