daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 1 | // |
| 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 | |
| 13 | namespace sh |
| 14 | { |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 15 | class OutputHLSL : public TIntermTraverser |
| 16 | { |
| 17 | public: |
| 18 | OutputHLSL(TParseContext &context); |
| 19 | |
daniel@transgaming.com | 950f993 | 2010-04-13 03:26:14 +0000 | [diff] [blame] | 20 | void output(); |
| 21 | |
| 22 | protected: |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 23 | void header(); |
daniel@transgaming.com | e78c0c9 | 2010-03-28 19:36:06 +0000 | [diff] [blame] | 24 | void footer(); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 25 | |
daniel@transgaming.com | 950f993 | 2010-04-13 03:26:14 +0000 | [diff] [blame] | 26 | // Visit AST nodes and output their code to the body stream |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 27 | 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.com | 4a35ef2 | 2010-04-08 03:51:06 +0000 | [diff] [blame] | 36 | bool handleExcessiveLoop(TIntermLoop *node); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 37 | void outputTriplet(Visit visit, const char *preString, const char *inString, const char *postString); |
| 38 | |
daniel@transgaming.com | d1acd1e | 2010-04-13 03:25:57 +0000 | [diff] [blame] | 39 | static TString argumentString(const TIntermSymbol *symbol); |
| 40 | static TString qualifierString(TQualifier qualifier); |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 41 | static TString typeString(const TType &type); |
| 42 | static TString arrayString(const TType &type); |
| 43 | static TString initializer(const TType &type); |
daniel@transgaming.com | 72d0b52 | 2010-04-13 19:53:44 +0000 | [diff] [blame] | 44 | static TString decorate(const TString &string); // Prepend an underscore to avoid naming clashes |
daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 45 | |
daniel@transgaming.com | 950f993 | 2010-04-13 03:26:14 +0000 | [diff] [blame] | 46 | TParseContext &mContext; |
| 47 | |
| 48 | // Output streams |
| 49 | TInfoSinkBase mHeader; |
| 50 | TInfoSinkBase mBody; |
| 51 | TInfoSinkBase mFooter; |
daniel@transgaming.com | d91cfe7 | 2010-04-13 03:26:17 +0000 | [diff] [blame] | 52 | |
| 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.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame] | 66 | }; |
| 67 | } |
| 68 | |
| 69 | #endif // COMPILER_OUTPUTHLSL_H_ |