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 | 11d5397 | 2016-11-28 11:23:23 -0500 | [diff] [blame] | 7 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 8 | #include "src/sksl/SkSLIRGenerator.h" |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 9 | |
| 10 | #include "limits.h" |
John Stiles | 44e96be | 2020-08-31 13:16:04 -0400 | [diff] [blame] | 11 | #include <iterator> |
John Stiles | fbd050b | 2020-08-03 13:21:46 -0400 | [diff] [blame] | 12 | #include <memory> |
Ethan Nicholas | af19769 | 2017-02-27 13:26:45 -0500 | [diff] [blame] | 13 | #include <unordered_set> |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 14 | |
Ethan Nicholas | daed259 | 2021-03-04 14:30:25 -0500 | [diff] [blame] | 15 | #include "include/private/SkSLLayout.h" |
John Stiles | 6bef6a7 | 2020-12-02 14:26:04 -0500 | [diff] [blame] | 16 | #include "include/private/SkTArray.h" |
Ethan Nicholas | be65cd5 | 2021-05-18 12:09:01 -0400 | [diff] [blame] | 17 | #include "include/sksl/DSLCore.h" |
John Stiles | b2705a1 | 2021-02-19 10:55:14 -0500 | [diff] [blame] | 18 | #include "src/core/SkScopeExit.h" |
Ethan Nicholas | 6e0fa40 | 2020-08-20 14:08:23 -0400 | [diff] [blame] | 19 | #include "src/sksl/SkSLAnalysis.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 20 | #include "src/sksl/SkSLCompiler.h" |
John Stiles | dc8ec31 | 2021-01-11 11:05:21 -0500 | [diff] [blame] | 21 | #include "src/sksl/SkSLConstantFolder.h" |
Ethan Nicholas | 58014fa | 2021-09-29 17:18:18 -0400 | [diff] [blame] | 22 | #include "src/sksl/SkSLIntrinsicMap.h" |
Brian Osman | 0018501 | 2021-02-04 16:07:11 -0500 | [diff] [blame] | 23 | #include "src/sksl/SkSLOperators.h" |
Brian Osman | 3000d6b | 2020-07-31 15:57:28 -0400 | [diff] [blame] | 24 | #include "src/sksl/SkSLUtil.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 25 | #include "src/sksl/ir/SkSLBinaryExpression.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 26 | #include "src/sksl/ir/SkSLBreakStatement.h" |
| 27 | #include "src/sksl/ir/SkSLConstructor.h" |
| 28 | #include "src/sksl/ir/SkSLContinueStatement.h" |
| 29 | #include "src/sksl/ir/SkSLDiscardStatement.h" |
| 30 | #include "src/sksl/ir/SkSLDoStatement.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 31 | #include "src/sksl/ir/SkSLExpressionStatement.h" |
Ethan Nicholas | 9e6a393 | 2019-05-17 16:31:21 -0400 | [diff] [blame] | 32 | #include "src/sksl/ir/SkSLExternalFunctionCall.h" |
Brian Osman | be0b3b7 | 2021-01-06 14:27:35 -0500 | [diff] [blame] | 33 | #include "src/sksl/ir/SkSLExternalFunctionReference.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 34 | #include "src/sksl/ir/SkSLField.h" |
| 35 | #include "src/sksl/ir/SkSLFieldAccess.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 36 | #include "src/sksl/ir/SkSLForStatement.h" |
| 37 | #include "src/sksl/ir/SkSLFunctionCall.h" |
| 38 | #include "src/sksl/ir/SkSLFunctionDeclaration.h" |
| 39 | #include "src/sksl/ir/SkSLFunctionDefinition.h" |
John Stiles | 569249b | 2020-11-03 12:18:22 -0500 | [diff] [blame] | 40 | #include "src/sksl/ir/SkSLFunctionPrototype.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 41 | #include "src/sksl/ir/SkSLFunctionReference.h" |
| 42 | #include "src/sksl/ir/SkSLIfStatement.h" |
| 43 | #include "src/sksl/ir/SkSLIndexExpression.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 44 | #include "src/sksl/ir/SkSLInterfaceBlock.h" |
John Stiles | 7591d4b | 2021-09-13 13:32:06 -0400 | [diff] [blame] | 45 | #include "src/sksl/ir/SkSLLiteral.h" |
Brian Osman | 3099f79 | 2021-09-01 13:12:16 -0400 | [diff] [blame] | 46 | #include "src/sksl/ir/SkSLMethodReference.h" |
Chris Dalton | b0fd4b1 | 2019-10-29 13:41:22 -0600 | [diff] [blame] | 47 | #include "src/sksl/ir/SkSLNop.h" |
John Stiles | ff6c5bf | 2021-09-07 15:22:02 -0400 | [diff] [blame] | 48 | #include "src/sksl/ir/SkSLPoison.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 49 | #include "src/sksl/ir/SkSLPostfixExpression.h" |
| 50 | #include "src/sksl/ir/SkSLPrefixExpression.h" |
| 51 | #include "src/sksl/ir/SkSLReturnStatement.h" |
| 52 | #include "src/sksl/ir/SkSLSetting.h" |
John Stiles | dc75a97 | 2020-11-25 16:24:55 -0500 | [diff] [blame] | 53 | #include "src/sksl/ir/SkSLStructDefinition.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 54 | #include "src/sksl/ir/SkSLSwitchCase.h" |
| 55 | #include "src/sksl/ir/SkSLSwitchStatement.h" |
| 56 | #include "src/sksl/ir/SkSLSwizzle.h" |
| 57 | #include "src/sksl/ir/SkSLTernaryExpression.h" |
| 58 | #include "src/sksl/ir/SkSLUnresolvedFunction.h" |
| 59 | #include "src/sksl/ir/SkSLVarDeclarations.h" |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 60 | #include "src/sksl/ir/SkSLVariable.h" |
| 61 | #include "src/sksl/ir/SkSLVariableReference.h" |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 62 | |
| 63 | namespace SkSL { |
| 64 | |
John Stiles | c1a98b8 | 2021-02-24 13:35:02 -0500 | [diff] [blame] | 65 | IRGenerator::IRGenerator(const Context* context) |
John Stiles | 10d39d9 | 2021-05-04 16:13:14 -0400 | [diff] [blame] | 66 | : fContext(*context) {} |
Brian Osman | 0006ad0 | 2020-11-18 15:38:39 -0500 | [diff] [blame] | 67 | |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 68 | void IRGenerator::checkVarDeclaration(int line, const Modifiers& modifiers, const Type* baseType, |
Ethan Nicholas | 489e552 | 2021-01-20 10:53:11 -0500 | [diff] [blame] | 69 | Variable::Storage storage) { |
John Stiles | e609598 | 2021-02-04 12:42:01 -0500 | [diff] [blame] | 70 | if (this->strictES2Mode() && baseType->isArray()) { |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 71 | this->errorReporter().error(line, "array size must appear after variable name"); |
John Stiles | e609598 | 2021-02-04 12:42:01 -0500 | [diff] [blame] | 72 | } |
| 73 | |
John Stiles | 3624aba | 2020-12-22 16:29:53 -0500 | [diff] [blame] | 74 | if (baseType->componentType().isOpaque() && storage != Variable::Storage::kGlobal) { |
John Stiles | b30151e | 2021-01-11 16:13:08 -0500 | [diff] [blame] | 75 | this->errorReporter().error( |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 76 | line, |
John Stiles | b30151e | 2021-01-11 16:13:08 -0500 | [diff] [blame] | 77 | "variables of type '" + baseType->displayName() + "' must be global"); |
Brian Osman | 8232900 | 2020-07-21 09:39:27 -0400 | [diff] [blame] | 78 | } |
Brian Osman | 8c26479 | 2021-07-01 16:41:27 -0400 | [diff] [blame] | 79 | if ((modifiers.fFlags & Modifiers::kIn_Flag) && baseType->isMatrix()) { |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 80 | this->errorReporter().error(line, "'in' variables may not have matrix type"); |
Brian Osman | 8c26479 | 2021-07-01 16:41:27 -0400 | [diff] [blame] | 81 | } |
| 82 | if ((modifiers.fFlags & Modifiers::kIn_Flag) && (modifiers.fFlags & Modifiers::kUniform_Flag)) { |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 83 | this->errorReporter().error(line, "'in uniform' variables not permitted"); |
Brian Osman | 2fe83fe | 2019-12-16 13:17:59 -0500 | [diff] [blame] | 84 | } |
John Stiles | bb2ef92 | 2021-07-26 08:32:07 -0400 | [diff] [blame] | 85 | if (this->isRuntimeEffect()) { |
Brian Osman | 5c62582 | 2021-04-06 14:28:07 -0400 | [diff] [blame] | 86 | if (modifiers.fFlags & Modifiers::kIn_Flag) { |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 87 | this->errorReporter().error(line, "'in' variables not permitted in runtime effects"); |
Brian Osman | a4b9169 | 2020-08-10 14:26:16 -0400 | [diff] [blame] | 88 | } |
| 89 | } |
Brian Osman | 5c62582 | 2021-04-06 14:28:07 -0400 | [diff] [blame] | 90 | if (baseType->isEffectChild() && !(modifiers.fFlags & Modifiers::kUniform_Flag)) { |
| 91 | this->errorReporter().error( |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 92 | line, "variables of type '" + baseType->displayName() + "' must be uniform"); |
Brian Osman | 5c62582 | 2021-04-06 14:28:07 -0400 | [diff] [blame] | 93 | } |
Brian Osman | b32d66b | 2020-04-30 17:12:03 -0400 | [diff] [blame] | 94 | if (modifiers.fLayout.fFlags & Layout::kSRGBUnpremul_Flag) { |
John Stiles | bb2ef92 | 2021-07-26 08:32:07 -0400 | [diff] [blame] | 95 | if (!this->isRuntimeEffect()) { |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 96 | this->errorReporter().error(line, |
John Stiles | b30151e | 2021-01-11 16:13:08 -0500 | [diff] [blame] | 97 | "'srgb_unpremul' is only permitted in runtime effects"); |
Brian Osman | b32d66b | 2020-04-30 17:12:03 -0400 | [diff] [blame] | 98 | } |
| 99 | if (!(modifiers.fFlags & Modifiers::kUniform_Flag)) { |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 100 | this->errorReporter().error(line, |
John Stiles | b30151e | 2021-01-11 16:13:08 -0500 | [diff] [blame] | 101 | "'srgb_unpremul' is only permitted on 'uniform' variables"); |
Brian Osman | b32d66b | 2020-04-30 17:12:03 -0400 | [diff] [blame] | 102 | } |
| 103 | auto validColorXformType = [](const Type& t) { |
John Stiles | 9aeed13 | 2020-11-24 17:36:06 -0500 | [diff] [blame] | 104 | return t.isVector() && t.componentType().isFloat() && |
Brian Osman | b32d66b | 2020-04-30 17:12:03 -0400 | [diff] [blame] | 105 | (t.columns() == 3 || t.columns() == 4); |
| 106 | }; |
John Stiles | c0c5106 | 2020-12-03 17:16:29 -0500 | [diff] [blame] | 107 | if (!validColorXformType(*baseType) && !(baseType->isArray() && |
Brian Osman | b32d66b | 2020-04-30 17:12:03 -0400 | [diff] [blame] | 108 | validColorXformType(baseType->componentType()))) { |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 109 | this->errorReporter().error(line, |
John Stiles | b30151e | 2021-01-11 16:13:08 -0500 | [diff] [blame] | 110 | "'srgb_unpremul' is only permitted on half3, half4, " |
| 111 | "float3, or float4 variables"); |
Brian Osman | b32d66b | 2020-04-30 17:12:03 -0400 | [diff] [blame] | 112 | } |
| 113 | } |
John Stiles | b806da4 | 2021-08-04 16:26:47 -0400 | [diff] [blame] | 114 | int permitted = Modifiers::kConst_Flag | Modifiers::kHighp_Flag | Modifiers::kMediump_Flag | |
| 115 | Modifiers::kLowp_Flag; |
Ethan Nicholas | 453f67f | 2020-10-09 10:43:45 -0400 | [diff] [blame] | 116 | if (storage == Variable::Storage::kGlobal) { |
Brian Osman | 9ca38ff | 2021-02-18 12:58:54 -0500 | [diff] [blame] | 117 | permitted |= Modifiers::kIn_Flag | Modifiers::kOut_Flag | Modifiers::kUniform_Flag | |
Brian Osman | e49703f | 2021-04-19 11:15:24 -0400 | [diff] [blame] | 118 | Modifiers::kFlat_Flag | Modifiers::kNoPerspective_Flag; |
Ethan Nicholas | 63d7ee3 | 2020-08-17 10:57:12 -0400 | [diff] [blame] | 119 | } |
Brian Osman | a654faa | 2021-02-26 11:52:59 -0500 | [diff] [blame] | 120 | // TODO(skbug.com/11301): Migrate above checks into building a mask of permitted layout flags |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 121 | CheckModifiers(fContext, line, modifiers, permitted, /*permittedLayoutFlags=*/~0); |
Ethan Nicholas | 489e552 | 2021-01-20 10:53:11 -0500 | [diff] [blame] | 122 | } |
| 123 | |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 124 | std::unique_ptr<Variable> IRGenerator::convertVar(int line, const Modifiers& modifiers, |
Ethan Nicholas | 962dec4 | 2021-06-10 13:06:39 -0400 | [diff] [blame] | 125 | const Type* baseType, skstd::string_view name, |
Ethan Nicholas | bd97400 | 2021-02-22 16:20:06 -0500 | [diff] [blame] | 126 | bool isArray, |
| 127 | std::unique_ptr<Expression> arraySize, |
| 128 | Variable::Storage storage) { |
Ethan Nicholas | 489e552 | 2021-01-20 10:53:11 -0500 | [diff] [blame] | 129 | if (modifiers.fLayout.fLocation == 0 && modifiers.fLayout.fIndex == 0 && |
John Stiles | d120464 | 2021-02-17 16:30:02 -0500 | [diff] [blame] | 130 | (modifiers.fFlags & Modifiers::kOut_Flag) && |
John Stiles | e67bd13 | 2021-03-19 18:39:25 -0400 | [diff] [blame] | 131 | this->programKind() == ProgramKind::kFragment && name != Compiler::FRAGCOLOR_NAME) { |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 132 | this->errorReporter().error(line, |
Ethan Nicholas | 489e552 | 2021-01-20 10:53:11 -0500 | [diff] [blame] | 133 | "out location=0, index=0 is reserved for sk_FragColor"); |
| 134 | } |
| 135 | const Type* type = baseType; |
| 136 | int arraySizeValue = 0; |
| 137 | if (isArray) { |
Ethan Nicholas | 489e552 | 2021-01-20 10:53:11 -0500 | [diff] [blame] | 138 | SkASSERT(arraySize); |
John Stiles | 7253a20 | 2021-08-23 09:24:33 -0400 | [diff] [blame] | 139 | arraySizeValue = type->convertArraySize(fContext, std::move(arraySize)); |
John Stiles | 80b02af | 2021-02-12 17:07:51 -0500 | [diff] [blame] | 140 | if (!arraySizeValue) { |
| 141 | return {}; |
| 142 | } |
Ethan Nicholas | 489e552 | 2021-01-20 10:53:11 -0500 | [diff] [blame] | 143 | type = fSymbolTable->addArrayDimension(type, arraySizeValue); |
| 144 | } |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 145 | return std::make_unique<Variable>(line, this->modifiersPool().add(modifiers), name, |
John Stiles | c876489 | 2021-10-04 11:56:30 -0400 | [diff] [blame] | 146 | type, fContext.fConfig->fIsBuiltinCode, storage); |
Ethan Nicholas | bd97400 | 2021-02-22 16:20:06 -0500 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | std::unique_ptr<Statement> IRGenerator::convertVarDeclaration(std::unique_ptr<Variable> var, |
Ethan Nicholas | dd2fdea | 2021-07-20 15:23:04 -0400 | [diff] [blame] | 150 | std::unique_ptr<Expression> value, |
| 151 | bool addToSymbolTable) { |
John Stiles | e67bd13 | 2021-03-19 18:39:25 -0400 | [diff] [blame] | 152 | std::unique_ptr<Statement> varDecl = VarDeclaration::Convert(fContext, var.get(), |
| 153 | std::move(value)); |
| 154 | if (!varDecl) { |
| 155 | return nullptr; |
| 156 | } |
| 157 | |
| 158 | // Detect the declaration of magical variables. |
| 159 | if ((var->storage() == Variable::Storage::kGlobal) && var->name() == Compiler::FRAGCOLOR_NAME) { |
| 160 | // Silently ignore duplicate definitions of `sk_FragColor`. |
| 161 | const Symbol* symbol = (*fSymbolTable)[var->name()]; |
| 162 | if (symbol) { |
Brian Osman | 7b36149 | 2021-02-25 11:25:30 -0500 | [diff] [blame] | 163 | return nullptr; |
| 164 | } |
John Stiles | e67bd13 | 2021-03-19 18:39:25 -0400 | [diff] [blame] | 165 | } else if ((var->storage() == Variable::Storage::kGlobal || |
| 166 | var->storage() == Variable::Storage::kInterfaceBlock) && |
| 167 | var->name() == Compiler::RTADJUST_NAME) { |
| 168 | // `sk_RTAdjust` is special, and makes the IR generator emit position-fixup expressions. |
| 169 | if (fRTAdjust) { |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 170 | this->errorReporter().error(var->fLine, "duplicate definition of 'sk_RTAdjust'"); |
Brian Osman | 7b36149 | 2021-02-25 11:25:30 -0500 | [diff] [blame] | 171 | return nullptr; |
| 172 | } |
John Stiles | e67bd13 | 2021-03-19 18:39:25 -0400 | [diff] [blame] | 173 | if (var->type() != *fContext.fTypes.fFloat4) { |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 174 | this->errorReporter().error(var->fLine, "sk_RTAdjust must have type 'float4'"); |
Brian Osman | fc4b991 | 2021-03-05 16:45:06 -0500 | [diff] [blame] | 175 | return nullptr; |
| 176 | } |
Ethan Nicholas | 489e552 | 2021-01-20 10:53:11 -0500 | [diff] [blame] | 177 | fRTAdjust = var.get(); |
| 178 | } |
John Stiles | e67bd13 | 2021-03-19 18:39:25 -0400 | [diff] [blame] | 179 | |
Ethan Nicholas | dd2fdea | 2021-07-20 15:23:04 -0400 | [diff] [blame] | 180 | if (addToSymbolTable) { |
| 181 | fSymbolTable->add(std::move(var)); |
| 182 | } else { |
| 183 | fSymbolTable->takeOwnershipOfSymbol(std::move(var)); |
| 184 | } |
John Stiles | e67bd13 | 2021-03-19 18:39:25 -0400 | [diff] [blame] | 185 | return varDecl; |
Ethan Nicholas | bd97400 | 2021-02-22 16:20:06 -0500 | [diff] [blame] | 186 | } |
| 187 | |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 188 | std::unique_ptr<Statement> IRGenerator::convertVarDeclaration(int line, |
Ethan Nicholas | bd97400 | 2021-02-22 16:20:06 -0500 | [diff] [blame] | 189 | const Modifiers& modifiers, |
| 190 | const Type* baseType, |
Ethan Nicholas | 962dec4 | 2021-06-10 13:06:39 -0400 | [diff] [blame] | 191 | skstd::string_view name, |
Ethan Nicholas | bd97400 | 2021-02-22 16:20:06 -0500 | [diff] [blame] | 192 | bool isArray, |
| 193 | std::unique_ptr<Expression> arraySize, |
| 194 | std::unique_ptr<Expression> value, |
| 195 | Variable::Storage storage) { |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 196 | std::unique_ptr<Variable> var = this->convertVar(line, modifiers, baseType, name, isArray, |
Ethan Nicholas | bd97400 | 2021-02-22 16:20:06 -0500 | [diff] [blame] | 197 | std::move(arraySize), storage); |
| 198 | if (!var) { |
| 199 | return nullptr; |
| 200 | } |
| 201 | return this->convertVarDeclaration(std::move(var), std::move(value)); |
Ethan Nicholas | 489e552 | 2021-01-20 10:53:11 -0500 | [diff] [blame] | 202 | } |
| 203 | |
John Stiles | 3b20489 | 2021-08-27 17:35:35 -0400 | [diff] [blame] | 204 | void IRGenerator::appendRTAdjustFixupToVertexMain(const FunctionDeclaration& decl, Block* body) { |
John Stiles | d45ebbc | 2021-05-18 16:54:36 -0400 | [diff] [blame] | 205 | using namespace SkSL::dsl; |
| 206 | using SkSL::dsl::Swizzle; // disambiguate from SkSL::Swizzle |
John Stiles | 3b20489 | 2021-08-27 17:35:35 -0400 | [diff] [blame] | 207 | using OwnerKind = SkSL::FieldAccess::OwnerKind; |
John Stiles | d45ebbc | 2021-05-18 16:54:36 -0400 | [diff] [blame] | 208 | |
John Stiles | 3b20489 | 2021-08-27 17:35:35 -0400 | [diff] [blame] | 209 | // If this is a vertex program that uses RTAdjust, and this is main()... |
Ethan Nicholas | a97ad0f | 2021-09-02 09:54:04 -0400 | [diff] [blame] | 210 | if ((fRTAdjust || fRTAdjustInterfaceBlock) && decl.isMain() && |
| 211 | ProgramKind::kVertex == this->programKind()) { |
John Stiles | 3b20489 | 2021-08-27 17:35:35 -0400 | [diff] [blame] | 212 | // ... append a line to the end of the function body which fixes up sk_Position. |
| 213 | const Variable* skPerVertex = nullptr; |
Ethan Nicholas | 58014fa | 2021-09-29 17:18:18 -0400 | [diff] [blame] | 214 | if (const ProgramElement* perVertexDecl = |
| 215 | fContext.fIntrinsics->find(Compiler::PERVERTEX_NAME)) { |
John Stiles | 3b20489 | 2021-08-27 17:35:35 -0400 | [diff] [blame] | 216 | SkASSERT(perVertexDecl->is<SkSL::InterfaceBlock>()); |
| 217 | skPerVertex = &perVertexDecl->as<SkSL::InterfaceBlock>().variable(); |
| 218 | } |
| 219 | |
| 220 | SkASSERT(skPerVertex); |
| 221 | auto Ref = [](const Variable* var) -> std::unique_ptr<Expression> { |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 222 | return VariableReference::Make(/*line=*/-1, var); |
John Stiles | 3b20489 | 2021-08-27 17:35:35 -0400 | [diff] [blame] | 223 | }; |
| 224 | auto Field = [&](const Variable* var, int idx) -> std::unique_ptr<Expression> { |
| 225 | return FieldAccess::Make(fContext, Ref(var), idx, OwnerKind::kAnonymousInterfaceBlock); |
| 226 | }; |
| 227 | auto Pos = [&]() -> DSLExpression { |
| 228 | return DSLExpression(FieldAccess::Make(fContext, Ref(skPerVertex), /*fieldIndex=*/0, |
| 229 | OwnerKind::kAnonymousInterfaceBlock)); |
| 230 | }; |
| 231 | auto Adjust = [&]() -> DSLExpression { |
| 232 | return DSLExpression(fRTAdjustInterfaceBlock |
| 233 | ? Field(fRTAdjustInterfaceBlock, fRTAdjustFieldIndex) |
| 234 | : Ref(fRTAdjust)); |
| 235 | }; |
| 236 | |
| 237 | auto fixupStmt = DSLStatement( |
| 238 | Pos() = Float4(Swizzle(Pos(), X, Y) * Swizzle(Adjust(), X, Z) + |
| 239 | Swizzle(Pos(), W, W) * Swizzle(Adjust(), Y, W), |
| 240 | 0, |
| 241 | Pos().w()) |
| 242 | ); |
| 243 | |
| 244 | body->children().push_back(fixupStmt.release()); |
Brian Osman | 88cda17 | 2020-10-09 12:05:16 -0400 | [diff] [blame] | 245 | } |
Robert Phillips | fe8da17 | 2018-01-24 14:52:02 +0000 | [diff] [blame] | 246 | } |
| 247 | |
Ethan Nicholas | 371f6e1 | 2021-05-04 14:30:02 -0400 | [diff] [blame] | 248 | void IRGenerator::CheckModifiers(const Context& context, |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 249 | int line, |
Brian Osman | a654faa | 2021-02-26 11:52:59 -0500 | [diff] [blame] | 250 | const Modifiers& modifiers, |
| 251 | int permittedModifierFlags, |
| 252 | int permittedLayoutFlags) { |
Brian Osman | b5de6be | 2021-08-10 15:16:34 -0400 | [diff] [blame] | 253 | static constexpr struct { Modifiers::Flag flag; const char* name; } kModifierFlags[] = { |
| 254 | { Modifiers::kConst_Flag, "const" }, |
| 255 | { Modifiers::kIn_Flag, "in" }, |
| 256 | { Modifiers::kOut_Flag, "out" }, |
| 257 | { Modifiers::kUniform_Flag, "uniform" }, |
| 258 | { Modifiers::kFlat_Flag, "flat" }, |
| 259 | { Modifiers::kNoPerspective_Flag, "noperspective" }, |
| 260 | { Modifiers::kHasSideEffects_Flag, "sk_has_side_effects" }, |
| 261 | { Modifiers::kInline_Flag, "inline" }, |
| 262 | { Modifiers::kNoInline_Flag, "noinline" }, |
| 263 | { Modifiers::kHighp_Flag, "highp" }, |
| 264 | { Modifiers::kMediump_Flag, "mediump" }, |
| 265 | { Modifiers::kLowp_Flag, "lowp" }, |
John Stiles | efde90d | 2021-08-12 23:06:24 -0400 | [diff] [blame] | 266 | { Modifiers::kES3_Flag, "$es3" }, |
Brian Osman | a654faa | 2021-02-26 11:52:59 -0500 | [diff] [blame] | 267 | }; |
| 268 | |
Brian Osman | b5de6be | 2021-08-10 15:16:34 -0400 | [diff] [blame] | 269 | int modifierFlags = modifiers.fFlags; |
| 270 | for (const auto& f : kModifierFlags) { |
| 271 | if (modifierFlags & f.flag) { |
| 272 | if (!(permittedModifierFlags & f.flag)) { |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 273 | context.fErrors->error(line, "'" + String(f.name) + "' is not permitted here"); |
Brian Osman | b5de6be | 2021-08-10 15:16:34 -0400 | [diff] [blame] | 274 | } |
| 275 | modifierFlags &= ~f.flag; |
| 276 | } |
| 277 | } |
| 278 | SkASSERT(modifierFlags == 0); |
| 279 | |
| 280 | static constexpr struct { Layout::Flag flag; const char* name; } kLayoutFlags[] = { |
| 281 | { Layout::kOriginUpperLeft_Flag, "origin_upper_left"}, |
| 282 | { Layout::kPushConstant_Flag, "push_constant"}, |
| 283 | { Layout::kBlendSupportAllEquations_Flag, "blend_support_all_equations"}, |
| 284 | { Layout::kSRGBUnpremul_Flag, "srgb_unpremul"}, |
| 285 | { Layout::kLocation_Flag, "location"}, |
| 286 | { Layout::kOffset_Flag, "offset"}, |
| 287 | { Layout::kBinding_Flag, "binding"}, |
| 288 | { Layout::kIndex_Flag, "index"}, |
| 289 | { Layout::kSet_Flag, "set"}, |
| 290 | { Layout::kBuiltin_Flag, "builtin"}, |
| 291 | { Layout::kInputAttachmentIndex_Flag, "input_attachment_index"}, |
Brian Osman | b5de6be | 2021-08-10 15:16:34 -0400 | [diff] [blame] | 292 | }; |
Brian Osman | a654faa | 2021-02-26 11:52:59 -0500 | [diff] [blame] | 293 | |
| 294 | int layoutFlags = modifiers.fLayout.fFlags; |
Brian Osman | b5de6be | 2021-08-10 15:16:34 -0400 | [diff] [blame] | 295 | for (const auto& lf : kLayoutFlags) { |
| 296 | if (layoutFlags & lf.flag) { |
| 297 | if (!(permittedLayoutFlags & lf.flag)) { |
Ethan Nicholas | 39f6da4 | 2021-08-23 13:10:07 -0400 | [diff] [blame] | 298 | context.fErrors->error( |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 299 | line, "layout qualifier '" + String(lf.name) + "' is not permitted here"); |
Brian Osman | a654faa | 2021-02-26 11:52:59 -0500 | [diff] [blame] | 300 | } |
Brian Osman | b5de6be | 2021-08-10 15:16:34 -0400 | [diff] [blame] | 301 | layoutFlags &= ~lf.flag; |
Brian Osman | a654faa | 2021-02-26 11:52:59 -0500 | [diff] [blame] | 302 | } |
Brian Osman | b5de6be | 2021-08-10 15:16:34 -0400 | [diff] [blame] | 303 | } |
Brian Osman | a654faa | 2021-02-26 11:52:59 -0500 | [diff] [blame] | 304 | SkASSERT(layoutFlags == 0); |
Ethan Nicholas | 63d7ee3 | 2020-08-17 10:57:12 -0400 | [diff] [blame] | 305 | } |
| 306 | |
Ethan Nicholas | 494eb3e | 2021-08-27 19:17:01 -0400 | [diff] [blame] | 307 | void IRGenerator::scanInterfaceBlock(SkSL::InterfaceBlock& intf) { |
| 308 | const std::vector<Type::Field>& fields = intf.variable().type().componentType().fields(); |
| 309 | for (size_t i = 0; i < fields.size(); ++i) { |
| 310 | const Type::Field& f = fields[i]; |
| 311 | if (f.fName == Compiler::RTADJUST_NAME) { |
| 312 | if (*f.fType == *fContext.fTypes.fFloat4) { |
| 313 | fRTAdjustInterfaceBlock = &intf.variable(); |
| 314 | fRTAdjustFieldIndex = i; |
| 315 | } else { |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 316 | this->errorReporter().error(intf.fLine, "sk_RTAdjust must have type 'float4'"); |
Ethan Nicholas | 494eb3e | 2021-08-27 19:17:01 -0400 | [diff] [blame] | 317 | } |
| 318 | } |
| 319 | } |
| 320 | } |
| 321 | |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 322 | std::unique_ptr<Expression> IRGenerator::convertIdentifier(int line, skstd::string_view name) { |
Ethan Nicholas | 9ead3df | 2021-01-06 12:10:48 -0500 | [diff] [blame] | 323 | const Symbol* result = (*fSymbolTable)[name]; |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 324 | if (!result) { |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 325 | this->errorReporter().error(line, "unknown identifier '" + name + "'"); |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 326 | return nullptr; |
| 327 | } |
Ethan Nicholas | e659214 | 2020-09-08 10:22:09 -0400 | [diff] [blame] | 328 | switch (result->kind()) { |
| 329 | case Symbol::Kind::kFunctionDeclaration: { |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 330 | std::vector<const FunctionDeclaration*> f = { |
John Stiles | 17c5b70 | 2020-08-18 10:40:03 -0400 | [diff] [blame] | 331 | &result->as<FunctionDeclaration>() |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 332 | }; |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 333 | return std::make_unique<FunctionReference>(fContext, line, f); |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 334 | } |
Ethan Nicholas | e659214 | 2020-09-08 10:22:09 -0400 | [diff] [blame] | 335 | case Symbol::Kind::kUnresolvedFunction: { |
John Stiles | 17c5b70 | 2020-08-18 10:40:03 -0400 | [diff] [blame] | 336 | const UnresolvedFunction* f = &result->as<UnresolvedFunction>(); |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 337 | return std::make_unique<FunctionReference>(fContext, line, f->functions()); |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 338 | } |
Ethan Nicholas | e659214 | 2020-09-08 10:22:09 -0400 | [diff] [blame] | 339 | case Symbol::Kind::kVariable: { |
John Stiles | 17c5b70 | 2020-08-18 10:40:03 -0400 | [diff] [blame] | 340 | const Variable* var = &result->as<Variable>(); |
Ethan Nicholas | 041fd0a | 2020-10-07 16:42:04 -0400 | [diff] [blame] | 341 | const Modifiers& modifiers = var->modifiers(); |
| 342 | switch (modifiers.fLayout.fBuiltin) { |
Ethan Nicholas | cd700e9 | 2018-08-24 16:43:57 -0400 | [diff] [blame] | 343 | case SK_FRAGCOORD_BUILTIN: |
Brian Salomon | d8d85b9 | 2021-07-07 09:41:17 -0400 | [diff] [blame] | 344 | if (caps().canUseFragCoord()) { |
| 345 | fInputs.fUseFlipRTUniform = true; |
Ethan Nicholas | cd700e9 | 2018-08-24 16:43:57 -0400 | [diff] [blame] | 346 | } |
Brian Salomon | d8d85b9 | 2021-07-07 09:41:17 -0400 | [diff] [blame] | 347 | break; |
| 348 | case SK_CLOCKWISE_BUILTIN: |
| 349 | fInputs.fUseFlipRTUniform = true; |
| 350 | break; |
Ethan Nicholas | cd700e9 | 2018-08-24 16:43:57 -0400 | [diff] [blame] | 351 | } |
Ethan Nicholas | 86a4340 | 2017-01-19 13:32:00 -0500 | [diff] [blame] | 352 | // default to kRead_RefKind; this will be corrected later if the variable is written to |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 353 | return VariableReference::Make(line, var, VariableReference::RefKind::kRead); |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 354 | } |
Ethan Nicholas | e659214 | 2020-09-08 10:22:09 -0400 | [diff] [blame] | 355 | case Symbol::Kind::kField: { |
John Stiles | 17c5b70 | 2020-08-18 10:40:03 -0400 | [diff] [blame] | 356 | const Field* field = &result->as<Field>(); |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 357 | auto base = VariableReference::Make(line, &field->owner(), |
John Stiles | a94e026 | 2021-04-27 17:29:59 -0400 | [diff] [blame] | 358 | VariableReference::RefKind::kRead); |
John Stiles | 06d600f | 2021-03-08 09:18:21 -0500 | [diff] [blame] | 359 | return FieldAccess::Make(fContext, std::move(base), field->fieldIndex(), |
| 360 | FieldAccess::OwnerKind::kAnonymousInterfaceBlock); |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 361 | } |
Ethan Nicholas | e659214 | 2020-09-08 10:22:09 -0400 | [diff] [blame] | 362 | case Symbol::Kind::kType: { |
John Stiles | a106472 | 2021-10-04 12:43:39 -0400 | [diff] [blame] | 363 | return TypeReference::Convert(fContext, line, &result->as<Type>()); |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 364 | } |
Ethan Nicholas | e659214 | 2020-09-08 10:22:09 -0400 | [diff] [blame] | 365 | case Symbol::Kind::kExternal: { |
Brian Osman | be0b3b7 | 2021-01-06 14:27:35 -0500 | [diff] [blame] | 366 | const ExternalFunction* r = &result->as<ExternalFunction>(); |
Ethan Nicholas | 89cfde1 | 2021-09-27 11:20:34 -0400 | [diff] [blame] | 367 | return std::make_unique<ExternalFunctionReference>(line, r); |
Ethan Nicholas | 91164d1 | 2019-05-15 15:29:54 -0400 | [diff] [blame] | 368 | } |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 369 | default: |
John Stiles | f57207b | 2021-02-02 17:50:34 -0500 | [diff] [blame] | 370 | SK_ABORT("unsupported symbol type %d\n", (int) result->kind()); |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 371 | } |
Ethan Nicholas | c070939 | 2017-06-27 11:20:22 -0400 | [diff] [blame] | 372 | } |
| 373 | |
Ethan Nicholas | 8b3dd34 | 2021-03-23 12:32:56 -0400 | [diff] [blame] | 374 | void IRGenerator::start(const ParsedModule& base, |
Ethan Nicholas | 8b3dd34 | 2021-03-23 12:32:56 -0400 | [diff] [blame] | 375 | std::vector<std::unique_ptr<ProgramElement>>* elements, |
| 376 | std::vector<const ProgramElement*>* sharedElements) { |
Ethan Nicholas | 624a529 | 2021-04-16 14:54:43 -0400 | [diff] [blame] | 377 | fProgramElements = elements; |
| 378 | fSharedElements = sharedElements; |
Brian Osman | 88cda17 | 2020-10-09 12:05:16 -0400 | [diff] [blame] | 379 | fSymbolTable = base.fSymbols; |
Brian Osman | 88cda17 | 2020-10-09 12:05:16 -0400 | [diff] [blame] | 380 | |
Brian Salomon | d8d85b9 | 2021-07-07 09:41:17 -0400 | [diff] [blame] | 381 | fInputs = {}; |
Brian Osman | 88cda17 | 2020-10-09 12:05:16 -0400 | [diff] [blame] | 382 | fRTAdjust = nullptr; |
| 383 | fRTAdjustInterfaceBlock = nullptr; |
Brian Osman | 02bc522 | 2021-01-28 11:00:20 -0500 | [diff] [blame] | 384 | fDefinedStructs.clear(); |
John Stiles | c876489 | 2021-10-04 11:56:30 -0400 | [diff] [blame] | 385 | SymbolTable::Push(&fSymbolTable, fContext.fConfig->fIsBuiltinCode); |
Brian Osman | 88cda17 | 2020-10-09 12:05:16 -0400 | [diff] [blame] | 386 | |
Ethan Nicholas | 55a63af | 2021-05-18 10:12:58 -0400 | [diff] [blame] | 387 | if (this->settings().fExternalFunctions) { |
John Stiles | aecf8d5 | 2021-05-14 12:15:01 -0400 | [diff] [blame] | 388 | // Add any external values to the new symbol table, so they're only visible to this Program. |
Ethan Nicholas | 55a63af | 2021-05-18 10:12:58 -0400 | [diff] [blame] | 389 | for (const std::unique_ptr<ExternalFunction>& ef : *this->settings().fExternalFunctions) { |
Brian Osman | be0b3b7 | 2021-01-06 14:27:35 -0500 | [diff] [blame] | 390 | fSymbolTable->addWithoutOwnership(ef.get()); |
Brian Osman | 88cda17 | 2020-10-09 12:05:16 -0400 | [diff] [blame] | 391 | } |
| 392 | } |
John Stiles | aecf8d5 | 2021-05-14 12:15:01 -0400 | [diff] [blame] | 393 | |
John Stiles | bb2ef92 | 2021-07-26 08:32:07 -0400 | [diff] [blame] | 394 | if (this->isRuntimeEffect() && !fContext.fConfig->fSettings.fEnforceES2Restrictions) { |
John Stiles | 325c808 | 2021-05-17 14:49:05 -0400 | [diff] [blame] | 395 | // We're compiling a runtime effect, but we're not enforcing ES2 restrictions. Add various |
John Stiles | 12eb0ee | 2021-06-01 14:14:50 -0400 | [diff] [blame] | 396 | // non-ES2 types to our symbol table to allow them to be tested. |
John Stiles | aecf8d5 | 2021-05-14 12:15:01 -0400 | [diff] [blame] | 397 | fSymbolTable->addAlias("mat2x2", fContext.fTypes.fFloat2x2.get()); |
| 398 | fSymbolTable->addAlias("mat2x3", fContext.fTypes.fFloat2x3.get()); |
| 399 | fSymbolTable->addAlias("mat2x4", fContext.fTypes.fFloat2x4.get()); |
| 400 | fSymbolTable->addAlias("mat3x2", fContext.fTypes.fFloat3x2.get()); |
| 401 | fSymbolTable->addAlias("mat3x3", fContext.fTypes.fFloat3x3.get()); |
| 402 | fSymbolTable->addAlias("mat3x4", fContext.fTypes.fFloat3x4.get()); |
| 403 | fSymbolTable->addAlias("mat4x2", fContext.fTypes.fFloat4x2.get()); |
| 404 | fSymbolTable->addAlias("mat4x3", fContext.fTypes.fFloat4x3.get()); |
| 405 | fSymbolTable->addAlias("mat4x4", fContext.fTypes.fFloat4x4.get()); |
| 406 | |
| 407 | fSymbolTable->addAlias("float2x3", fContext.fTypes.fFloat2x3.get()); |
| 408 | fSymbolTable->addAlias("float2x4", fContext.fTypes.fFloat2x4.get()); |
| 409 | fSymbolTable->addAlias("float3x2", fContext.fTypes.fFloat3x2.get()); |
| 410 | fSymbolTable->addAlias("float3x4", fContext.fTypes.fFloat3x4.get()); |
| 411 | fSymbolTable->addAlias("float4x2", fContext.fTypes.fFloat4x2.get()); |
| 412 | fSymbolTable->addAlias("float4x3", fContext.fTypes.fFloat4x3.get()); |
| 413 | |
| 414 | fSymbolTable->addAlias("half2x3", fContext.fTypes.fHalf2x3.get()); |
| 415 | fSymbolTable->addAlias("half2x4", fContext.fTypes.fHalf2x4.get()); |
| 416 | fSymbolTable->addAlias("half3x2", fContext.fTypes.fHalf3x2.get()); |
| 417 | fSymbolTable->addAlias("half3x4", fContext.fTypes.fHalf3x4.get()); |
| 418 | fSymbolTable->addAlias("half4x2", fContext.fTypes.fHalf4x2.get()); |
| 419 | fSymbolTable->addAlias("half4x3", fContext.fTypes.fHalf4x3.get()); |
John Stiles | 325c808 | 2021-05-17 14:49:05 -0400 | [diff] [blame] | 420 | |
| 421 | fSymbolTable->addAlias("uint", fContext.fTypes.fUInt.get()); |
| 422 | fSymbolTable->addAlias("uint2", fContext.fTypes.fUInt2.get()); |
| 423 | fSymbolTable->addAlias("uint3", fContext.fTypes.fUInt3.get()); |
| 424 | fSymbolTable->addAlias("uint4", fContext.fTypes.fUInt4.get()); |
John Stiles | 2648716 | 2021-08-10 16:03:44 -0400 | [diff] [blame] | 425 | |
| 426 | fSymbolTable->addAlias("short", fContext.fTypes.fShort.get()); |
| 427 | fSymbolTable->addAlias("short2", fContext.fTypes.fShort2.get()); |
| 428 | fSymbolTable->addAlias("short3", fContext.fTypes.fShort3.get()); |
| 429 | fSymbolTable->addAlias("short4", fContext.fTypes.fShort4.get()); |
| 430 | |
| 431 | fSymbolTable->addAlias("ushort", fContext.fTypes.fUShort.get()); |
| 432 | fSymbolTable->addAlias("ushort2", fContext.fTypes.fUShort2.get()); |
| 433 | fSymbolTable->addAlias("ushort3", fContext.fTypes.fUShort3.get()); |
| 434 | fSymbolTable->addAlias("ushort4", fContext.fTypes.fUShort4.get()); |
John Stiles | aecf8d5 | 2021-05-14 12:15:01 -0400 | [diff] [blame] | 435 | } |
Ethan Nicholas | 8b3dd34 | 2021-03-23 12:32:56 -0400 | [diff] [blame] | 436 | } |
Brian Osman | 88cda17 | 2020-10-09 12:05:16 -0400 | [diff] [blame] | 437 | |
Ethan Nicholas | 8b3dd34 | 2021-03-23 12:32:56 -0400 | [diff] [blame] | 438 | IRGenerator::IRBundle IRGenerator::finish() { |
John Stiles | f2872e6 | 2021-05-04 11:38:43 -0400 | [diff] [blame] | 439 | return IRBundle{std::move(*fProgramElements), |
| 440 | std::move(*fSharedElements), |
John Stiles | f2872e6 | 2021-05-04 11:38:43 -0400 | [diff] [blame] | 441 | std::move(fSymbolTable), |
| 442 | fInputs}; |
Ethan Nicholas | 8b3dd34 | 2021-03-23 12:32:56 -0400 | [diff] [blame] | 443 | } |
| 444 | |
John Stiles | a6841be | 2020-08-06 14:11:56 -0400 | [diff] [blame] | 445 | } // namespace SkSL |