2020-11-25 21:55:37 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2020 Google LLC
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "src/sksl/SkSLCompiler.h"
|
|
|
|
|
|
|
|
#include "tests/Test.h"
|
|
|
|
|
|
|
|
static void test(skiatest::Reporter* r,
|
2021-11-19 15:59:59 +00:00
|
|
|
const SkSL::ShaderCaps& caps,
|
2020-11-25 21:55:37 +00:00
|
|
|
const char* src,
|
2021-02-16 18:29:15 +00:00
|
|
|
SkSL::ProgramKind kind = SkSL::ProgramKind::kFragment) {
|
2020-11-25 21:55:37 +00:00
|
|
|
SkSL::Compiler compiler(&caps);
|
|
|
|
SkSL::Program::Settings settings;
|
|
|
|
SkSL::String output;
|
|
|
|
std::unique_ptr<SkSL::Program> program = compiler.convertProgram(kind, SkSL::String(src),
|
|
|
|
settings);
|
|
|
|
if (!program) {
|
|
|
|
SkDebugf("Unexpected error compiling %s\n%s", src, compiler.errorText().c_str());
|
|
|
|
REPORTER_ASSERT(r, program);
|
|
|
|
} else {
|
|
|
|
REPORTER_ASSERT(r, compiler.toSPIRV(*program, &output));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_TEST(SkSLSPIRVTestbed, r) {
|
|
|
|
// Add in your SkSL here.
|
|
|
|
test(r,
|
|
|
|
*SkSL::ShaderCapsFactory::Default(),
|
|
|
|
R"__SkSL__(
|
|
|
|
void main() {
|
|
|
|
sk_FragColor = half4(0);
|
|
|
|
}
|
|
|
|
)__SkSL__");
|
|
|
|
}
|