Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [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 | */ |
| 7 | |
| 8 | #ifndef SKSL_METALCODEGENERATOR |
| 9 | #define SKSL_METALCODEGENERATOR |
| 10 | |
| 11 | #include <stack> |
| 12 | #include <tuple> |
| 13 | #include <unordered_map> |
John Stiles | 1bdafbf | 2020-05-28 12:17:20 -0400 | [diff] [blame] | 14 | #include <unordered_set> |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 15 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 16 | #include "src/sksl/SkSLCodeGenerator.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 17 | #include "src/sksl/SkSLStringStream.h" |
| 18 | #include "src/sksl/ir/SkSLBinaryExpression.h" |
| 19 | #include "src/sksl/ir/SkSLBoolLiteral.h" |
| 20 | #include "src/sksl/ir/SkSLConstructor.h" |
| 21 | #include "src/sksl/ir/SkSLDoStatement.h" |
| 22 | #include "src/sksl/ir/SkSLExtension.h" |
| 23 | #include "src/sksl/ir/SkSLFieldAccess.h" |
| 24 | #include "src/sksl/ir/SkSLFloatLiteral.h" |
| 25 | #include "src/sksl/ir/SkSLForStatement.h" |
| 26 | #include "src/sksl/ir/SkSLFunctionCall.h" |
| 27 | #include "src/sksl/ir/SkSLFunctionDeclaration.h" |
| 28 | #include "src/sksl/ir/SkSLFunctionDefinition.h" |
John Stiles | 569249b | 2020-11-03 12:18:22 -0500 | [diff] [blame] | 29 | #include "src/sksl/ir/SkSLFunctionPrototype.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 30 | #include "src/sksl/ir/SkSLIfStatement.h" |
| 31 | #include "src/sksl/ir/SkSLIndexExpression.h" |
John Stiles | 98c1f82 | 2020-09-09 14:18:53 -0400 | [diff] [blame] | 32 | #include "src/sksl/ir/SkSLInlineMarker.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 33 | #include "src/sksl/ir/SkSLIntLiteral.h" |
| 34 | #include "src/sksl/ir/SkSLInterfaceBlock.h" |
| 35 | #include "src/sksl/ir/SkSLPostfixExpression.h" |
| 36 | #include "src/sksl/ir/SkSLPrefixExpression.h" |
| 37 | #include "src/sksl/ir/SkSLProgramElement.h" |
| 38 | #include "src/sksl/ir/SkSLReturnStatement.h" |
| 39 | #include "src/sksl/ir/SkSLSetting.h" |
| 40 | #include "src/sksl/ir/SkSLStatement.h" |
| 41 | #include "src/sksl/ir/SkSLSwitchStatement.h" |
| 42 | #include "src/sksl/ir/SkSLSwizzle.h" |
| 43 | #include "src/sksl/ir/SkSLTernaryExpression.h" |
| 44 | #include "src/sksl/ir/SkSLVarDeclarations.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 45 | #include "src/sksl/ir/SkSLVariableReference.h" |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 46 | |
| 47 | namespace SkSL { |
| 48 | |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 49 | /** |
| 50 | * Converts a Program into Metal code. |
| 51 | */ |
| 52 | class MetalCodeGenerator : public CodeGenerator { |
| 53 | public: |
Timothy Liang | a06f215 | 2018-05-24 15:33:31 -0400 | [diff] [blame] | 54 | static constexpr const char* SAMPLER_SUFFIX = "Smplr"; |
Timothy Liang | 7d63778 | 2018-06-05 09:58:07 -0400 | [diff] [blame] | 55 | static constexpr const char* PACKED_PREFIX = "packed_"; |
Timothy Liang | a06f215 | 2018-05-24 15:33:31 -0400 | [diff] [blame] | 56 | |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 57 | enum Precedence { |
| 58 | kParentheses_Precedence = 1, |
| 59 | kPostfix_Precedence = 2, |
| 60 | kPrefix_Precedence = 3, |
| 61 | kMultiplicative_Precedence = 4, |
| 62 | kAdditive_Precedence = 5, |
| 63 | kShift_Precedence = 6, |
| 64 | kRelational_Precedence = 7, |
| 65 | kEquality_Precedence = 8, |
| 66 | kBitwiseAnd_Precedence = 9, |
| 67 | kBitwiseXor_Precedence = 10, |
| 68 | kBitwiseOr_Precedence = 11, |
| 69 | kLogicalAnd_Precedence = 12, |
| 70 | kLogicalXor_Precedence = 13, |
| 71 | kLogicalOr_Precedence = 14, |
| 72 | kTernary_Precedence = 15, |
| 73 | kAssignment_Precedence = 16, |
| 74 | kSequence_Precedence = 17, |
| 75 | kTopLevel_Precedence = kSequence_Precedence |
| 76 | }; |
| 77 | |
| 78 | MetalCodeGenerator(const Context* context, const Program* program, ErrorReporter* errors, |
Ethan Nicholas | 5a9a9b8 | 2019-09-20 12:59:22 -0400 | [diff] [blame] | 79 | OutputStream* out) |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 80 | : INHERITED(program, errors, out) |
John Stiles | 2345653 | 2020-12-30 18:12:48 -0500 | [diff] [blame] | 81 | , fReservedWords({"atan2", "rsqrt", "rint", "dfdx", "dfdy", "vertex", "fragment"}) |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 82 | , fLineEnding("\n") |
Timothy Liang | 6403b0e | 2018-05-17 10:40:04 -0400 | [diff] [blame] | 83 | , fContext(*context) { |
| 84 | this->setupIntrinsics(); |
| 85 | } |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 86 | |
| 87 | bool generateCode() override; |
| 88 | |
| 89 | protected: |
| 90 | typedef int Requirements; |
Ethan Nicholas | c6dce5a | 2019-07-24 16:51:36 -0400 | [diff] [blame] | 91 | static constexpr Requirements kNo_Requirements = 0; |
| 92 | static constexpr Requirements kInputs_Requirement = 1 << 0; |
| 93 | static constexpr Requirements kOutputs_Requirement = 1 << 1; |
| 94 | static constexpr Requirements kUniforms_Requirement = 1 << 2; |
| 95 | static constexpr Requirements kGlobals_Requirement = 1 << 3; |
| 96 | static constexpr Requirements kFragCoord_Requirement = 1 << 4; |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 97 | |
Timothy Liang | 6403b0e | 2018-05-17 10:40:04 -0400 | [diff] [blame] | 98 | enum IntrinsicKind { |
John Stiles | d7199b2 | 2020-12-30 16:22:58 -0500 | [diff] [blame] | 99 | kAtan_IntrinsicKind, |
| 100 | kBitcast_IntrinsicKind, |
| 101 | kBitCount_IntrinsicKind, |
| 102 | kCompareEqual_IntrinsicKind, |
| 103 | kCompareGreaterThan_IntrinsicKind, |
| 104 | kCompareGreaterThanEqual_IntrinsicKind, |
| 105 | kCompareLessThan_IntrinsicKind, |
| 106 | kCompareLessThanEqual_IntrinsicKind, |
| 107 | kCompareNotEqual_IntrinsicKind, |
| 108 | kDegrees_IntrinsicKind, |
| 109 | kDFdx_IntrinsicKind, |
| 110 | kDFdy_IntrinsicKind, |
| 111 | kDistance_IntrinsicKind, |
| 112 | kDot_IntrinsicKind, |
| 113 | kFaceforward_IntrinsicKind, |
| 114 | kFindLSB_IntrinsicKind, |
| 115 | kFindMSB_IntrinsicKind, |
| 116 | kInverse_IntrinsicKind, |
| 117 | kInversesqrt_IntrinsicKind, |
| 118 | kLength_IntrinsicKind, |
| 119 | kMatrixCompMult_IntrinsicKind, |
| 120 | kMod_IntrinsicKind, |
| 121 | kNormalize_IntrinsicKind, |
| 122 | kRadians_IntrinsicKind, |
| 123 | kReflect_IntrinsicKind, |
| 124 | kRefract_IntrinsicKind, |
John Stiles | 2345653 | 2020-12-30 18:12:48 -0500 | [diff] [blame] | 125 | kRoundEven_IntrinsicKind, |
John Stiles | d7199b2 | 2020-12-30 16:22:58 -0500 | [diff] [blame] | 126 | kTexture_IntrinsicKind, |
Timothy Liang | a06f215 | 2018-05-24 15:33:31 -0400 | [diff] [blame] | 127 | }; |
Timothy Liang | 6403b0e | 2018-05-17 10:40:04 -0400 | [diff] [blame] | 128 | |
John Stiles | d6449e9 | 2020-11-30 09:13:23 -0500 | [diff] [blame] | 129 | static const char* OperatorName(Token::Kind op); |
| 130 | |
John Stiles | cdcdb04 | 2020-07-06 09:03:51 -0400 | [diff] [blame] | 131 | class GlobalStructVisitor; |
| 132 | void visitGlobalStruct(GlobalStructVisitor* visitor); |
| 133 | |
Timothy Liang | a06f215 | 2018-05-24 15:33:31 -0400 | [diff] [blame] | 134 | void setupIntrinsics(); |
Timothy Liang | ee84fe1 | 2018-05-18 14:38:19 -0400 | [diff] [blame] | 135 | |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 136 | void write(const char* s); |
| 137 | |
| 138 | void writeLine(); |
| 139 | |
| 140 | void writeLine(const char* s); |
| 141 | |
| 142 | void write(const String& s); |
| 143 | |
| 144 | void writeLine(const String& s); |
| 145 | |
| 146 | void writeHeader(); |
| 147 | |
| 148 | void writeUniformStruct(); |
| 149 | |
| 150 | void writeInputStruct(); |
| 151 | |
| 152 | void writeOutputStruct(); |
| 153 | |
Timothy Liang | 7d63778 | 2018-06-05 09:58:07 -0400 | [diff] [blame] | 154 | void writeInterfaceBlocks(); |
| 155 | |
John Stiles | dc75a97 | 2020-11-25 16:24:55 -0500 | [diff] [blame] | 156 | void writeStructDefinitions(); |
| 157 | |
Timothy Liang | dc89f19 | 2018-06-13 09:20:31 -0400 | [diff] [blame] | 158 | void writeFields(const std::vector<Type::Field>& fields, int parentOffset, |
| 159 | const InterfaceBlock* parentIntf = nullptr); |
| 160 | |
Timothy Liang | 7d63778 | 2018-06-05 09:58:07 -0400 | [diff] [blame] | 161 | int size(const Type* type, bool isPacked) const; |
| 162 | |
| 163 | int alignment(const Type* type, bool isPacked) const; |
| 164 | |
Timothy Liang | ee84fe1 | 2018-05-18 14:38:19 -0400 | [diff] [blame] | 165 | void writeGlobalStruct(); |
John Stiles | d7199b2 | 2020-12-30 16:22:58 -0500 | [diff] [blame] | 166 | |
John Stiles | cdcdb04 | 2020-07-06 09:03:51 -0400 | [diff] [blame] | 167 | void writeGlobalInit(); |
Timothy Liang | ee84fe1 | 2018-05-18 14:38:19 -0400 | [diff] [blame] | 168 | |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 169 | void writePrecisionModifier(); |
| 170 | |
Ethan Nicholas | 45fa810 | 2020-01-13 10:58:49 -0500 | [diff] [blame] | 171 | String typeName(const Type& type); |
| 172 | |
Brian Osman | 02bc522 | 2021-01-28 11:00:20 -0500 | [diff] [blame^] | 173 | void writeStructDefinition(const StructDefinition& s); |
John Stiles | dc75a97 | 2020-11-25 16:24:55 -0500 | [diff] [blame] | 174 | |
John Stiles | ea16670 | 2020-12-11 17:30:47 -0500 | [diff] [blame] | 175 | void disallowArrayTypes(const Type& type, int offset); |
John Stiles | 3dba3ee | 2020-12-02 23:35:49 -0500 | [diff] [blame] | 176 | |
| 177 | void writeBaseType(const Type& type); |
| 178 | |
| 179 | void writeArrayDimensions(const Type& type); |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 180 | |
| 181 | void writeExtension(const Extension& ext); |
| 182 | |
| 183 | void writeInterfaceBlock(const InterfaceBlock& intf); |
| 184 | |
| 185 | void writeFunctionStart(const FunctionDeclaration& f); |
| 186 | |
John Stiles | 06b84ef | 2020-12-09 12:35:48 -0500 | [diff] [blame] | 187 | void writeFunctionRequirementParams(const FunctionDeclaration& f, |
| 188 | const char*& separator); |
| 189 | |
| 190 | void writeFunctionRequirementArgs(const FunctionDeclaration& f, const char*& separator); |
| 191 | |
John Stiles | 569249b | 2020-11-03 12:18:22 -0500 | [diff] [blame] | 192 | bool writeFunctionDeclaration(const FunctionDeclaration& f); |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 193 | |
| 194 | void writeFunction(const FunctionDefinition& f); |
| 195 | |
John Stiles | 569249b | 2020-11-03 12:18:22 -0500 | [diff] [blame] | 196 | void writeFunctionPrototype(const FunctionPrototype& f); |
| 197 | |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 198 | void writeLayout(const Layout& layout); |
| 199 | |
| 200 | void writeModifiers(const Modifiers& modifiers, bool globalContext); |
| 201 | |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 202 | void writeVarInitializer(const Variable& var, const Expression& value); |
| 203 | |
Timothy Liang | 651286f | 2018-06-07 09:55:33 -0400 | [diff] [blame] | 204 | void writeName(const String& name); |
| 205 | |
Brian Osman | c021360 | 2020-10-06 14:43:32 -0400 | [diff] [blame] | 206 | void writeVarDeclaration(const VarDeclaration& decl, bool global); |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 207 | |
| 208 | void writeFragCoord(); |
| 209 | |
| 210 | void writeVariableReference(const VariableReference& ref); |
| 211 | |
| 212 | void writeExpression(const Expression& expr, Precedence parentPrecedence); |
| 213 | |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 214 | void writeMinAbsHack(Expression& absExpr, Expression& otherExpr); |
| 215 | |
John Stiles | 06b84ef | 2020-12-09 12:35:48 -0500 | [diff] [blame] | 216 | String getOutParamHelper(const FunctionCall& c, |
| 217 | const ExpressionArray& arguments, |
| 218 | const SkTArray<VariableReference*>& outVars); |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 219 | |
John Stiles | d7199b2 | 2020-12-30 16:22:58 -0500 | [diff] [blame] | 220 | String getInversePolyfill(const ExpressionArray& arguments); |
John Stiles | b21fac2 | 2020-12-04 15:36:49 -0500 | [diff] [blame] | 221 | |
John Stiles | f64e407 | 2020-12-10 10:34:27 -0500 | [diff] [blame] | 222 | String getBitcastIntrinsic(const Type& outType); |
| 223 | |
John Stiles | 86424eb | 2020-12-11 11:17:14 -0500 | [diff] [blame] | 224 | String getTempVariable(const Type& varType); |
| 225 | |
John Stiles | b21fac2 | 2020-12-04 15:36:49 -0500 | [diff] [blame] | 226 | void writeFunctionCall(const FunctionCall& c); |
Chris Dalton | dba7aab | 2018-11-15 10:57:49 -0500 | [diff] [blame] | 227 | |
John Stiles | 1bdafbf | 2020-05-28 12:17:20 -0400 | [diff] [blame] | 228 | bool matrixConstructHelperIsNeeded(const Constructor& c); |
| 229 | String getMatrixConstructHelper(const Constructor& c); |
John Stiles | fcf8cb2 | 2020-08-06 14:29:22 -0400 | [diff] [blame] | 230 | void assembleMatrixFromMatrix(const Type& sourceMatrix, int rows, int columns); |
John Stiles | 8e3b6be | 2020-10-13 11:14:08 -0400 | [diff] [blame] | 231 | void assembleMatrixFromExpressions(const ExpressionArray& args, int rows, int columns); |
Ethan Nicholas | 842d31b | 2019-01-22 10:59:11 -0500 | [diff] [blame] | 232 | |
Brian Osman | 93aed9a | 2020-12-28 15:18:46 -0500 | [diff] [blame] | 233 | void writeMatrixCompMult(); |
Ethan Nicholas | 0dc8087 | 2019-02-08 15:46:24 -0500 | [diff] [blame] | 234 | void writeMatrixTimesEqualHelper(const Type& left, const Type& right, const Type& result); |
| 235 | |
John Stiles | d7199b2 | 2020-12-30 16:22:58 -0500 | [diff] [blame] | 236 | void writeArgumentList(const ExpressionArray& arguments); |
| 237 | |
John Stiles | 791c27d | 2020-12-30 14:56:57 -0500 | [diff] [blame] | 238 | void writeSimpleIntrinsic(const FunctionCall& c); |
| 239 | |
John Stiles | d7199b2 | 2020-12-30 16:22:58 -0500 | [diff] [blame] | 240 | void writeIntrinsicCall(const FunctionCall& c, IntrinsicKind kind); |
Timothy Liang | 6403b0e | 2018-05-17 10:40:04 -0400 | [diff] [blame] | 241 | |
Ethan Nicholas | 842d31b | 2019-01-22 10:59:11 -0500 | [diff] [blame] | 242 | bool canCoerce(const Type& t1, const Type& t2); |
| 243 | |
| 244 | void writeConstructor(const Constructor& c, Precedence parentPrecedence); |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 245 | |
| 246 | void writeFieldAccess(const FieldAccess& f); |
| 247 | |
| 248 | void writeSwizzle(const Swizzle& swizzle); |
| 249 | |
| 250 | static Precedence GetBinaryPrecedence(Token::Kind op); |
| 251 | |
| 252 | void writeBinaryExpression(const BinaryExpression& b, Precedence parentPrecedence); |
| 253 | |
| 254 | void writeTernaryExpression(const TernaryExpression& t, Precedence parentPrecedence); |
| 255 | |
| 256 | void writeIndexExpression(const IndexExpression& expr); |
| 257 | |
| 258 | void writePrefixExpression(const PrefixExpression& p, Precedence parentPrecedence); |
| 259 | |
| 260 | void writePostfixExpression(const PostfixExpression& p, Precedence parentPrecedence); |
| 261 | |
| 262 | void writeBoolLiteral(const BoolLiteral& b); |
| 263 | |
| 264 | void writeIntLiteral(const IntLiteral& i); |
| 265 | |
| 266 | void writeFloatLiteral(const FloatLiteral& f); |
| 267 | |
| 268 | void writeSetting(const Setting& s); |
| 269 | |
| 270 | void writeStatement(const Statement& s); |
| 271 | |
John Stiles | 8f2a0cf | 2020-10-13 12:48:21 -0400 | [diff] [blame] | 272 | void writeStatements(const StatementArray& statements); |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 273 | |
| 274 | void writeBlock(const Block& b); |
| 275 | |
| 276 | void writeIfStatement(const IfStatement& stmt); |
| 277 | |
| 278 | void writeForStatement(const ForStatement& f); |
| 279 | |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 280 | void writeDoStatement(const DoStatement& d); |
| 281 | |
| 282 | void writeSwitchStatement(const SwitchStatement& s); |
| 283 | |
John Stiles | 986c7fb | 2020-12-01 14:44:56 -0500 | [diff] [blame] | 284 | void writeReturnStatementFromMain(); |
| 285 | |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 286 | void writeReturnStatement(const ReturnStatement& r); |
| 287 | |
| 288 | void writeProgramElement(const ProgramElement& e); |
| 289 | |
| 290 | Requirements requirements(const FunctionDeclaration& f); |
| 291 | |
Ethan Nicholas | ff350cb | 2020-05-14 14:05:13 -0400 | [diff] [blame] | 292 | Requirements requirements(const Expression* e); |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 293 | |
Ethan Nicholas | ff350cb | 2020-05-14 14:05:13 -0400 | [diff] [blame] | 294 | Requirements requirements(const Statement* s); |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 295 | |
John Stiles | da5cdf6 | 2021-01-28 11:47:29 -0500 | [diff] [blame] | 296 | int getUniformBinding(const Modifiers& m); |
| 297 | |
| 298 | int getUniformSet(const Modifiers& m); |
| 299 | |
John Stiles | d7199b2 | 2020-12-30 16:22:58 -0500 | [diff] [blame] | 300 | std::unordered_map<String, IntrinsicKind> fIntrinsicMap; |
Timothy Liang | 651286f | 2018-06-07 09:55:33 -0400 | [diff] [blame] | 301 | std::unordered_set<String> fReservedWords; |
Timothy Liang | a06f215 | 2018-05-24 15:33:31 -0400 | [diff] [blame] | 302 | std::unordered_map<const Type::Field*, const InterfaceBlock*> fInterfaceBlockMap; |
| 303 | std::unordered_map<const InterfaceBlock*, String> fInterfaceBlockNameMap; |
| 304 | int fAnonInterfaceCount = 0; |
Timothy Liang | 7d63778 | 2018-06-05 09:58:07 -0400 | [diff] [blame] | 305 | int fPaddingCount = 0; |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 306 | const char* fLineEnding; |
| 307 | const Context& fContext; |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 308 | String fFunctionHeader; |
Chris Dalton | dba7aab | 2018-11-15 10:57:49 -0500 | [diff] [blame] | 309 | StringStream fExtraFunctions; |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 310 | Program::Kind fProgramKind; |
| 311 | int fVarCount = 0; |
| 312 | int fIndentation = 0; |
| 313 | bool fAtLineStart = false; |
Chris Dalton | dba7aab | 2018-11-15 10:57:49 -0500 | [diff] [blame] | 314 | std::set<String> fWrittenIntrinsics; |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 315 | // true if we have run into usages of dFdx / dFdy |
| 316 | bool fFoundDerivatives = false; |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 317 | std::unordered_map<const FunctionDeclaration*, Requirements> fRequirements; |
| 318 | bool fSetupFragPositionGlobal = false; |
| 319 | bool fSetupFragPositionLocal = false; |
John Stiles | 1bdafbf | 2020-05-28 12:17:20 -0400 | [diff] [blame] | 320 | std::unordered_set<String> fHelpers; |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 321 | int fUniformBuffer = -1; |
Ethan Nicholas | f931e40 | 2019-07-26 15:40:33 -0400 | [diff] [blame] | 322 | String fRTHeightName; |
John Stiles | 986c7fb | 2020-12-01 14:44:56 -0500 | [diff] [blame] | 323 | const FunctionDeclaration* fCurrentFunction = nullptr; |
John Stiles | 06b84ef | 2020-12-09 12:35:48 -0500 | [diff] [blame] | 324 | int fSwizzleHelperCount = 0; |
| 325 | bool fIgnoreVariableReferenceModifiers = false; |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 326 | |
John Stiles | 7571f9e | 2020-09-02 22:42:33 -0400 | [diff] [blame] | 327 | using INHERITED = CodeGenerator; |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 328 | }; |
| 329 | |
John Stiles | a6841be | 2020-08-06 14:11:56 -0400 | [diff] [blame] | 330 | } // namespace SkSL |
Ethan Nicholas | cc30577 | 2017-10-13 16:17:45 -0400 | [diff] [blame] | 331 | |
| 332 | #endif |