Corentin Wallez | f4eab3b | 2015-03-18 12:55:45 -0700 | [diff] [blame] | 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 | class CallDAG; |
| 16 | class TIntermNode; |
| 17 | class TIntermSelection; |
| 18 | class TIntermLoop; |
| 19 | |
| 20 | struct ASTMetadataHLSL |
| 21 | { |
| 22 | ASTMetadataHLSL() |
Corentin Wallez | 5093145 | 2015-03-19 10:39:13 -0700 | [diff] [blame] | 23 | : mUsesGradient(false), |
| 24 | mCalledInDiscontinuousLoop(false), |
| 25 | mHasDiscontinuousLoopInCallGraph(false), |
| 26 | mNeedsLod0(false) |
Corentin Wallez | f4eab3b | 2015-03-18 12:55:45 -0700 | [diff] [blame] | 27 | { |
| 28 | } |
| 29 | |
| 30 | // Here "something uses a gradient" means here that it either contains a |
| 31 | // gradient operation, or a call to a function that uses a gradient. |
| 32 | bool hasGradientInCallGraph(TIntermSelection *node); |
| 33 | bool hasGradientInCallGraph(TIntermLoop *node); |
Corentin Wallez | 5093145 | 2015-03-19 10:39:13 -0700 | [diff] [blame] | 34 | bool hasDiscontinuousLoop(TIntermSelection *node); |
Corentin Wallez | f4eab3b | 2015-03-18 12:55:45 -0700 | [diff] [blame] | 35 | |
| 36 | // Does the function use a gradient. |
| 37 | bool mUsesGradient; |
| 38 | |
| 39 | // Even if usesGradient is true, some control flow might not use a gradient |
| 40 | // so we store the set of all gradient-using control flows. |
| 41 | std::set<TIntermNode*> mControlFlowsContainingGradient; |
Corentin Wallez | 5093145 | 2015-03-19 10:39:13 -0700 | [diff] [blame] | 42 | |
| 43 | // Remember information about the discontinuous loops and which functions |
| 44 | // are called in such loops. |
| 45 | bool mCalledInDiscontinuousLoop; |
| 46 | bool mHasDiscontinuousLoopInCallGraph; |
| 47 | std::set<TIntermLoop*> mDiscontinuousLoops; |
| 48 | std::set<TIntermSelection*> mIfsContainingDiscontinuousLoop; |
| 49 | |
| 50 | // Will we need to generate a Lod0 version of the function. |
| 51 | bool mNeedsLod0; |
Corentin Wallez | f4eab3b | 2015-03-18 12:55:45 -0700 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | typedef std::vector<ASTMetadataHLSL> MetadataList; |
| 55 | |
| 56 | // Return the AST analysis result, in the order defined by the call DAG |
| 57 | MetadataList CreateASTMetadataHLSL(TIntermNode *root, const CallDAG &callDag); |
| 58 | |
| 59 | #endif // COMPILER_TRANSLATOR_ASTMETADATAHLSL_H_ |