Line data Source code
1 : //
2 : // Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
3 : // Use of this source code is governed by a BSD-style license that can be
4 : // found in the LICENSE file.
5 : //
6 :
7 : #include "compiler/translator/FlagStd140Structs.h"
8 :
9 : namespace sh
10 : {
11 :
12 0 : bool FlagStd140Structs::visitBinary(Visit visit, TIntermBinary *binaryNode)
13 : {
14 0 : if (binaryNode->getRight()->getBasicType() == EbtStruct)
15 : {
16 0 : switch (binaryNode->getOp())
17 : {
18 : case EOpIndexDirectInterfaceBlock:
19 : case EOpIndexDirectStruct:
20 0 : if (isInStd140InterfaceBlock(binaryNode->getLeft()))
21 : {
22 0 : mFlaggedNodes.push_back(binaryNode);
23 : }
24 0 : break;
25 :
26 0 : default: break;
27 : }
28 0 : return false;
29 : }
30 :
31 0 : if (binaryNode->getOp() == EOpIndexDirectStruct)
32 : {
33 0 : return false;
34 : }
35 :
36 0 : return visit == PreVisit;
37 : }
38 :
39 0 : void FlagStd140Structs::visitSymbol(TIntermSymbol *symbol)
40 : {
41 0 : if (isInStd140InterfaceBlock(symbol) && symbol->getBasicType() == EbtStruct)
42 : {
43 0 : mFlaggedNodes.push_back(symbol);
44 : }
45 0 : }
46 :
47 0 : bool FlagStd140Structs::isInStd140InterfaceBlock(TIntermTyped *node) const
48 : {
49 0 : TIntermBinary *binaryNode = node->getAsBinaryNode();
50 :
51 0 : if (binaryNode)
52 : {
53 0 : return isInStd140InterfaceBlock(binaryNode->getLeft());
54 : }
55 :
56 0 : const TType &type = node->getType();
57 :
58 : // determine if we are in the standard layout
59 0 : const TInterfaceBlock *interfaceBlock = type.getInterfaceBlock();
60 0 : if (interfaceBlock)
61 : {
62 0 : return (interfaceBlock->blockStorage() == EbsStd140);
63 : }
64 :
65 0 : return false;
66 : }
67 :
68 0 : std::vector<TIntermTyped *> FlagStd140ValueStructs(TIntermNode *node)
69 : {
70 0 : FlagStd140Structs flaggingTraversal;
71 :
72 0 : node->traverse(&flaggingTraversal);
73 :
74 0 : return flaggingTraversal.getFlaggedNodes();
75 : }
76 :
77 : }
|