preliminary SkSL Metal backend
Bug: skia:
Change-Id: I03e839fb4f1061bc6d1b1b72d54fd39ca7bd7b84
Reviewed-on: https://skia-review.googlesource.com/51245
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/sksl/SkSLMain.cpp b/src/sksl/SkSLMain.cpp
index 9f1fec1..8ba0933 100644
--- a/src/sksl/SkSLMain.cpp
+++ b/src/sksl/SkSLMain.cpp
@@ -93,6 +93,22 @@
printf("error writing '%s'\n", argv[2]);
exit(4);
}
+ } else if (name.endsWith(".metal")) {
+ SkSL::FileOutputStream out(argv[2]);
+ SkSL::Compiler compiler;
+ if (!out.isValid()) {
+ printf("error writing '%s'\n", argv[2]);
+ exit(4);
+ }
+ std::unique_ptr<SkSL::Program> program = compiler.convertProgram(kind, text, settings);
+ if (!program || !compiler.toMetal(*program, out)) {
+ printf("%s", compiler.errorText().c_str());
+ exit(3);
+ }
+ if (!out.close()) {
+ printf("error writing '%s'\n", argv[2]);
+ exit(4);
+ }
} else if (name.endsWith(".h")) {
SkSL::FileOutputStream out(argv[2]);
SkSL::Compiler compiler(SkSL::Compiler::kPermitInvalidStaticTests_Flag);
@@ -128,6 +144,7 @@
exit(4);
}
} else {
- printf("expected output filename to end with '.spirv', '.glsl', '.cpp', or '.h'");
+ printf("expected output filename to end with '.spirv', '.glsl', '.cpp', '.h', or '.metal'");
+ exit(1);
}
}