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