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

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

Issue 2288033003: Turned on SkSL->GLSL compiler (Closed)
Patch Set: fixed unused variable error Created 4 years, 3 months 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
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_GLSLCODEGENERATOR 8 #ifndef SKSL_GLSLCODEGENERATOR
9 #define SKSL_GLSLCODEGENERATOR 9 #define SKSL_GLSLCODEGENERATOR
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 namespace SkSL { 43 namespace SkSL {
44 44
45 #define kLast_Capability SpvCapabilityMultiViewport 45 #define kLast_Capability SpvCapabilityMultiViewport
46 46
47 struct GLCaps { 47 struct GLCaps {
48 int fVersion; 48 int fVersion;
49 enum { 49 enum {
50 kGL_Standard, 50 kGL_Standard,
51 kGLES_Standard 51 kGLES_Standard
52 } fStandard; 52 } fStandard;
53 bool fIsCoreProfile;
54 bool fUsesPrecisionModifiers;
55 bool fMustDeclareFragmentShaderOutput;
56 // The Tegra3 compiler will sometimes never return if we have min(abs(x), y)
57 bool fCanUseMinAndAbsTogether;
53 }; 58 };
54 59
55 /** 60 /**
56 * Converts a Program into GLSL code. 61 * Converts a Program into GLSL code.
57 */ 62 */
58 class GLSLCodeGenerator : public CodeGenerator { 63 class GLSLCodeGenerator : public CodeGenerator {
59 public: 64 public:
60 enum Precedence { 65 enum Precedence {
61 kParentheses_Precedence = 1, 66 kParentheses_Precedence = 1,
62 kPostfix_Precedence = 2, 67 kPostfix_Precedence = 2,
(...skipping 11 matching lines...) Expand all
74 kLogicalOr_Precedence = 14, 79 kLogicalOr_Precedence = 14,
75 kTernary_Precedence = 15, 80 kTernary_Precedence = 15,
76 kAssignment_Precedence = 16, 81 kAssignment_Precedence = 16,
77 kSequence_Precedence = 17, 82 kSequence_Precedence = 17,
78 kTopLevel_Precedence = 18 83 kTopLevel_Precedence = 18
79 }; 84 };
80 85
81 GLSLCodeGenerator(const Context* context, GLCaps caps) 86 GLSLCodeGenerator(const Context* context, GLCaps caps)
82 : fContext(*context) 87 : fContext(*context)
83 , fCaps(caps) 88 , fCaps(caps)
89 , fVarCount(0)
84 , fIndentation(0) 90 , fIndentation(0)
85 , fAtLineStart(true) {} 91 , fAtLineStart(true) {}
86 92
87 void generateCode(const Program& program, std::ostream& out) override; 93 void generateCode(const Program& program, std::ostream& out) override;
88 94
89 private: 95 private:
90 void write(const char* s); 96 void write(const char* s);
91 97
92 void writeLine(); 98 void writeLine();
93 99
(...skipping 10 matching lines...) Expand all
104 void writeInterfaceBlock(const InterfaceBlock& intf); 110 void writeInterfaceBlock(const InterfaceBlock& intf);
105 111
106 void writeFunctionStart(const FunctionDeclaration& f); 112 void writeFunctionStart(const FunctionDeclaration& f);
107 113
108 void writeFunctionDeclaration(const FunctionDeclaration& f); 114 void writeFunctionDeclaration(const FunctionDeclaration& f);
109 115
110 void writeFunction(const FunctionDefinition& f); 116 void writeFunction(const FunctionDefinition& f);
111 117
112 void writeLayout(const Layout& layout); 118 void writeLayout(const Layout& layout);
113 119
114 void writeModifiers(const Modifiers& modifiers); 120 void writeModifiers(const Modifiers& modifiers, bool globalContext);
115 121
116 void writeGlobalVars(const VarDeclaration& vs); 122 void writeGlobalVars(const VarDeclaration& vs);
117 123
118 void writeVarDeclarations(const VarDeclarations& decl); 124 void writeVarDeclarations(const VarDeclarations& decl, bool global);
119 125
120 void writeVariableReference(const VariableReference& ref); 126 void writeVariableReference(const VariableReference& ref);
121 127
122 void writeExpression(const Expression& expr, Precedence parentPrecedence); 128 void writeExpression(const Expression& expr, Precedence parentPrecedence);
123 129
124 void writeIntrinsicCall(const FunctionCall& c); 130 void writeIntrinsicCall(const FunctionCall& c);
125 131
132 void writeMinAbsHack(Expression& absExpr, Expression& otherExpr);
133
126 void writeFunctionCall(const FunctionCall& c); 134 void writeFunctionCall(const FunctionCall& c);
127 135
128 void writeConstructor(const Constructor& c); 136 void writeConstructor(const Constructor& c);
129 137
130 void writeFieldAccess(const FieldAccess& f); 138 void writeFieldAccess(const FieldAccess& f);
131 139
132 void writeSwizzle(const Swizzle& swizzle); 140 void writeSwizzle(const Swizzle& swizzle);
133 141
134 void writeBinaryExpression(const BinaryExpression& b, Precedence parentPrece dence); 142 void writeBinaryExpression(const BinaryExpression& b, Precedence parentPrece dence);
135 143
(...skipping 21 matching lines...) Expand all
157 165
158 void writeWhileStatement(const WhileStatement& w); 166 void writeWhileStatement(const WhileStatement& w);
159 167
160 void writeDoStatement(const DoStatement& d); 168 void writeDoStatement(const DoStatement& d);
161 169
162 void writeReturnStatement(const ReturnStatement& r); 170 void writeReturnStatement(const ReturnStatement& r);
163 171
164 const Context& fContext; 172 const Context& fContext;
165 const GLCaps fCaps; 173 const GLCaps fCaps;
166 std::ostream* fOut; 174 std::ostream* fOut;
175 std::string fFunctionHeader;
176 Program::Kind fProgramKind;
177 int fVarCount;
167 int fIndentation; 178 int fIndentation;
168 bool fAtLineStart; 179 bool fAtLineStart;
169 // Keeps track of which struct types we have written. Given that we are unli kely to ever write 180 // Keeps track of which struct types we have written. Given that we are unli kely to ever write
170 // more than one or two structs per shader, a simple linear search will be f aster than anything 181 // more than one or two structs per shader, a simple linear search will be f aster than anything
171 // fancier. 182 // fancier.
172 std::vector<const Type*> fWrittenStructs; 183 std::vector<const Type*> fWrittenStructs;
173 }; 184 };
174 185
175 } 186 }
176 187
177 #endif 188 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698