blob: bde821233482210f38d43559612c88317602c8bf [file] [log] [blame]
John Stiles34de5cb2020-11-13 18:14:11 -05001/*
2 * Copyright 2020 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "src/sksl/SkSLCompiler.h"
9
10#include "tests/Test.h"
11
12static void test(skiatest::Reporter* r,
13 const GrShaderCaps& caps,
14 const char* src,
15 SkSL::Program::Kind kind = SkSL::Program::kFragment_Kind) {
16 SkSL::Compiler compiler(&caps);
17 SkSL::Program::Settings settings;
18 SkSL::String output;
19 std::unique_ptr<SkSL::Program> program = compiler.convertProgram(kind, SkSL::String(src),
20 settings);
21 if (!program) {
22 SkDebugf("Unexpected error compiling %s\n%s", src, compiler.errorText().c_str());
23 REPORTER_ASSERT(r, program);
24 } else {
25 REPORTER_ASSERT(r, compiler.toMetal(*program, &output));
26 REPORTER_ASSERT(r, output != "");
27 //SkDebugf("Metal output:\n\n%s", output.c_str());
28 }
29}
30
31DEF_TEST(SkSLMetalTestbed, r) {
32 // Add in your SkSL here.
33 test(r,
34 *SkSL::ShaderCapsFactory::Default(),
35 R"__SkSL__(
36 void main() {
37 sk_FragColor = half4(0);
38 }
39 )__SkSL__");
40}