gfx/angle/src/compiler/depgraph/DependencyGraph.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/angle/src/compiler/depgraph/DependencyGraph.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,97 @@
     1.4 +//
     1.5 +// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
     1.6 +// Use of this source code is governed by a BSD-style license that can be
     1.7 +// found in the LICENSE file.
     1.8 +//
     1.9 +
    1.10 +#pragma warning(disable: 4718)
    1.11 +
    1.12 +#include "compiler/depgraph/DependencyGraph.h"
    1.13 +#include "compiler/depgraph/DependencyGraphBuilder.h"
    1.14 +
    1.15 +TDependencyGraph::TDependencyGraph(TIntermNode* intermNode)
    1.16 +{
    1.17 +    TDependencyGraphBuilder::build(intermNode, this);
    1.18 +}
    1.19 +
    1.20 +TDependencyGraph::~TDependencyGraph()
    1.21 +{
    1.22 +    for (TGraphNodeVector::const_iterator iter = mAllNodes.begin(); iter != mAllNodes.end(); ++iter)
    1.23 +    {
    1.24 +        TGraphNode* node = *iter;
    1.25 +        delete node;
    1.26 +    }
    1.27 +}
    1.28 +
    1.29 +TGraphArgument* TDependencyGraph::createArgument(TIntermAggregate* intermFunctionCall,
    1.30 +                                                 int argumentNumber)
    1.31 +{
    1.32 +    TGraphArgument* argument = new TGraphArgument(intermFunctionCall, argumentNumber);
    1.33 +    mAllNodes.push_back(argument);
    1.34 +    return argument;
    1.35 +}
    1.36 +
    1.37 +TGraphFunctionCall* TDependencyGraph::createFunctionCall(TIntermAggregate* intermFunctionCall)
    1.38 +{
    1.39 +    TGraphFunctionCall* functionCall = new TGraphFunctionCall(intermFunctionCall);
    1.40 +    mAllNodes.push_back(functionCall);
    1.41 +    if (functionCall->getIntermFunctionCall()->isUserDefined())
    1.42 +        mUserDefinedFunctionCalls.push_back(functionCall);
    1.43 +    return functionCall;
    1.44 +}
    1.45 +
    1.46 +TGraphSymbol* TDependencyGraph::getOrCreateSymbol(TIntermSymbol* intermSymbol)
    1.47 +{
    1.48 +    TSymbolIdMap::const_iterator iter = mSymbolIdMap.find(intermSymbol->getId());
    1.49 +
    1.50 +    TGraphSymbol* symbol = NULL;
    1.51 +
    1.52 +    if (iter != mSymbolIdMap.end()) {
    1.53 +        TSymbolIdPair pair = *iter;
    1.54 +        symbol = pair.second;
    1.55 +    } else {
    1.56 +        symbol = new TGraphSymbol(intermSymbol);
    1.57 +        mAllNodes.push_back(symbol);
    1.58 +
    1.59 +        TSymbolIdPair pair(intermSymbol->getId(), symbol);
    1.60 +        mSymbolIdMap.insert(pair);
    1.61 +
    1.62 +        // We save all sampler symbols in a collection, so we can start graph traversals from them quickly.
    1.63 +        if (IsSampler(intermSymbol->getBasicType()))
    1.64 +            mSamplerSymbols.push_back(symbol);
    1.65 +    }
    1.66 +
    1.67 +    return symbol;
    1.68 +}
    1.69 +
    1.70 +TGraphSelection* TDependencyGraph::createSelection(TIntermSelection* intermSelection)
    1.71 +{
    1.72 +    TGraphSelection* selection = new TGraphSelection(intermSelection);
    1.73 +    mAllNodes.push_back(selection);
    1.74 +    return selection;
    1.75 +}
    1.76 +
    1.77 +TGraphLoop* TDependencyGraph::createLoop(TIntermLoop* intermLoop)
    1.78 +{
    1.79 +    TGraphLoop* loop = new TGraphLoop(intermLoop);
    1.80 +    mAllNodes.push_back(loop);
    1.81 +    return loop;
    1.82 +}
    1.83 +
    1.84 +TGraphLogicalOp* TDependencyGraph::createLogicalOp(TIntermBinary* intermLogicalOp)
    1.85 +{
    1.86 +    TGraphLogicalOp* logicalOp = new TGraphLogicalOp(intermLogicalOp);
    1.87 +    mAllNodes.push_back(logicalOp);
    1.88 +    return logicalOp;
    1.89 +}
    1.90 +
    1.91 +const char* TGraphLogicalOp::getOpString() const
    1.92 +{
    1.93 +    const char* opString = NULL;
    1.94 +    switch (getIntermLogicalOp()->getOp()) {
    1.95 +        case EOpLogicalAnd: opString = "and"; break;
    1.96 +        case EOpLogicalOr: opString = "or"; break;
    1.97 +        default: opString = "unknown"; break;
    1.98 +    }
    1.99 +    return opString;
   1.100 +}

mercurial