OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SKSL_COMPILER | 8 #ifndef SKSL_COMPILER |
9 #define SKSL_COMPILER | 9 #define SKSL_COMPILER |
10 | 10 |
11 #include <vector> | 11 #include <vector> |
12 #include "ir/SkSLProgram.h" | 12 #include "ir/SkSLProgram.h" |
13 #include "ir/SkSLSymbolTable.h" | 13 #include "ir/SkSLSymbolTable.h" |
14 #include "SkSLContext.h" | 14 #include "SkSLContext.h" |
15 #include "SkSLErrorReporter.h" | 15 #include "SkSLErrorReporter.h" |
16 #include "SkSLGLSLCodeGenerator.h" | 16 #include "SkSLGLSLCodeGenerator.h" |
17 | 17 |
| 18 #define SK_FRAGCOLOR_BUILTIN 10001 |
| 19 |
18 namespace SkSL { | 20 namespace SkSL { |
19 | 21 |
20 class IRGenerator; | 22 class IRGenerator; |
21 | 23 |
22 /** | 24 /** |
23 * Main compiler entry point. This is a traditional compiler design which first
parses the .sksl | 25 * Main compiler entry point. This is a traditional compiler design which first
parses the .sksl |
24 * file into an abstract syntax tree (a tree of ASTNodes), then performs semanti
c analysis to | 26 * file into an abstract syntax tree (a tree of ASTNodes), then performs semanti
c analysis to |
25 * produce a Program (a tree of IRNodes), then feeds the Program into a CodeGene
rator to produce | 27 * produce a Program (a tree of IRNodes), then feeds the Program into a CodeGene
rator to produce |
26 * compiled output. | 28 * compiled output. |
| 29 * |
| 30 * See the README for information about SkSL. |
27 */ | 31 */ |
28 class Compiler : public ErrorReporter { | 32 class Compiler : public ErrorReporter { |
29 public: | 33 public: |
30 Compiler(); | 34 Compiler(); |
31 | 35 |
32 ~Compiler(); | 36 ~Compiler(); |
33 | 37 |
34 std::unique_ptr<Program> convertProgram(Program::Kind kind, std::string text
); | 38 std::unique_ptr<Program> convertProgram(Program::Kind kind, std::string text
); |
35 | 39 |
36 bool toSPIRV(Program::Kind kind, const std::string& text, std::ostream& out)
; | 40 bool toSPIRV(Program::Kind kind, const std::string& text, std::ostream& out)
; |
37 | 41 |
38 bool toSPIRV(Program::Kind kind, const std::string& text, std::string* out); | 42 bool toSPIRV(Program::Kind kind, const std::string& text, std::string* out); |
39 | 43 |
40 bool toGLSL(Program::Kind kind, const std::string& text, GLCaps caps, std::o
stream& out); | 44 bool toGLSL(Program::Kind kind, const std::string& text, GLCaps caps, std::o
stream& out); |
41 | 45 |
42 bool toGLSL(Program::Kind kind, const std::string& text, GLCaps caps, std::s
tring* out); | 46 bool toGLSL(Program::Kind kind, const std::string& text, GLCaps caps, std::s
tring* out); |
43 | 47 |
44 void error(Position position, std::string msg) override; | 48 void error(Position position, std::string msg) override; |
45 | 49 |
46 std::string errorText(); | 50 std::string errorText(); |
47 | 51 |
48 void writeErrorCount(); | 52 void writeErrorCount(); |
49 | 53 |
50 private: | 54 private: |
51 | 55 |
52 void internalConvertProgram(std::string text, | 56 void internalConvertProgram(std::string text, |
| 57 Modifiers::Flag* defaultPrecision, |
53 std::vector<std::unique_ptr<ProgramElement>>* re
sult); | 58 std::vector<std::unique_ptr<ProgramElement>>* re
sult); |
54 | 59 |
55 std::shared_ptr<SymbolTable> fTypes; | 60 std::shared_ptr<SymbolTable> fTypes; |
56 IRGenerator* fIRGenerator; | 61 IRGenerator* fIRGenerator; |
57 std::string fSkiaVertText; // FIXME store parsed version instead | 62 std::string fSkiaVertText; // FIXME store parsed version instead |
58 | 63 |
59 Context fContext; | 64 Context fContext; |
60 int fErrorCount; | 65 int fErrorCount; |
61 std::string fErrorText; | 66 std::string fErrorText; |
62 }; | 67 }; |
63 | 68 |
64 } // namespace | 69 } // namespace |
65 | 70 |
66 #endif | 71 #endif |
OLD | NEW |