blob: a751b768b78b9ac545e6afc62d42ab7edb655024 (
plain)
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
77
|
//
// 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.
//
#include "compiler/translator/FlagStd140Structs.h"
namespace sh
{
bool FlagStd140Structs::visitBinary(Visit visit, TIntermBinary *binaryNode)
{
if (binaryNode->getRight()->getBasicType() == EbtStruct)
{
switch (binaryNode->getOp())
{
case EOpIndexDirectInterfaceBlock:
case EOpIndexDirectStruct:
if (isInStd140InterfaceBlock(binaryNode->getLeft()))
{
mFlaggedNodes.push_back(binaryNode);
}
break;
default: break;
}
return false;
}
if (binaryNode->getOp() == EOpIndexDirectStruct)
{
return false;
}
return visit == PreVisit;
}
void FlagStd140Structs::visitSymbol(TIntermSymbol *symbol)
{
if (isInStd140InterfaceBlock(symbol) && symbol->getBasicType() == EbtStruct)
{
mFlaggedNodes.push_back(symbol);
}
}
bool FlagStd140Structs::isInStd140InterfaceBlock(TIntermTyped *node) const
{
TIntermBinary *binaryNode = node->getAsBinaryNode();
if (binaryNode)
{
return isInStd140InterfaceBlock(binaryNode->getLeft());
}
const TType &type = node->getType();
// determine if we are in the standard layout
const TInterfaceBlock *interfaceBlock = type.getInterfaceBlock();
if (interfaceBlock)
{
return (interfaceBlock->blockStorage() == EbsStd140);
}
return false;
}
std::vector<TIntermTyped *> FlagStd140ValueStructs(TIntermNode *node)
{
FlagStd140Structs flaggingTraversal;
node->traverse(&flaggingTraversal);
return flaggingTraversal.getFlaggedNodes();
}
}
|