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

Side by Side Diff: src/sksl/SkSLCompiler.cpp

Issue 2185393003: added initial GLSL support to skslc (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fixed gn build Created 4 years, 4 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
« no previous file with comments | « src/sksl/SkSLCompiler.h ('k') | src/sksl/SkSLGLSLCodeGenerator.h » ('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 #include "SkSLCompiler.h" 8 #include "SkSLCompiler.h"
9 9
10 #include <fstream> 10 #include <fstream>
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 ADD_TYPE(IVec4); 60 ADD_TYPE(IVec4);
61 ADD_TYPE(UInt); 61 ADD_TYPE(UInt);
62 ADD_TYPE(UVec2); 62 ADD_TYPE(UVec2);
63 ADD_TYPE(UVec3); 63 ADD_TYPE(UVec3);
64 ADD_TYPE(UVec4); 64 ADD_TYPE(UVec4);
65 ADD_TYPE(Bool); 65 ADD_TYPE(Bool);
66 ADD_TYPE(BVec2); 66 ADD_TYPE(BVec2);
67 ADD_TYPE(BVec3); 67 ADD_TYPE(BVec3);
68 ADD_TYPE(BVec4); 68 ADD_TYPE(BVec4);
69 ADD_TYPE(Mat2x2); 69 ADD_TYPE(Mat2x2);
70 types->addWithoutOwnership("mat2x2", fContext.fMat2x2_Type.get());
70 ADD_TYPE(Mat2x3); 71 ADD_TYPE(Mat2x3);
71 ADD_TYPE(Mat2x4); 72 ADD_TYPE(Mat2x4);
72 ADD_TYPE(Mat3x2); 73 ADD_TYPE(Mat3x2);
73 ADD_TYPE(Mat3x3); 74 ADD_TYPE(Mat3x3);
75 types->addWithoutOwnership("mat3x3", fContext.fMat3x3_Type.get());
74 ADD_TYPE(Mat3x4); 76 ADD_TYPE(Mat3x4);
75 ADD_TYPE(Mat4x2); 77 ADD_TYPE(Mat4x2);
76 ADD_TYPE(Mat4x3); 78 ADD_TYPE(Mat4x3);
77 ADD_TYPE(Mat4x4); 79 ADD_TYPE(Mat4x4);
80 types->addWithoutOwnership("mat4x4", fContext.fMat4x4_Type.get());
78 ADD_TYPE(GenType); 81 ADD_TYPE(GenType);
79 ADD_TYPE(GenDType); 82 ADD_TYPE(GenDType);
80 ADD_TYPE(GenIType); 83 ADD_TYPE(GenIType);
81 ADD_TYPE(GenUType); 84 ADD_TYPE(GenUType);
82 ADD_TYPE(GenBType); 85 ADD_TYPE(GenBType);
83 ADD_TYPE(Mat); 86 ADD_TYPE(Mat);
84 ADD_TYPE(Vec); 87 ADD_TYPE(Vec);
85 ADD_TYPE(GVec); 88 ADD_TYPE(GVec);
86 ADD_TYPE(GVec2); 89 ADD_TYPE(GVec2);
87 ADD_TYPE(GVec3); 90 ADD_TYPE(GVec3);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 void Compiler::writeErrorCount() { 219 void Compiler::writeErrorCount() {
217 if (fErrorCount) { 220 if (fErrorCount) {
218 fErrorText += to_string(fErrorCount) + " error"; 221 fErrorText += to_string(fErrorCount) + " error";
219 if (fErrorCount > 1) { 222 if (fErrorCount > 1) {
220 fErrorText += "s"; 223 fErrorText += "s";
221 } 224 }
222 fErrorText += "\n"; 225 fErrorText += "\n";
223 } 226 }
224 } 227 }
225 228
226 #include <fstream> 229 bool Compiler::toSPIRV(Program::Kind kind, const std::string& text, std::ostream & out) {
227 bool Compiler::toSPIRV(Program::Kind kind, std::string text, std::ostream& out) {
228 auto program = this->convertProgram(kind, text); 230 auto program = this->convertProgram(kind, text);
229 if (fErrorCount == 0) { 231 if (fErrorCount == 0) {
230 SkSL::SPIRVCodeGenerator cg(&fContext); 232 SkSL::SPIRVCodeGenerator cg(&fContext);
231 cg.generateCode(*program.get(), out); 233 cg.generateCode(*program.get(), out);
232 ASSERT(!out.rdstate()); 234 ASSERT(!out.rdstate());
233 } 235 }
234 return fErrorCount == 0; 236 return fErrorCount == 0;
235 } 237 }
236 238
237 bool Compiler::toSPIRV(Program::Kind kind, std::string text, std::string* out) { 239 bool Compiler::toSPIRV(Program::Kind kind, const std::string& text, std::string* out) {
238 std::stringstream buffer; 240 std::stringstream buffer;
239 bool result = this->toSPIRV(kind, text, buffer); 241 bool result = this->toSPIRV(kind, text, buffer);
240 if (result) { 242 if (result) {
241 *out = buffer.str(); 243 *out = buffer.str();
242 } 244 }
245 return result;
246 }
247
248 bool Compiler::toGLSL(Program::Kind kind, const std::string& text, GLCaps caps,
249 std::ostream& out) {
250 auto program = this->convertProgram(kind, text);
251 if (fErrorCount == 0) {
252 SkSL::GLSLCodeGenerator cg(&fContext, caps);
253 cg.generateCode(*program.get(), out);
254 ASSERT(!out.rdstate());
255 }
243 return fErrorCount == 0; 256 return fErrorCount == 0;
244 } 257 }
245 258
259 bool Compiler::toGLSL(Program::Kind kind, const std::string& text, GLCaps caps,
260 std::string* out) {
261 std::stringstream buffer;
262 bool result = this->toGLSL(kind, text, caps, buffer);
263 if (result) {
264 *out = buffer.str();
265 }
266 return result;
267 }
268
246 } // namespace 269 } // namespace
OLDNEW
« no previous file with comments | « src/sksl/SkSLCompiler.h ('k') | src/sksl/SkSLGLSLCodeGenerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698