Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020 Google LLC |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #ifndef SKSL_DSLWRITER |
| 9 | #define SKSL_DSLWRITER |
| 10 | |
John Stiles | d6c08c9 | 2021-08-11 11:37:51 -0400 | [diff] [blame] | 11 | #include "include/core/SkSpan.h" |
Ethan Nicholas | dd2fdea | 2021-07-20 15:23:04 -0400 | [diff] [blame] | 12 | #include "include/core/SkStringView.h" |
Ethan Nicholas | daed259 | 2021-03-04 14:30:25 -0500 | [diff] [blame] | 13 | #include "include/private/SkSLModifiers.h" |
Ethan Nicholas | 24c1772 | 2021-03-09 13:10:59 -0500 | [diff] [blame] | 14 | #include "include/private/SkSLStatement.h" |
Ethan Nicholas | daed259 | 2021-03-04 14:30:25 -0500 | [diff] [blame] | 15 | #include "include/sksl/DSLExpression.h" |
| 16 | #include "include/sksl/DSLStatement.h" |
Ethan Nicholas | bffe80a | 2021-01-11 15:42:44 -0500 | [diff] [blame] | 17 | #include "src/sksl/SkSLMangler.h" |
John Stiles | 4599050 | 2021-02-16 10:55:27 -0500 | [diff] [blame] | 18 | #include "src/sksl/SkSLOperators.h" |
Ethan Nicholas | 55a63af | 2021-05-18 10:12:58 -0400 | [diff] [blame] | 19 | #include "src/sksl/SkSLParsedModule.h" |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 20 | #include "src/sksl/ir/SkSLExpressionStatement.h" |
| 21 | #include "src/sksl/ir/SkSLProgram.h" |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 22 | #if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU |
Brian Salomon | 4895946 | 2021-08-11 13:01:06 -0400 | [diff] [blame^] | 23 | #include "src/gpu/GrFragmentProcessor.h" |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 24 | #endif // !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU |
John Stiles | 3befaf2 | 2021-04-23 14:42:22 -0400 | [diff] [blame] | 25 | #include <list> |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 26 | #include <stack> |
| 27 | |
| 28 | class AutoDSLContext; |
| 29 | |
| 30 | namespace SkSL { |
| 31 | |
| 32 | class Compiler; |
| 33 | class Context; |
| 34 | class IRGenerator; |
Ethan Nicholas | daed259 | 2021-03-04 14:30:25 -0500 | [diff] [blame] | 35 | class ProgramElement; |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 36 | class SymbolTable; |
| 37 | class Type; |
Ethan Nicholas | daed259 | 2021-03-04 14:30:25 -0500 | [diff] [blame] | 38 | class Variable; |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 39 | |
| 40 | namespace dsl { |
| 41 | |
Ethan Nicholas | a2d22b2 | 2021-07-15 10:35:54 -0400 | [diff] [blame] | 42 | class DSLGlobalVar; |
| 43 | class DSLParameter; |
| 44 | class DSLVar; |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 45 | class ErrorHandler; |
| 46 | |
| 47 | /** |
| 48 | * Thread-safe class that tracks per-thread state associated with DSL output. This class is for |
| 49 | * internal use only. |
| 50 | */ |
| 51 | class DSLWriter { |
| 52 | public: |
Ethan Nicholas | 55a63af | 2021-05-18 10:12:58 -0400 | [diff] [blame] | 53 | DSLWriter(SkSL::Compiler* compiler, SkSL::ProgramKind kind, |
| 54 | const SkSL::ProgramSettings& settings, SkSL::ParsedModule module, bool isModule); |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 55 | |
Ethan Nicholas | 0584ac0 | 2021-02-17 10:48:14 -0500 | [diff] [blame] | 56 | ~DSLWriter(); |
| 57 | |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 58 | /** |
| 59 | * Returns the Compiler used by DSL operations in the current thread. |
| 60 | */ |
| 61 | static SkSL::Compiler& Compiler() { |
| 62 | return *Instance().fCompiler; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Returns the IRGenerator used by DSL operations in the current thread. |
| 67 | */ |
| 68 | static SkSL::IRGenerator& IRGenerator(); |
| 69 | |
| 70 | /** |
| 71 | * Returns the Context used by DSL operations in the current thread. |
| 72 | */ |
| 73 | static const SkSL::Context& Context(); |
| 74 | |
| 75 | /** |
Ethan Nicholas | 459777a | 2021-07-16 11:16:27 -0400 | [diff] [blame] | 76 | * Returns the Settings used by DSL operations in the current thread. |
| 77 | */ |
| 78 | static SkSL::ProgramSettings& Settings(); |
| 79 | |
| 80 | /** |
Ethan Nicholas | 1ff7609 | 2021-01-28 10:02:43 -0500 | [diff] [blame] | 81 | * Returns the collection to which DSL program elements in this thread should be appended. |
| 82 | */ |
| 83 | static std::vector<std::unique_ptr<SkSL::ProgramElement>>& ProgramElements() { |
| 84 | return Instance().fProgramElements; |
| 85 | } |
| 86 | |
Ethan Nicholas | 55a63af | 2021-05-18 10:12:58 -0400 | [diff] [blame] | 87 | static std::vector<const ProgramElement*>& SharedElements() { |
| 88 | return Instance().fSharedElements; |
| 89 | } |
| 90 | |
Ethan Nicholas | 1ff7609 | 2021-01-28 10:02:43 -0500 | [diff] [blame] | 91 | /** |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 92 | * Returns the SymbolTable of the current thread's IRGenerator. |
| 93 | */ |
| 94 | static const std::shared_ptr<SkSL::SymbolTable>& SymbolTable(); |
| 95 | |
Ethan Nicholas | 55a63af | 2021-05-18 10:12:58 -0400 | [diff] [blame] | 96 | /** |
| 97 | * Returns the current memory pool. |
| 98 | */ |
| 99 | static std::unique_ptr<Pool>& MemoryPool() { return Instance().fPool; } |
| 100 | |
| 101 | /** |
| 102 | * Returns the current modifiers pool. |
| 103 | */ |
| 104 | static std::unique_ptr<ModifiersPool>& GetModifiersPool() { return Instance().fModifiersPool; } |
| 105 | |
| 106 | /** |
| 107 | * Returns the current ProgramConfig. |
| 108 | */ |
| 109 | static std::unique_ptr<ProgramConfig>& GetProgramConfig() { return Instance().fConfig; } |
| 110 | |
Ethan Nicholas | 292a09d | 2021-07-14 09:52:16 -0400 | [diff] [blame] | 111 | static bool IsModule() { return Instance().fIsModule; } |
| 112 | |
Ethan Nicholas | fe5d692 | 2021-03-05 14:23:48 -0500 | [diff] [blame] | 113 | static void Reset(); |
| 114 | |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 115 | /** |
Ethan Nicholas | bffe80a | 2021-01-11 15:42:44 -0500 | [diff] [blame] | 116 | * Returns the final pointer to a pooled Modifiers object that should be used to represent the |
| 117 | * given modifiers. |
| 118 | */ |
John Stiles | f2872e6 | 2021-05-04 11:38:43 -0400 | [diff] [blame] | 119 | static const SkSL::Modifiers* Modifiers(const SkSL::Modifiers& modifiers); |
Ethan Nicholas | bffe80a | 2021-01-11 15:42:44 -0500 | [diff] [blame] | 120 | |
| 121 | /** |
Ethan Nicholas | a2d22b2 | 2021-07-15 10:35:54 -0400 | [diff] [blame] | 122 | * Returns the SkSL variable corresponding to a DSL var. |
Ethan Nicholas | d6b26e5 | 2021-01-27 07:53:46 -0500 | [diff] [blame] | 123 | */ |
Ethan Nicholas | a2d22b2 | 2021-07-15 10:35:54 -0400 | [diff] [blame] | 124 | static const SkSL::Variable* Var(DSLVarBase& var); |
Ethan Nicholas | 707d315 | 2021-03-25 17:49:08 -0400 | [diff] [blame] | 125 | |
| 126 | /** |
Ethan Nicholas | a2d22b2 | 2021-07-15 10:35:54 -0400 | [diff] [blame] | 127 | * Creates an SkSL variable corresponding to a DSLParameter. |
Ethan Nicholas | 371f6e1 | 2021-05-04 14:30:02 -0400 | [diff] [blame] | 128 | */ |
Ethan Nicholas | a2d22b2 | 2021-07-15 10:35:54 -0400 | [diff] [blame] | 129 | static std::unique_ptr<SkSL::Variable> CreateParameterVar(DSLParameter& var); |
| 130 | |
Ethan Nicholas | 371f6e1 | 2021-05-04 14:30:02 -0400 | [diff] [blame] | 131 | |
| 132 | /** |
Ethan Nicholas | 707d315 | 2021-03-25 17:49:08 -0400 | [diff] [blame] | 133 | * Returns the SkSL declaration corresponding to a DSLVar. |
| 134 | */ |
Ethan Nicholas | a2d22b2 | 2021-07-15 10:35:54 -0400 | [diff] [blame] | 135 | static std::unique_ptr<SkSL::Statement> Declaration(DSLVarBase& var); |
Ethan Nicholas | d6b26e5 | 2021-01-27 07:53:46 -0500 | [diff] [blame] | 136 | |
| 137 | /** |
Ethan Nicholas | 961d944 | 2021-03-16 16:37:29 -0400 | [diff] [blame] | 138 | * For use in testing only: marks the variable as having been declared, so that it can be |
| 139 | * destroyed without generating errors. |
| 140 | */ |
Ethan Nicholas | a2d22b2 | 2021-07-15 10:35:54 -0400 | [diff] [blame] | 141 | static void MarkDeclared(DSLVarBase& var); |
Ethan Nicholas | 961d944 | 2021-03-16 16:37:29 -0400 | [diff] [blame] | 142 | |
| 143 | /** |
Ethan Nicholas | bffe80a | 2021-01-11 15:42:44 -0500 | [diff] [blame] | 144 | * Returns the (possibly mangled) final name that should be used for an entity with the given |
| 145 | * raw name. |
| 146 | */ |
Ethan Nicholas | d0f4d0d | 2021-06-23 13:51:55 -0400 | [diff] [blame] | 147 | static skstd::string_view Name(skstd::string_view name); |
Ethan Nicholas | bffe80a | 2021-01-11 15:42:44 -0500 | [diff] [blame] | 148 | |
Ethan Nicholas | c3bb9e3 | 2021-02-02 11:51:03 -0500 | [diff] [blame] | 149 | #if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU |
| 150 | /** |
| 151 | * Returns the fragment processor for which DSL output is being generated for the current |
| 152 | * thread. |
| 153 | */ |
Brian Salomon | 3176e86 | 2021-08-09 11:23:04 -0400 | [diff] [blame] | 154 | static GrFragmentProcessor::ProgramImpl* CurrentProcessor() { |
Ethan Nicholas | c3bb9e3 | 2021-02-02 11:51:03 -0500 | [diff] [blame] | 155 | SkASSERTF(!Instance().fStack.empty(), "This feature requires a FragmentProcessor"); |
| 156 | return Instance().fStack.top().fProcessor; |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Returns the EmitArgs for fragment processor output in the current thread. |
| 161 | */ |
Brian Salomon | 3176e86 | 2021-08-09 11:23:04 -0400 | [diff] [blame] | 162 | static GrFragmentProcessor::ProgramImpl::EmitArgs* CurrentEmitArgs() { |
Ethan Nicholas | c3bb9e3 | 2021-02-02 11:51:03 -0500 | [diff] [blame] | 163 | SkASSERTF(!Instance().fStack.empty(), "This feature requires a FragmentProcessor"); |
| 164 | return Instance().fStack.top().fEmitArgs; |
| 165 | } |
| 166 | |
Ethan Nicholas | 11a15b1 | 2021-02-11 15:56:27 -0500 | [diff] [blame] | 167 | static bool InFragmentProcessor() { |
| 168 | return !Instance().fStack.empty(); |
| 169 | } |
| 170 | |
Ethan Nicholas | c3bb9e3 | 2021-02-02 11:51:03 -0500 | [diff] [blame] | 171 | /** |
| 172 | * Pushes a new processor / emitArgs pair for the current thread. |
| 173 | */ |
Brian Salomon | 3176e86 | 2021-08-09 11:23:04 -0400 | [diff] [blame] | 174 | static void StartFragmentProcessor(GrFragmentProcessor::ProgramImpl* processor, |
| 175 | GrFragmentProcessor::ProgramImpl::EmitArgs* emitArgs); |
Ethan Nicholas | c3bb9e3 | 2021-02-02 11:51:03 -0500 | [diff] [blame] | 176 | |
| 177 | /** |
| 178 | * Pops the processor / emitArgs pair associated with the current thread. |
| 179 | */ |
| 180 | static void EndFragmentProcessor(); |
Ethan Nicholas | 11a15b1 | 2021-02-11 15:56:27 -0500 | [diff] [blame] | 181 | |
Ethan Nicholas | a2d22b2 | 2021-07-15 10:35:54 -0400 | [diff] [blame] | 182 | static GrGLSLUniformHandler::UniformHandle VarUniformHandle(const DSLGlobalVar& var); |
Ethan Nicholas | ee49efc | 2021-04-09 15:33:53 -0400 | [diff] [blame] | 183 | #else |
| 184 | static bool InFragmentProcessor() { |
| 185 | return false; |
| 186 | } |
Ethan Nicholas | c3bb9e3 | 2021-02-02 11:51:03 -0500 | [diff] [blame] | 187 | #endif // !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU |
| 188 | |
Ethan Nicholas | daed259 | 2021-03-04 14:30:25 -0500 | [diff] [blame] | 189 | static std::unique_ptr<SkSL::Expression> Call(const FunctionDeclaration& function, |
| 190 | ExpressionArray arguments); |
| 191 | |
Ethan Nicholas | 1ff7609 | 2021-01-28 10:02:43 -0500 | [diff] [blame] | 192 | /** |
Ethan Nicholas | 722cb67 | 2021-05-06 10:47:06 -0400 | [diff] [blame] | 193 | * Invokes expr(arguments), where expr is a function or type reference. |
| 194 | */ |
| 195 | static std::unique_ptr<SkSL::Expression> Call(std::unique_ptr<SkSL::Expression> expr, |
| 196 | ExpressionArray arguments); |
| 197 | |
Ethan Nicholas | b4f8b7a | 2021-06-23 10:27:09 -0400 | [diff] [blame] | 198 | static DSLPossibleExpression Coerce(std::unique_ptr<Expression> expr, const SkSL::Type& type); |
Ethan Nicholas | 92969f2 | 2021-01-13 10:38:59 -0500 | [diff] [blame] | 199 | |
John Stiles | d6c08c9 | 2021-08-11 11:37:51 -0400 | [diff] [blame] | 200 | static DSLPossibleExpression Construct(const SkSL::Type& type, SkSpan<DSLExpression> rawArgs); |
Ethan Nicholas | b3d4e74 | 2021-01-08 11:42:25 -0500 | [diff] [blame] | 201 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 202 | static std::unique_ptr<Expression> ConvertBinary(std::unique_ptr<Expression> left, Operator op, |
| 203 | std::unique_ptr<Expression> right); |
Ethan Nicholas | bf79dff | 2021-02-11 15:18:31 -0500 | [diff] [blame] | 204 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 205 | static std::unique_ptr<SkSL::Expression> ConvertField(std::unique_ptr<Expression> base, |
Ethan Nicholas | d0f4d0d | 2021-06-23 13:51:55 -0400 | [diff] [blame] | 206 | skstd::string_view name); |
Ethan Nicholas | 92969f2 | 2021-01-13 10:38:59 -0500 | [diff] [blame] | 207 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 208 | static std::unique_ptr<Expression> ConvertIndex(std::unique_ptr<Expression> base, |
| 209 | std::unique_ptr<Expression> index); |
Ethan Nicholas | 92969f2 | 2021-01-13 10:38:59 -0500 | [diff] [blame] | 210 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 211 | static std::unique_ptr<Expression> ConvertPostfix(std::unique_ptr<Expression> expr, |
| 212 | Operator op); |
Ethan Nicholas | 92969f2 | 2021-01-13 10:38:59 -0500 | [diff] [blame] | 213 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 214 | static std::unique_ptr<Expression> ConvertPrefix(Operator op, std::unique_ptr<Expression> expr); |
Ethan Nicholas | 92969f2 | 2021-01-13 10:38:59 -0500 | [diff] [blame] | 215 | |
Ethan Nicholas | 34c7e11 | 2021-02-25 20:50:32 -0500 | [diff] [blame] | 216 | static DSLPossibleStatement ConvertSwitch(std::unique_ptr<Expression> value, |
| 217 | ExpressionArray caseValues, |
Ethan Nicholas | 8a6537d | 2021-04-30 12:44:00 -0400 | [diff] [blame] | 218 | SkTArray<SkSL::StatementArray> caseStatements, |
| 219 | bool isStatic); |
Ethan Nicholas | cfefec0 | 2021-02-09 15:22:57 -0500 | [diff] [blame] | 220 | |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 221 | /** |
Ethan Nicholas | 65e368b | 2021-08-05 14:53:02 -0400 | [diff] [blame] | 222 | * Returns the ErrorHandler associated with the current thread. This object will be notified |
| 223 | * when any DSL errors occur. With a null ErrorHandler (the default), any errors will be dumped |
| 224 | * to stderr and a fatal exception will be generated. |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 225 | */ |
Ethan Nicholas | 65e368b | 2021-08-05 14:53:02 -0400 | [diff] [blame] | 226 | static ErrorHandler* GetErrorHandler() { |
| 227 | return Instance().fErrorHandler; |
| 228 | } |
| 229 | |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 230 | static void SetErrorHandler(ErrorHandler* errorHandler) { |
| 231 | Instance().fErrorHandler = errorHandler; |
| 232 | } |
| 233 | |
| 234 | /** |
| 235 | * Notifies the current ErrorHandler that a DSL error has occurred. With a null ErrorHandler |
| 236 | * (the default), any errors will be dumped to stderr and a fatal exception will be generated. |
| 237 | */ |
Ethan Nicholas | a40ddcd | 2021-08-06 09:17:18 -0400 | [diff] [blame] | 238 | static void ReportError(const char* msg, PositionInfo info = PositionInfo()); |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 239 | |
Ethan Nicholas | bffe80a | 2021-01-11 15:42:44 -0500 | [diff] [blame] | 240 | /** |
Ethan Nicholas | 55a63af | 2021-05-18 10:12:58 -0400 | [diff] [blame] | 241 | * Returns whether name mangling is enabled. Mangling is important for the DSL because its |
| 242 | * variables normally all go into the same symbol table; for instance if you were to translate |
| 243 | * this legal (albeit silly) GLSL code: |
| 244 | * int x; |
| 245 | * { |
| 246 | * int x; |
| 247 | * } |
| 248 | * |
| 249 | * into DSL, you'd end up with: |
| 250 | * DSLVar x1(kInt_Type, "x"); |
| 251 | * DSLVar x2(kInt_Type, "x"); |
| 252 | * Declare(x1); |
| 253 | * Block(Declare(x2)); |
| 254 | * |
| 255 | * with x1 and x2 ending up in the same symbol table. This is fine as long as their effective |
| 256 | * names are different, so mangling prevents this situation from causing problems. |
Ethan Nicholas | bffe80a | 2021-01-11 15:42:44 -0500 | [diff] [blame] | 257 | */ |
| 258 | static bool ManglingEnabled() { |
Ethan Nicholas | 55a63af | 2021-05-18 10:12:58 -0400 | [diff] [blame] | 259 | return Instance().fSettings.fDSLMangling; |
| 260 | } |
| 261 | |
| 262 | /** |
| 263 | * Returns whether DSLVars should automatically be marked declared upon creation. This is used |
| 264 | * to simplify testing. |
| 265 | */ |
| 266 | static bool MarkVarsDeclared() { |
| 267 | return Instance().fSettings.fDSLMarkVarsDeclared; |
Ethan Nicholas | bffe80a | 2021-01-11 15:42:44 -0500 | [diff] [blame] | 268 | } |
| 269 | |
Ethan Nicholas | b4f8b7a | 2021-06-23 10:27:09 -0400 | [diff] [blame] | 270 | /** |
| 271 | * Forwards any pending Compiler errors to the DSL ErrorHandler. |
| 272 | */ |
| 273 | static void ReportErrors(PositionInfo pos = PositionInfo()); |
| 274 | |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 275 | static DSLWriter& Instance(); |
| 276 | |
| 277 | static void SetInstance(std::unique_ptr<DSLWriter> instance); |
| 278 | |
| 279 | private: |
Ethan Nicholas | 624a529 | 2021-04-16 14:54:43 -0400 | [diff] [blame] | 280 | std::unique_ptr<SkSL::ProgramConfig> fConfig; |
John Stiles | 10d39d9 | 2021-05-04 16:13:14 -0400 | [diff] [blame] | 281 | std::unique_ptr<SkSL::ModifiersPool> fModifiersPool; |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 282 | SkSL::Compiler* fCompiler; |
Ethan Nicholas | 961d944 | 2021-03-16 16:37:29 -0400 | [diff] [blame] | 283 | std::unique_ptr<Pool> fPool; |
John Stiles | d120464 | 2021-02-17 16:30:02 -0500 | [diff] [blame] | 284 | SkSL::ProgramConfig* fOldConfig; |
John Stiles | 10d39d9 | 2021-05-04 16:13:14 -0400 | [diff] [blame] | 285 | SkSL::ModifiersPool* fOldModifiersPool; |
Ethan Nicholas | 1ff7609 | 2021-01-28 10:02:43 -0500 | [diff] [blame] | 286 | std::vector<std::unique_ptr<SkSL::ProgramElement>> fProgramElements; |
Ethan Nicholas | 624a529 | 2021-04-16 14:54:43 -0400 | [diff] [blame] | 287 | std::vector<const SkSL::ProgramElement*> fSharedElements; |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 288 | ErrorHandler* fErrorHandler = nullptr; |
Ethan Nicholas | 55a63af | 2021-05-18 10:12:58 -0400 | [diff] [blame] | 289 | ProgramSettings fSettings; |
Ethan Nicholas | bffe80a | 2021-01-11 15:42:44 -0500 | [diff] [blame] | 290 | Mangler fMangler; |
Ethan Nicholas | 292a09d | 2021-07-14 09:52:16 -0400 | [diff] [blame] | 291 | bool fIsModule; |
Ethan Nicholas | 4f3e6a2 | 2021-06-15 09:17:05 -0400 | [diff] [blame] | 292 | bool fEncounteredErrors = false; |
Ethan Nicholas | c3bb9e3 | 2021-02-02 11:51:03 -0500 | [diff] [blame] | 293 | #if !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU |
| 294 | struct StackFrame { |
Brian Salomon | 3176e86 | 2021-08-09 11:23:04 -0400 | [diff] [blame] | 295 | GrFragmentProcessor::ProgramImpl* fProcessor; |
| 296 | GrFragmentProcessor::ProgramImpl::EmitArgs* fEmitArgs; |
John Stiles | 3befaf2 | 2021-04-23 14:42:22 -0400 | [diff] [blame] | 297 | SkSL::StatementArray fSavedDeclarations; |
Ethan Nicholas | c3bb9e3 | 2021-02-02 11:51:03 -0500 | [diff] [blame] | 298 | }; |
John Stiles | 3befaf2 | 2021-04-23 14:42:22 -0400 | [diff] [blame] | 299 | std::stack<StackFrame, std::list<StackFrame>> fStack; |
Ethan Nicholas | c3bb9e3 | 2021-02-02 11:51:03 -0500 | [diff] [blame] | 300 | #endif // !defined(SKSL_STANDALONE) && SK_SUPPORT_GPU |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 301 | |
| 302 | friend class DSLCore; |
Ethan Nicholas | 961d944 | 2021-03-16 16:37:29 -0400 | [diff] [blame] | 303 | friend class DSLVar; |
Ethan Nicholas | 9504614 | 2021-01-07 10:57:27 -0500 | [diff] [blame] | 304 | }; |
| 305 | |
| 306 | } // namespace dsl |
| 307 | |
| 308 | } // namespace SkSL |
| 309 | |
| 310 | #endif |