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

Unified 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: added initial GLSL support to skslc Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: src/sksl/SkSLCompiler.cpp
diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp
index 0d65b107ecf28bc587bf03e1b9ee332eeb3bac1d..b6e5fa4df55dc340de701a24ad9c36a20903ed1e 100644
--- a/src/sksl/SkSLCompiler.cpp
+++ b/src/sksl/SkSLCompiler.cpp
@@ -223,8 +223,7 @@ void Compiler::writeErrorCount() {
}
}
-#include <fstream>
-bool Compiler::toSPIRV(Program::Kind kind, std::string text, std::ostream& out) {
+bool Compiler::toSPIRV(Program::Kind kind, const std::string& text, std::ostream& out) {
auto program = this->convertProgram(kind, text);
if (fErrorCount == 0) {
SkSL::SPIRVCodeGenerator cg(&fContext);
@@ -234,13 +233,34 @@ bool Compiler::toSPIRV(Program::Kind kind, std::string text, std::ostream& out)
return fErrorCount == 0;
}
-bool Compiler::toSPIRV(Program::Kind kind, std::string text, std::string* out) {
+bool Compiler::toSPIRV(Program::Kind kind, const std::string& text, std::string* out) {
std::stringstream buffer;
bool result = this->toSPIRV(kind, text, buffer);
if (result) {
*out = buffer.str();
}
+ return result;
+}
+
+bool Compiler::toGLSL(Program::Kind kind, const std::string& text, GLCaps caps,
+ std::ostream& out) {
+ auto program = this->convertProgram(kind, text);
+ if (fErrorCount == 0) {
+ SkSL::GLSLCodeGenerator cg(&fContext, caps);
+ cg.generateCode(*program.get(), out);
+ ASSERT(!out.rdstate());
+ }
return fErrorCount == 0;
}
+bool Compiler::toGLSL(Program::Kind kind, const std::string& text, GLCaps caps,
+ std::string* out) {
+ std::stringstream buffer;
+ bool result = this->toGLSL(kind, text, caps, buffer);
+ if (result) {
+ *out = buffer.str();
+ }
+ return result;
+}
+
} // namespace

Powered by Google App Engine
This is Rietveld 408576698