ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
Ethan Nicholas | 0df1b04 | 2017-03-31 13:56:23 -0400 | [diff] [blame] | 7 | |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 8 | #ifndef SKSL_COMPILER |
| 9 | #define SKSL_COMPILER |
| 10 | |
ethannicholas | 22f939e | 2016-10-13 13:25:34 -0700 | [diff] [blame] | 11 | #include <set> |
Ethan Nicholas | cb67096 | 2017-04-20 19:31:52 -0400 | [diff] [blame] | 12 | #include <unordered_set> |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 13 | #include <vector> |
Ethan Nicholas | db80f69 | 2019-11-22 14:06:12 -0500 | [diff] [blame] | 14 | #include "src/sksl/SkSLASTFile.h" |
Brian Osman | 010ce6a | 2020-10-19 16:34:10 -0400 | [diff] [blame] | 15 | #include "src/sksl/SkSLAnalysis.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 16 | #include "src/sksl/SkSLContext.h" |
John Stiles | 7b46300 | 2020-08-31 17:29:21 -0400 | [diff] [blame] | 17 | #include "src/sksl/SkSLInliner.h" |
Ethan Nicholas | 55a63af | 2021-05-18 10:12:58 -0400 | [diff] [blame] | 18 | #include "src/sksl/SkSLParsedModule.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 19 | #include "src/sksl/ir/SkSLProgram.h" |
| 20 | #include "src/sksl/ir/SkSLSymbolTable.h" |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 21 | |
Brian Osman | 2e29ab5 | 2019-09-20 12:19:11 -0400 | [diff] [blame] | 22 | #if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU |
| 23 | #include "src/gpu/GrShaderVar.h" |
| 24 | #endif |
| 25 | |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 26 | #define SK_FRAGCOLOR_BUILTIN 10001 |
Ethan Nicholas | eab2baa | 2018-04-13 15:16:27 -0400 | [diff] [blame] | 27 | #define SK_LASTFRAGCOLOR_BUILTIN 10008 |
Brian Osman | 7353dc5 | 2020-02-07 13:37:12 -0500 | [diff] [blame] | 28 | #define SK_MAIN_COORDS_BUILTIN 10009 |
Brian Osman | 577c606 | 2021-04-12 17:17:19 -0400 | [diff] [blame] | 29 | #define SK_INPUT_COLOR_BUILTIN 10010 |
John Stiles | 50d0d09 | 2021-06-09 17:24:31 -0400 | [diff] [blame] | 30 | #define SK_DEST_COLOR_BUILTIN 10011 |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 31 | #define SK_FRAGCOORD_BUILTIN 15 |
Chris Dalton | 49d14e9 | 2018-07-27 12:38:35 -0600 | [diff] [blame] | 32 | #define SK_CLOCKWISE_BUILTIN 17 |
Ethan Nicholas | 9eded2c | 2018-03-22 10:10:44 -0400 | [diff] [blame] | 33 | #define SK_VERTEXID_BUILTIN 42 |
| 34 | #define SK_INSTANCEID_BUILTIN 43 |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 35 | #define SK_POSITION_BUILTIN 0 |
ethannicholas | 5961bc9 | 2016-10-12 06:39:56 -0700 | [diff] [blame] | 36 | |
John Stiles | e615000 | 2020-10-05 12:03:53 -0400 | [diff] [blame] | 37 | class SkBitSet; |
Ethan Nicholas | ba9a04f | 2020-11-06 09:28:04 -0500 | [diff] [blame] | 38 | class SkSLCompileBench; |
John Stiles | e615000 | 2020-10-05 12:03:53 -0400 | [diff] [blame] | 39 | |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 40 | namespace SkSL { |
| 41 | |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 42 | namespace dsl { |
Ethan Nicholas | 4f3e6a2 | 2021-06-15 09:17:05 -0400 | [diff] [blame] | 43 | class DSLCore; |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 44 | class DSLWriter; |
| 45 | } |
| 46 | |
Brian Osman | be0b3b7 | 2021-01-06 14:27:35 -0500 | [diff] [blame] | 47 | class ExternalFunction; |
Brian Osman | 4fca995 | 2021-01-28 15:04:51 -0500 | [diff] [blame] | 48 | class FunctionDeclaration; |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 49 | class IRGenerator; |
Brian Osman | 2b469eb | 2020-09-21 11:32:10 -0400 | [diff] [blame] | 50 | class IRIntrinsicMap; |
Brian Osman | 010ce6a | 2020-10-19 16:34:10 -0400 | [diff] [blame] | 51 | class ProgramUsage; |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 52 | |
Brian Osman | 3d87e9f | 2020-10-08 11:50:22 -0400 | [diff] [blame] | 53 | struct LoadedModule { |
John Stiles | dbd4e6f | 2021-02-16 13:29:15 -0500 | [diff] [blame] | 54 | ProgramKind fKind; |
Brian Osman | 3d87e9f | 2020-10-08 11:50:22 -0400 | [diff] [blame] | 55 | std::shared_ptr<SymbolTable> fSymbols; |
| 56 | std::vector<std::unique_ptr<ProgramElement>> fElements; |
| 57 | }; |
| 58 | |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 59 | /** |
| 60 | * Main compiler entry point. This is a traditional compiler design which first parses the .sksl |
Ethan Nicholas | 941e7e2 | 2016-12-12 15:33:30 -0500 | [diff] [blame] | 61 | * file into an abstract syntax tree (a tree of ASTNodes), then performs semantic analysis to |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 62 | * produce a Program (a tree of IRNodes), then feeds the Program into a CodeGenerator to produce |
| 63 | * compiled output. |
ethannicholas | 5961bc9 | 2016-10-12 06:39:56 -0700 | [diff] [blame] | 64 | * |
| 65 | * See the README for information about SkSL. |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 66 | */ |
Ethan Nicholas | 4a5e22a | 2021-08-13 17:29:51 -0400 | [diff] [blame] | 67 | class SK_API Compiler { |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 68 | public: |
Brian Salomon | 3e2fe2b | 2021-06-02 09:16:30 -0400 | [diff] [blame] | 69 | static constexpr const char FRAGCOLOR_NAME[] = "sk_FragColor"; |
John Stiles | e67bd13 | 2021-03-19 18:39:25 -0400 | [diff] [blame] | 70 | static constexpr const char RTADJUST_NAME[] = "sk_RTAdjust"; |
| 71 | static constexpr const char PERVERTEX_NAME[] = "sk_PerVertex"; |
Ethan Nicholas | 549c6b8 | 2021-06-25 12:31:44 -0400 | [diff] [blame] | 72 | static constexpr const char POISON_TAG[] = "<POISON>"; |
Robert Phillips | fe8da17 | 2018-01-24 14:52:02 +0000 | [diff] [blame] | 73 | |
Brian Salomon | 3e2fe2b | 2021-06-02 09:16:30 -0400 | [diff] [blame] | 74 | /** |
| 75 | * Gets a float4 that adjusts the position from Skia device coords to normalized device coords, |
| 76 | * used to populate sk_RTAdjust. Assuming the transformed position, pos, is a homogeneous |
| 77 | * float4, the vec, v, is applied as such: |
| 78 | * float4((pos.xy * v.xz) + sk_Position.ww * v.yw, 0, pos.w); |
| 79 | */ |
| 80 | static std::array<float, 4> GetRTAdjustVector(SkISize rtDims, bool flipY) { |
| 81 | std::array<float, 4> result; |
| 82 | result[0] = 2.f/rtDims.width(); |
| 83 | result[2] = 2.f/rtDims.height(); |
| 84 | result[1] = -1.f; |
| 85 | result[3] = -1.f; |
| 86 | if (flipY) { |
| 87 | result[2] = -result[2]; |
| 88 | result[3] = -result[3]; |
| 89 | } |
| 90 | return result; |
| 91 | } |
| 92 | |
Brian Salomon | d8d85b9 | 2021-07-07 09:41:17 -0400 | [diff] [blame] | 93 | /** |
| 94 | * Uniform values by the compiler to implement origin-neutral dFdy, sk_Clockwise, and |
| 95 | * sk_FragCoord. |
| 96 | */ |
| 97 | static std::array<float, 2> GetRTFlipVector(int rtHeight, bool flipY) { |
| 98 | std::array<float, 2> result; |
| 99 | result[0] = flipY ? rtHeight : 0.f; |
| 100 | result[1] = flipY ? -1.f : 1.f; |
| 101 | return result; |
| 102 | } |
| 103 | |
Ethan Nicholas | cdeae8c | 2020-10-22 14:39:46 -0400 | [diff] [blame] | 104 | struct OptimizationContext { |
| 105 | // nodes we have already reported errors for and should not error on again |
| 106 | std::unordered_set<const IRNode*> fSilences; |
| 107 | // true if we have updated the CFG during this pass |
| 108 | bool fUpdated = false; |
| 109 | // true if we need to completely regenerate the CFG |
| 110 | bool fNeedsRescan = false; |
Brian Osman | 010ce6a | 2020-10-19 16:34:10 -0400 | [diff] [blame] | 111 | // Metadata about function and variable usage within the program |
| 112 | ProgramUsage* fUsage = nullptr; |
Ethan Nicholas | 5b9b0db | 2021-01-21 13:12:01 -0500 | [diff] [blame] | 113 | // Nodes which we can't throw away until the end of optimization |
| 114 | StatementArray fOwnedStatements; |
Ethan Nicholas | cdeae8c | 2020-10-22 14:39:46 -0400 | [diff] [blame] | 115 | }; |
| 116 | |
John Stiles | d6a5f449 | 2021-02-11 15:46:11 -0500 | [diff] [blame] | 117 | Compiler(const ShaderCapsClass* caps); |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 118 | |
Ethan Nicholas | 4a5e22a | 2021-08-13 17:29:51 -0400 | [diff] [blame] | 119 | ~Compiler(); |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 120 | |
Brian Osman | 1400382 | 2019-04-10 11:47:26 -0400 | [diff] [blame] | 121 | Compiler(const Compiler&) = delete; |
| 122 | Compiler& operator=(const Compiler&) = delete; |
| 123 | |
Ethan Nicholas | 91164d1 | 2019-05-15 15:29:54 -0400 | [diff] [blame] | 124 | /** |
John Stiles | 2ee4d7a | 2021-03-30 10:30:47 -0400 | [diff] [blame] | 125 | * Allows optimization settings to be unilaterally overridden. This is meant to allow tools like |
| 126 | * Viewer or Nanobench to override the compiler's ProgramSettings and ShaderCaps for debugging. |
| 127 | */ |
| 128 | enum class OverrideFlag { |
| 129 | kDefault, |
| 130 | kOff, |
| 131 | kOn, |
| 132 | }; |
| 133 | static void EnableOptimizer(OverrideFlag flag) { sOptimizer = flag; } |
| 134 | static void EnableInliner(OverrideFlag flag) { sInliner = flag; } |
| 135 | |
| 136 | /** |
Ethan Nicholas | 55a63af | 2021-05-18 10:12:58 -0400 | [diff] [blame] | 137 | * If fExternalFunctions is supplied in the settings, those values are registered in the symbol |
| 138 | * table of the Program, but ownership is *not* transferred. It is up to the caller to keep them |
| 139 | * alive. |
Ethan Nicholas | 91164d1 | 2019-05-15 15:29:54 -0400 | [diff] [blame] | 140 | */ |
Brian Osman | 32d5355 | 2020-09-23 13:55:20 -0400 | [diff] [blame] | 141 | std::unique_ptr<Program> convertProgram( |
John Stiles | dbd4e6f | 2021-02-16 13:29:15 -0500 | [diff] [blame] | 142 | ProgramKind kind, |
Brian Osman | 32d5355 | 2020-09-23 13:55:20 -0400 | [diff] [blame] | 143 | String text, |
Ethan Nicholas | 55a63af | 2021-05-18 10:12:58 -0400 | [diff] [blame] | 144 | Program::Settings settings); |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 145 | |
Ethan Nicholas | 0054311 | 2018-07-31 09:44:36 -0400 | [diff] [blame] | 146 | bool toSPIRV(Program& program, OutputStream& out); |
Ethan Nicholas | 941e7e2 | 2016-12-12 15:33:30 -0500 | [diff] [blame] | 147 | |
Ethan Nicholas | 0054311 | 2018-07-31 09:44:36 -0400 | [diff] [blame] | 148 | bool toSPIRV(Program& program, String* out); |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 149 | |
Ethan Nicholas | 0054311 | 2018-07-31 09:44:36 -0400 | [diff] [blame] | 150 | bool toGLSL(Program& program, OutputStream& out); |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 151 | |
Ethan Nicholas | 0054311 | 2018-07-31 09:44:36 -0400 | [diff] [blame] | 152 | bool toGLSL(Program& program, String* out); |
Timothy Liang | b8eeb80 | 2018-07-23 16:46:16 -0400 | [diff] [blame] | 153 | |
Brian Osman | c024391 | 2020-02-19 15:35:26 -0500 | [diff] [blame] | 154 | bool toHLSL(Program& program, String* out); |
| 155 | |
Ethan Nicholas | 0054311 | 2018-07-31 09:44:36 -0400 | [diff] [blame] | 156 | bool toMetal(Program& program, OutputStream& out); |
Ethan Nicholas | 762466e | 2017-06-29 10:03:38 -0400 | [diff] [blame] | 157 | |
Ethan Nicholas | 0054311 | 2018-07-31 09:44:36 -0400 | [diff] [blame] | 158 | bool toMetal(Program& program, String* out); |
| 159 | |
Ethan Nicholas | 4a5e22a | 2021-08-13 17:29:51 -0400 | [diff] [blame] | 160 | void handleError(const char* msg, PositionInfo pos); |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 161 | |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 162 | String errorText(bool showCount = true); |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 163 | |
Ethan Nicholas | 39f6da4 | 2021-08-23 13:10:07 -0400 | [diff] [blame] | 164 | ErrorReporter& errorReporter() { return *fContext->fErrors; } |
Ethan Nicholas | 4a5e22a | 2021-08-13 17:29:51 -0400 | [diff] [blame] | 165 | |
Ethan Nicholas | 39f6da4 | 2021-08-23 13:10:07 -0400 | [diff] [blame] | 166 | int errorCount() const { return fContext->fErrors->errorCount(); } |
Ethan Nicholas | 4a5e22a | 2021-08-13 17:29:51 -0400 | [diff] [blame] | 167 | |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 168 | void writeErrorCount(); |
| 169 | |
Ethan Nicholas | 5547866 | 2021-08-10 17:14:26 -0400 | [diff] [blame] | 170 | void resetErrors() { |
| 171 | fErrorText.clear(); |
Ethan Nicholas | 4a5e22a | 2021-08-13 17:29:51 -0400 | [diff] [blame] | 172 | this->errorReporter().resetErrorCount(); |
Ethan Nicholas | 941e7e2 | 2016-12-12 15:33:30 -0500 | [diff] [blame] | 173 | } |
| 174 | |
Ethan Nicholas | 26a9aad | 2018-03-27 14:10:52 -0400 | [diff] [blame] | 175 | Context& context() { |
| 176 | return *fContext; |
| 177 | } |
| 178 | |
Brian Osman | 3d87e9f | 2020-10-08 11:50:22 -0400 | [diff] [blame] | 179 | // When SKSL_STANDALONE, fPath is used. (fData, fSize) will be (nullptr, 0) |
| 180 | // When !SKSL_STANDALONE, fData and fSize are used. fPath will be nullptr. |
| 181 | struct ModuleData { |
| 182 | const char* fPath; |
| 183 | |
| 184 | const uint8_t* fData; |
| 185 | size_t fSize; |
| 186 | }; |
| 187 | |
| 188 | static ModuleData MakeModulePath(const char* path) { |
| 189 | return ModuleData{path, /*fData=*/nullptr, /*fSize=*/0}; |
| 190 | } |
| 191 | static ModuleData MakeModuleData(const uint8_t* data, size_t size) { |
| 192 | return ModuleData{/*fPath=*/nullptr, data, size}; |
| 193 | } |
| 194 | |
John Stiles | a935c3f | 2021-02-25 10:35:49 -0500 | [diff] [blame] | 195 | LoadedModule loadModule(ProgramKind kind, ModuleData data, std::shared_ptr<SymbolTable> base, |
| 196 | bool dehydrate); |
John Stiles | dbd4e6f | 2021-02-16 13:29:15 -0500 | [diff] [blame] | 197 | ParsedModule parseModule(ProgramKind kind, ModuleData data, const ParsedModule& base); |
Ethan Nicholas | 8da1e65 | 2019-05-24 11:01:59 -0400 | [diff] [blame] | 198 | |
Ethan Nicholas | ba9a04f | 2020-11-06 09:28:04 -0500 | [diff] [blame] | 199 | IRGenerator& irGenerator() { |
| 200 | return *fIRGenerator; |
| 201 | } |
| 202 | |
John Stiles | dbd4e6f | 2021-02-16 13:29:15 -0500 | [diff] [blame] | 203 | const ParsedModule& moduleForProgramKind(ProgramKind kind); |
Ethan Nicholas | ba9a04f | 2020-11-06 09:28:04 -0500 | [diff] [blame] | 204 | |
Ethan Nicholas | c18bb51 | 2020-07-28 14:46:53 -0400 | [diff] [blame] | 205 | private: |
Ethan Nicholas | 4a5e22a | 2021-08-13 17:29:51 -0400 | [diff] [blame] | 206 | class CompilerErrorReporter : public ErrorReporter { |
| 207 | public: |
| 208 | CompilerErrorReporter(Compiler* compiler) |
| 209 | : fCompiler(*compiler) {} |
| 210 | |
| 211 | void handleError(const char* msg, PositionInfo pos) override { |
| 212 | fCompiler.handleError(msg, pos); |
| 213 | } |
| 214 | |
| 215 | private: |
| 216 | Compiler& fCompiler; |
| 217 | }; |
| 218 | |
Brian Osman | 5626998 | 2020-11-20 12:38:07 -0500 | [diff] [blame] | 219 | const ParsedModule& loadGPUModule(); |
| 220 | const ParsedModule& loadFragmentModule(); |
| 221 | const ParsedModule& loadVertexModule(); |
Brian Osman | b06301e | 2020-11-06 11:45:36 -0500 | [diff] [blame] | 222 | const ParsedModule& loadPublicModule(); |
Brian Osman | cbb60bd | 2021-04-12 09:49:20 -0400 | [diff] [blame] | 223 | const ParsedModule& loadRuntimeColorFilterModule(); |
| 224 | const ParsedModule& loadRuntimeShaderModule(); |
John Stiles | 2d8b835 | 2021-06-16 11:33:13 -0400 | [diff] [blame] | 225 | const ParsedModule& loadRuntimeBlenderModule(); |
Brian Osman | 88cda17 | 2020-10-09 12:05:16 -0400 | [diff] [blame] | 226 | |
John Stiles | b624b72 | 2021-08-13 12:16:13 -0400 | [diff] [blame] | 227 | std::shared_ptr<SymbolTable> makeRootSymbolTable(); |
| 228 | std::shared_ptr<SymbolTable> makePrivateSymbolTable(std::shared_ptr<SymbolTable> parent); |
| 229 | |
John Stiles | bb1505f | 2021-02-12 09:17:53 -0500 | [diff] [blame] | 230 | /** Verifies that @if and @switch statements were actually optimized away. */ |
| 231 | void verifyStaticTests(const Program& program); |
| 232 | |
John Stiles | 0bfeae6 | 2021-03-11 09:09:42 -0500 | [diff] [blame] | 233 | /** Optimize every function in the program. */ |
Ethan Nicholas | 34b19c5 | 2020-09-14 11:33:47 -0400 | [diff] [blame] | 234 | bool optimize(Program& program); |
| 235 | |
John Stiles | 0bfeae6 | 2021-03-11 09:09:42 -0500 | [diff] [blame] | 236 | /** Optimize the module. */ |
Brian Osman | 0006ad0 | 2020-11-18 15:38:39 -0500 | [diff] [blame] | 237 | bool optimize(LoadedModule& module); |
| 238 | |
John Stiles | 0bfeae6 | 2021-03-11 09:09:42 -0500 | [diff] [blame] | 239 | /** Eliminates unused functions from a Program, according to the stats in ProgramUsage. */ |
| 240 | bool removeDeadFunctions(Program& program, ProgramUsage* usage); |
| 241 | |
John Stiles | 2654187 | 2021-03-16 12:19:54 -0400 | [diff] [blame] | 242 | /** Eliminates unreferenced variables from a Program, according to the stats in ProgramUsage. */ |
John Stiles | 0bfeae6 | 2021-03-11 09:09:42 -0500 | [diff] [blame] | 243 | bool removeDeadGlobalVariables(Program& program, ProgramUsage* usage); |
John Stiles | 2654187 | 2021-03-16 12:19:54 -0400 | [diff] [blame] | 244 | bool removeDeadLocalVariables(Program& program, ProgramUsage* usage); |
John Stiles | 0bfeae6 | 2021-03-11 09:09:42 -0500 | [diff] [blame] | 245 | |
John Stiles | 25be58e | 2021-05-20 14:38:40 -0400 | [diff] [blame] | 246 | /** Eliminates unreachable statements from a Program. */ |
| 247 | void removeUnreachableCode(Program& program, ProgramUsage* usage); |
| 248 | |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 249 | Position position(int offset); |
| 250 | |
Ethan Nicholas | 4a5e22a | 2021-08-13 17:29:51 -0400 | [diff] [blame] | 251 | CompilerErrorReporter fErrorReporter; |
Brian Osman | 0006ad0 | 2020-11-18 15:38:39 -0500 | [diff] [blame] | 252 | std::shared_ptr<Context> fContext; |
Brian Osman | d7e7659 | 2020-11-02 12:26:22 -0500 | [diff] [blame] | 253 | |
Brian Osman | cbb60bd | 2021-04-12 09:49:20 -0400 | [diff] [blame] | 254 | ParsedModule fRootModule; // Core types |
Brian Osman | b06301e | 2020-11-06 11:45:36 -0500 | [diff] [blame] | 255 | |
Brian Osman | cbb60bd | 2021-04-12 09:49:20 -0400 | [diff] [blame] | 256 | ParsedModule fPrivateModule; // [Root] + Internal types |
| 257 | ParsedModule fGPUModule; // [Private] + GPU intrinsics, helper functions |
| 258 | ParsedModule fVertexModule; // [GPU] + Vertex stage decls |
| 259 | ParsedModule fFragmentModule; // [GPU] + Fragment stage decls |
Brian Osman | b06301e | 2020-11-06 11:45:36 -0500 | [diff] [blame] | 260 | |
Brian Osman | cbb60bd | 2021-04-12 09:49:20 -0400 | [diff] [blame] | 261 | ParsedModule fPublicModule; // [Root] + Public features |
Brian Osman | cbb60bd | 2021-04-12 09:49:20 -0400 | [diff] [blame] | 262 | ParsedModule fRuntimeColorFilterModule; // [Public] + Runtime shader decls |
| 263 | ParsedModule fRuntimeShaderModule; // [Public] + Runtime color filter decls |
John Stiles | 2d8b835 | 2021-06-16 11:33:13 -0400 | [diff] [blame] | 264 | ParsedModule fRuntimeBlenderModule; // [Public] + Runtime blender decls |
Ethan Nicholas | 3c6ae62 | 2018-04-24 13:06:09 -0400 | [diff] [blame] | 265 | |
Ethan Nicholas | 041fd0a | 2020-10-07 16:42:04 -0400 | [diff] [blame] | 266 | // holds ModifiersPools belonging to the core includes for lifetime purposes |
John Stiles | a47b351 | 2021-05-04 16:15:00 -0400 | [diff] [blame] | 267 | ModifiersPool fCoreModifiers; |
Ethan Nicholas | 041fd0a | 2020-10-07 16:42:04 -0400 | [diff] [blame] | 268 | |
John Stiles | 7b46300 | 2020-08-31 17:29:21 -0400 | [diff] [blame] | 269 | Inliner fInliner; |
John Stiles | 656427a | 2020-08-27 15:26:26 -0400 | [diff] [blame] | 270 | std::unique_ptr<IRGenerator> fIRGenerator; |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 271 | |
Ethan Nicholas | 0df1b04 | 2017-03-31 13:56:23 -0400 | [diff] [blame] | 272 | String fErrorText; |
Brian Osman | 88cda17 | 2020-10-09 12:05:16 -0400 | [diff] [blame] | 273 | |
John Stiles | 2ee4d7a | 2021-03-30 10:30:47 -0400 | [diff] [blame] | 274 | static OverrideFlag sOptimizer; |
| 275 | static OverrideFlag sInliner; |
| 276 | |
Brian Osman | 88cda17 | 2020-10-09 12:05:16 -0400 | [diff] [blame] | 277 | friend class AutoSource; |
Ethan Nicholas | ba9a04f | 2020-11-06 09:28:04 -0500 | [diff] [blame] | 278 | friend class ::SkSLCompileBench; |
Ethan Nicholas | 6f20b8d | 2021-08-31 07:40:24 -0400 | [diff] [blame^] | 279 | friend class DSLParser; |
Ethan Nicholas | 4f3e6a2 | 2021-06-15 09:17:05 -0400 | [diff] [blame] | 280 | friend class dsl::DSLCore; |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 281 | friend class dsl::DSLWriter; |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 282 | }; |
| 283 | |
John Stiles | a6841be | 2020-08-06 14:11:56 -0400 | [diff] [blame] | 284 | } // namespace SkSL |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 285 | |
| 286 | #endif |