blob: b9b334dbeb92ba1d9c7b556a16105f34bb5841c1 [file] [log] [blame]
Corentin Wallezf4eab3b2015-03-18 12:55:45 -07001//
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
15class CallDAG;
16class TIntermNode;
17class TIntermSelection;
18class TIntermLoop;
19
20struct ASTMetadataHLSL
21{
22 ASTMetadataHLSL()
Corentin Wallez50931452015-03-19 10:39:13 -070023 : mUsesGradient(false),
24 mCalledInDiscontinuousLoop(false),
25 mHasDiscontinuousLoopInCallGraph(false),
26 mNeedsLod0(false)
Corentin Wallezf4eab3b2015-03-18 12:55:45 -070027 {
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 Wallez50931452015-03-19 10:39:13 -070034 bool hasDiscontinuousLoop(TIntermSelection *node);
Corentin Wallezf4eab3b2015-03-18 12:55:45 -070035
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 Wallez50931452015-03-19 10:39:13 -070042
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 Wallezf4eab3b2015-03-18 12:55:45 -070052};
53
54typedef std::vector<ASTMetadataHLSL> MetadataList;
55
56// Return the AST analysis result, in the order defined by the call DAG
57MetadataList CreateASTMetadataHLSL(TIntermNode *root, const CallDAG &callDag);
58
59#endif // COMPILER_TRANSLATOR_ASTMETADATAHLSL_H_