blob: 43ee78ccab6325a1f28cba48fbac7f72aeee28e1 [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
2// Copyright (c) 2002-2010 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#ifndef COMPILER_OUTPUTHLSL_H_
8#define COMPILER_OUTPUTHLSL_H_
9
10#include "intermediate.h"
11#include "ParseHelper.h"
12
13namespace sh
14{
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000015class OutputHLSL : public TIntermTraverser
16{
17 public:
18 OutputHLSL(TParseContext &context);
19
daniel@transgaming.com950f9932010-04-13 03:26:14 +000020 void output();
21
22 protected:
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000023 void header();
daniel@transgaming.come78c0c92010-03-28 19:36:06 +000024 void footer();
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000025
daniel@transgaming.com950f9932010-04-13 03:26:14 +000026 // Visit AST nodes and output their code to the body stream
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000027 void visitSymbol(TIntermSymbol*);
28 void visitConstantUnion(TIntermConstantUnion*);
29 bool visitBinary(Visit visit, TIntermBinary*);
30 bool visitUnary(Visit visit, TIntermUnary*);
31 bool visitSelection(Visit visit, TIntermSelection*);
32 bool visitAggregate(Visit visit, TIntermAggregate*);
33 bool visitLoop(Visit visit, TIntermLoop*);
34 bool visitBranch(Visit visit, TIntermBranch*);
35
daniel@transgaming.com4a35ef22010-04-08 03:51:06 +000036 bool handleExcessiveLoop(TIntermLoop *node);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000037 void outputTriplet(Visit visit, const char *preString, const char *inString, const char *postString);
38
daniel@transgaming.comd1acd1e2010-04-13 03:25:57 +000039 static TString argumentString(const TIntermSymbol *symbol);
40 static TString qualifierString(TQualifier qualifier);
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000041 static TString typeString(const TType &type);
42 static TString arrayString(const TType &type);
43 static TString initializer(const TType &type);
daniel@transgaming.com72d0b522010-04-13 19:53:44 +000044 static TString decorate(const TString &string); // Prepend an underscore to avoid naming clashes
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000045
daniel@transgaming.com950f9932010-04-13 03:26:14 +000046 TParseContext &mContext;
47
48 // Output streams
49 TInfoSinkBase mHeader;
50 TInfoSinkBase mBody;
51 TInfoSinkBase mFooter;
daniel@transgaming.comd91cfe72010-04-13 03:26:17 +000052
53 // Parameters determining what goes in the header output
54 bool mUsesEqualMat2;
55 bool mUsesEqualMat3;
56 bool mUsesEqualMat4;
57 bool mUsesEqualVec2;
58 bool mUsesEqualVec3;
59 bool mUsesEqualVec4;
60 bool mUsesEqualIVec2;
61 bool mUsesEqualIVec3;
62 bool mUsesEqualIVec4;
63 bool mUsesEqualBVec2;
64 bool mUsesEqualBVec3;
65 bool mUsesEqualBVec4;
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +000066};
67}
68
69#endif // COMPILER_OUTPUTHLSL_H_