| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SKSL_SPIRVCODEGENERATOR | 8 #ifndef SKSL_SPIRVCODEGENERATOR |
| 9 #define SKSL_SPIRVCODEGENERATOR | 9 #define SKSL_SPIRVCODEGENERATOR |
| 10 | 10 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 kTexture2D_SpecialIntrinsic, | 85 kTexture2D_SpecialIntrinsic, |
| 86 kTextureProj_SpecialIntrinsic | 86 kTextureProj_SpecialIntrinsic |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 void setupIntrinsics(); | 89 void setupIntrinsics(); |
| 90 | 90 |
| 91 SpvId nextId(); | 91 SpvId nextId(); |
| 92 | 92 |
| 93 SpvId getType(const Type& type); | 93 SpvId getType(const Type& type); |
| 94 | 94 |
| 95 SpvId getFunctionType(const FunctionDeclaration& function); | 95 SpvId getFunctionType(std::shared_ptr<FunctionDeclaration> function); |
| 96 | 96 |
| 97 SpvId getPointerType(const Type& type, SpvStorageClass_ storageClass); | 97 SpvId getPointerType(std::shared_ptr<Type> type, SpvStorageClass_ storageCla
ss); |
| 98 | 98 |
| 99 std::vector<SpvId> getAccessChain(Expression& expr, std::ostream& out); | 99 std::vector<SpvId> getAccessChain(Expression& expr, std::ostream& out); |
| 100 | 100 |
| 101 void writeLayout(const Layout& layout, SpvId target); | 101 void writeLayout(const Layout& layout, SpvId target); |
| 102 | 102 |
| 103 void writeLayout(const Layout& layout, SpvId target, int member); | 103 void writeLayout(const Layout& layout, SpvId target, int member); |
| 104 | 104 |
| 105 void writeStruct(const Type& type, SpvId resultId); | 105 void writeStruct(const Type& type, SpvId resultId); |
| 106 | 106 |
| 107 void writeProgramElement(ProgramElement& pe, std::ostream& out); | 107 void writeProgramElement(ProgramElement& pe, std::ostream& out); |
| 108 | 108 |
| 109 SpvId writeInterfaceBlock(InterfaceBlock& intf); | 109 SpvId writeInterfaceBlock(InterfaceBlock& intf); |
| 110 | 110 |
| 111 SpvId writeFunctionStart(const FunctionDeclaration& f, std::ostream& out); | 111 SpvId writeFunctionStart(std::shared_ptr<FunctionDeclaration> f, std::ostrea
m& out); |
| 112 | 112 |
| 113 SpvId writeFunctionDeclaration(const FunctionDeclaration& f, std::ostream& o
ut); | 113 SpvId writeFunctionDeclaration(std::shared_ptr<FunctionDeclaration> f, std::
ostream& out); |
| 114 | 114 |
| 115 SpvId writeFunction(const FunctionDefinition& f, std::ostream& out); | 115 SpvId writeFunction(FunctionDefinition& f, std::ostream& out); |
| 116 | 116 |
| 117 void writeGlobalVars(VarDeclaration& v, std::ostream& out); | 117 void writeGlobalVars(VarDeclaration& v, std::ostream& out); |
| 118 | 118 |
| 119 void writeVarDeclaration(VarDeclaration& decl, std::ostream& out); | 119 void writeVarDeclaration(VarDeclaration& decl, std::ostream& out); |
| 120 | 120 |
| 121 SpvId writeVariableReference(VariableReference& ref, std::ostream& out); | 121 SpvId writeVariableReference(VariableReference& ref, std::ostream& out); |
| 122 | 122 |
| 123 std::unique_ptr<LValue> getLValue(Expression& value, std::ostream& out); | 123 std::unique_ptr<LValue> getLValue(Expression& value, std::ostream& out); |
| 124 | 124 |
| 125 SpvId writeExpression(Expression& expr, std::ostream& out); | 125 SpvId writeExpression(Expression& expr, std::ostream& out); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 225 |
| 226 void writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2, int32_t w
ord3, int32_t word4, | 226 void writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2, int32_t w
ord3, int32_t word4, |
| 227 int32_t word5, int32_t word6, int32_t word7, int32_t w
ord8, | 227 int32_t word5, int32_t word6, int32_t word7, int32_t w
ord8, |
| 228 std::ostream& out); | 228 std::ostream& out); |
| 229 | 229 |
| 230 uint64_t fCapabilities; | 230 uint64_t fCapabilities; |
| 231 SpvId fIdCount; | 231 SpvId fIdCount; |
| 232 SpvId fGLSLExtendedInstructions; | 232 SpvId fGLSLExtendedInstructions; |
| 233 typedef std::tuple<IntrinsicKind, int32_t, int32_t, int32_t, int32_t> Intrin
sic; | 233 typedef std::tuple<IntrinsicKind, int32_t, int32_t, int32_t, int32_t> Intrin
sic; |
| 234 std::unordered_map<std::string, Intrinsic> fIntrinsicMap; | 234 std::unordered_map<std::string, Intrinsic> fIntrinsicMap; |
| 235 std::unordered_map<const FunctionDeclaration*, SpvId> fFunctionMap; | 235 std::unordered_map<std::shared_ptr<FunctionDeclaration>, SpvId> fFunctionMap
; |
| 236 std::unordered_map<const Variable*, SpvId> fVariableMap; | 236 std::unordered_map<std::shared_ptr<Variable>, SpvId> fVariableMap; |
| 237 std::unordered_map<const Variable*, int32_t> fInterfaceBlockMap; | 237 std::unordered_map<std::shared_ptr<Variable>, int32_t> fInterfaceBlockMap; |
| 238 std::unordered_map<std::string, SpvId> fTypeMap; | 238 std::unordered_map<std::string, SpvId> fTypeMap; |
| 239 std::stringstream fCapabilitiesBuffer; | 239 std::stringstream fCapabilitiesBuffer; |
| 240 std::stringstream fGlobalInitializersBuffer; | 240 std::stringstream fGlobalInitializersBuffer; |
| 241 std::stringstream fConstantBuffer; | 241 std::stringstream fConstantBuffer; |
| 242 std::stringstream fExternalFunctionsBuffer; | 242 std::stringstream fExternalFunctionsBuffer; |
| 243 std::stringstream fVariableBuffer; | 243 std::stringstream fVariableBuffer; |
| 244 std::stringstream fNameBuffer; | 244 std::stringstream fNameBuffer; |
| 245 std::stringstream fDecorationBuffer; | 245 std::stringstream fDecorationBuffer; |
| 246 | 246 |
| 247 SpvId fBoolTrue; | 247 SpvId fBoolTrue; |
| 248 SpvId fBoolFalse; | 248 SpvId fBoolFalse; |
| 249 std::unordered_map<int64_t, SpvId> fIntConstants; | 249 std::unordered_map<int64_t, SpvId> fIntConstants; |
| 250 std::unordered_map<uint64_t, SpvId> fUIntConstants; | 250 std::unordered_map<uint64_t, SpvId> fUIntConstants; |
| 251 std::unordered_map<float, SpvId> fFloatConstants; | 251 std::unordered_map<float, SpvId> fFloatConstants; |
| 252 std::unordered_map<double, SpvId> fDoubleConstants; | 252 std::unordered_map<double, SpvId> fDoubleConstants; |
| 253 // label of the current block, or 0 if we are not in a block | 253 // label of the current block, or 0 if we are not in a block |
| 254 SpvId fCurrentBlock; | 254 SpvId fCurrentBlock; |
| 255 std::stack<SpvId> fBreakTarget; | 255 std::stack<SpvId> fBreakTarget; |
| 256 std::stack<SpvId> fContinueTarget; | 256 std::stack<SpvId> fContinueTarget; |
| 257 | 257 |
| 258 friend class PointerLValue; | 258 friend class PointerLValue; |
| 259 friend class SwizzleLValue; | 259 friend class SwizzleLValue; |
| 260 }; | 260 }; |
| 261 | 261 |
| 262 } | 262 } |
| 263 | 263 |
| 264 #endif | 264 #endif |
| OLD | NEW |