Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: src/sksl/SkSLSPIRVCodeGenerator.h

Issue 2509673002: Revert of added support for push_constant layout (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/sksl/SkSLParser.cpp ('k') | src/sksl/SkSLSPIRVCodeGenerator.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include <sstream> 11 #include <sstream>
12 #include <stack> 12 #include <stack>
13 #include <tuple> 13 #include <tuple>
14 #include <unordered_map> 14 #include <unordered_map>
15 15
16 #include "SkSLCodeGenerator.h" 16 #include "SkSLCodeGenerator.h"
17 #include "SkSLMemoryLayout.h"
18 #include "ir/SkSLBinaryExpression.h" 17 #include "ir/SkSLBinaryExpression.h"
19 #include "ir/SkSLBoolLiteral.h" 18 #include "ir/SkSLBoolLiteral.h"
20 #include "ir/SkSLConstructor.h" 19 #include "ir/SkSLConstructor.h"
21 #include "ir/SkSLFloatLiteral.h" 20 #include "ir/SkSLFloatLiteral.h"
22 #include "ir/SkSLIfStatement.h" 21 #include "ir/SkSLIfStatement.h"
23 #include "ir/SkSLIndexExpression.h" 22 #include "ir/SkSLIndexExpression.h"
24 #include "ir/SkSLInterfaceBlock.h" 23 #include "ir/SkSLInterfaceBlock.h"
25 #include "ir/SkSLIntLiteral.h" 24 #include "ir/SkSLIntLiteral.h"
26 #include "ir/SkSLFieldAccess.h" 25 #include "ir/SkSLFieldAccess.h"
27 #include "ir/SkSLForStatement.h" 26 #include "ir/SkSLForStatement.h"
(...skipping 29 matching lines...) Expand all
57 // by a pointer (e.g. vector swizzles), returns 0. 56 // by a pointer (e.g. vector swizzles), returns 0.
58 virtual SpvId getPointer() = 0; 57 virtual SpvId getPointer() = 0;
59 58
60 virtual SpvId load(std::ostream& out) = 0; 59 virtual SpvId load(std::ostream& out) = 0;
61 60
62 virtual void store(SpvId value, std::ostream& out) = 0; 61 virtual void store(SpvId value, std::ostream& out) = 0;
63 }; 62 };
64 63
65 SPIRVCodeGenerator(const Context* context) 64 SPIRVCodeGenerator(const Context* context)
66 : fContext(*context) 65 : fContext(*context)
67 , fDefaultLayout(MemoryLayout::k140_Standard)
68 , fCapabilities(1 << SpvCapabilityShader) 66 , fCapabilities(1 << SpvCapabilityShader)
69 , fIdCount(1) 67 , fIdCount(1)
70 , fBoolTrue(0) 68 , fBoolTrue(0)
71 , fBoolFalse(0) 69 , fBoolFalse(0)
72 , fCurrentBlock(0) { 70 , fCurrentBlock(0) {
73 this->setupIntrinsics(); 71 this->setupIntrinsics();
74 } 72 }
75 73
76 void generateCode(const Program& program, std::ostream& out) override; 74 void generateCode(const Program& program, std::ostream& out) override;
77 75
(...skipping 10 matching lines...) Expand all
88 kTexture2D_SpecialIntrinsic, 86 kTexture2D_SpecialIntrinsic,
89 kTextureProj_SpecialIntrinsic 87 kTextureProj_SpecialIntrinsic
90 }; 88 };
91 89
92 void setupIntrinsics(); 90 void setupIntrinsics();
93 91
94 SpvId nextId(); 92 SpvId nextId();
95 93
96 SpvId getType(const Type& type); 94 SpvId getType(const Type& type);
97 95
98 SpvId getType(const Type& type, const MemoryLayout& layout);
99
100 SpvId getFunctionType(const FunctionDeclaration& function); 96 SpvId getFunctionType(const FunctionDeclaration& function);
101 97
102 SpvId getPointerType(const Type& type, SpvStorageClass_ storageClass); 98 SpvId getPointerType(const Type& type, SpvStorageClass_ storageClass);
103 99
104 SpvId getPointerType(const Type& type, const MemoryLayout& layout,
105 SpvStorageClass_ storageClass);
106
107 std::vector<SpvId> getAccessChain(const Expression& expr, std::ostream& out) ; 100 std::vector<SpvId> getAccessChain(const Expression& expr, std::ostream& out) ;
108 101
109 void writeLayout(const Layout& layout, SpvId target); 102 void writeLayout(const Layout& layout, SpvId target);
110 103
111 void writeLayout(const Layout& layout, SpvId target, int member); 104 void writeLayout(const Layout& layout, SpvId target, int member);
112 105
113 void writeStruct(const Type& type, const MemoryLayout& layout, SpvId resultI d); 106 void writeStruct(const Type& type, SpvId resultId);
114 107
115 void writeProgramElement(const ProgramElement& pe, std::ostream& out); 108 void writeProgramElement(const ProgramElement& pe, std::ostream& out);
116 109
117 SpvId writeInterfaceBlock(const InterfaceBlock& intf); 110 SpvId writeInterfaceBlock(const InterfaceBlock& intf);
118 111
119 SpvId writeFunctionStart(const FunctionDeclaration& f, std::ostream& out); 112 SpvId writeFunctionStart(const FunctionDeclaration& f, std::ostream& out);
120 113
121 SpvId writeFunctionDeclaration(const FunctionDeclaration& f, std::ostream& o ut); 114 SpvId writeFunctionDeclaration(const FunctionDeclaration& f, std::ostream& o ut);
122 115
123 SpvId writeFunction(const FunctionDefinition& f, std::ostream& out); 116 SpvId writeFunction(const FunctionDefinition& f, std::ostream& out);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 int32_t word5, int32_t word6, std::ostream& out); 222 int32_t word5, int32_t word6, std::ostream& out);
230 223
231 void writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2, int32_t w ord3, int32_t word4, 224 void writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2, int32_t w ord3, int32_t word4,
232 int32_t word5, int32_t word6, int32_t word7, std::ostr eam& out); 225 int32_t word5, int32_t word6, int32_t word7, std::ostr eam& out);
233 226
234 void writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2, int32_t w ord3, int32_t word4, 227 void writeInstruction(SpvOp_ opCode, int32_t word1, int32_t word2, int32_t w ord3, int32_t word4,
235 int32_t word5, int32_t word6, int32_t word7, int32_t w ord8, 228 int32_t word5, int32_t word6, int32_t word7, int32_t w ord8,
236 std::ostream& out); 229 std::ostream& out);
237 230
238 const Context& fContext; 231 const Context& fContext;
239 const MemoryLayout fDefaultLayout;
240 232
241 uint64_t fCapabilities; 233 uint64_t fCapabilities;
242 SpvId fIdCount; 234 SpvId fIdCount;
243 SpvId fGLSLExtendedInstructions; 235 SpvId fGLSLExtendedInstructions;
244 typedef std::tuple<IntrinsicKind, int32_t, int32_t, int32_t, int32_t> Intrin sic; 236 typedef std::tuple<IntrinsicKind, int32_t, int32_t, int32_t, int32_t> Intrin sic;
245 std::unordered_map<std::string, Intrinsic> fIntrinsicMap; 237 std::unordered_map<std::string, Intrinsic> fIntrinsicMap;
246 std::unordered_map<const FunctionDeclaration*, SpvId> fFunctionMap; 238 std::unordered_map<const FunctionDeclaration*, SpvId> fFunctionMap;
247 std::unordered_map<const Variable*, SpvId> fVariableMap; 239 std::unordered_map<const Variable*, SpvId> fVariableMap;
248 std::unordered_map<const Variable*, int32_t> fInterfaceBlockMap; 240 std::unordered_map<const Variable*, int32_t> fInterfaceBlockMap;
249 std::unordered_map<std::string, SpvId> fTypeMap; 241 std::unordered_map<std::string, SpvId> fTypeMap;
(...skipping 16 matching lines...) Expand all
266 std::stack<SpvId> fBreakTarget; 258 std::stack<SpvId> fBreakTarget;
267 std::stack<SpvId> fContinueTarget; 259 std::stack<SpvId> fContinueTarget;
268 260
269 friend class PointerLValue; 261 friend class PointerLValue;
270 friend class SwizzleLValue; 262 friend class SwizzleLValue;
271 }; 263 };
272 264
273 } 265 }
274 266
275 #endif 267 #endif
OLDNEW
« no previous file with comments | « src/sksl/SkSLParser.cpp ('k') | src/sksl/SkSLSPIRVCodeGenerator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698