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