diff options
author | Ethan Nicholas <ethannicholas@google.com> | 2017-10-13 16:17:45 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-10-24 14:47:01 +0000 |
commit | cc3057784b89cdde367fd1d645f1cf69d0eee5f7 (patch) | |
tree | 0d8a93d1d53e9ed3ad4974911a74bbc046c10bb8 /src/sksl/SkSLMain.cpp | |
parent | 2ebf3d11f1c6d43e1d8304c4efcc6a041c1bf6a0 (diff) |
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>
Diffstat (limited to 'src/sksl/SkSLMain.cpp')
-rw-r--r-- | src/sksl/SkSLMain.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/sksl/SkSLMain.cpp b/src/sksl/SkSLMain.cpp index 9f1fec1f1b..8ba0933f8c 100644 --- a/src/sksl/SkSLMain.cpp +++ b/src/sksl/SkSLMain.cpp @@ -93,6 +93,22 @@ int main(int argc, const char** argv) { 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 @@ int main(int argc, const char** argv) { 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); } } |