1 // 2 // Copyright (c) 2002-2015 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 // Defines analyses of the AST needed for HLSL generation 8 9 #ifndef COMPILER_TRANSLATOR_ASTMETADATAHLSL_H_ 10 #define COMPILER_TRANSLATOR_ASTMETADATAHLSL_H_ 11 12 #include <set> 13 #include <vector> 14 15 namespace sh 16 { 17 18 class CallDAG; 19 class TIntermNode; 20 class TIntermIfElse; 21 class TIntermLoop; 22 23 struct ASTMetadataHLSL 24 { ASTMetadataHLSLASTMetadataHLSL25 ASTMetadataHLSL() 26 : mUsesGradient(false), 27 mCalledInDiscontinuousLoop(false), 28 mHasGradientLoopInCallGraph(false), 29 mNeedsLod0(false) 30 { 31 } 32 33 // Here "something uses a gradient" means here that it either contains a 34 // gradient operation, or a call to a function that uses a gradient. 35 bool hasGradientInCallGraph(TIntermLoop *node); 36 bool hasGradientLoop(TIntermIfElse *node); 37 38 // Does the function use a gradient. 39 bool mUsesGradient; 40 41 // Even if usesGradient is true, some control flow might not use a gradient 42 // so we store the set of all gradient-using control flows. 43 std::set<TIntermNode *> mControlFlowsContainingGradient; 44 45 // Remember information about the discontinuous loops and which functions 46 // are called in such loops. 47 bool mCalledInDiscontinuousLoop; 48 bool mHasGradientLoopInCallGraph; 49 std::set<TIntermLoop *> mDiscontinuousLoops; 50 std::set<TIntermIfElse *> mIfsContainingGradientLoop; 51 52 // Will we need to generate a Lod0 version of the function. 53 bool mNeedsLod0; 54 }; 55 56 typedef std::vector<ASTMetadataHLSL> MetadataList; 57 58 // Return the AST analysis result, in the order defined by the call DAG 59 MetadataList CreateASTMetadataHLSL(TIntermNode *root, const CallDAG &callDag); 60 61 } // namespace sh 62 63 #endif // COMPILER_TRANSLATOR_ASTMETADATAHLSL_H_ 64