blob: 23017a94e96f25c42e24ad060f3d72de64431c8c [file] [log] [blame]
John Stilesba067aa2020-11-25 16:55:37 -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,
Jim Van Verth3b0eacc2021-11-19 10:59:59 -050013 const SkSL::ShaderCaps& caps,
John Stilesba067aa2020-11-25 16:55:37 -050014 const char* src,
John Stilesdbd4e6f2021-02-16 13:29:15 -050015 SkSL::ProgramKind kind = SkSL::ProgramKind::kFragment) {
John Stilesba067aa2020-11-25 16:55:37 -050016 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.toSPIRV(*program, &output));
26 }
27}
28
29DEF_TEST(SkSLSPIRVTestbed, r) {
30 // Add in your SkSL here.
31 test(r,
32 *SkSL::ShaderCapsFactory::Default(),
33 R"__SkSL__(
34 void main() {
35 sk_FragColor = half4(0);
36 }
37 )__SkSL__");
38}