2020-09-23 18:08:40 +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"
|
|
|
|
|
2020-11-02 17:26:22 +00:00
|
|
|
static void test(skiatest::Reporter* r,
|
|
|
|
const GrShaderCaps& caps,
|
|
|
|
const char* src,
|
2020-09-23 18:08:40 +00:00
|
|
|
SkSL::Program::Kind kind = SkSL::Program::kFragment_Kind) {
|
2020-11-02 17:26:22 +00:00
|
|
|
SkSL::Compiler compiler(&caps);
|
|
|
|
SkSL::Program::Settings settings;
|
2020-09-23 18:08:40 +00:00
|
|
|
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.toGLSL(*program, &output));
|
|
|
|
REPORTER_ASSERT(r, output != "");
|
2020-09-23 19:24:51 +00:00
|
|
|
//SkDebugf("GLSL output:\n\n%s", output.c_str());
|
2020-09-23 18:08:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_TEST(SkSLGLSLTestbed, r) {
|
|
|
|
// Add in your SkSL here.
|
|
|
|
test(r,
|
|
|
|
*SkSL::ShaderCapsFactory::Default(),
|
|
|
|
R"__SkSL__(
|
|
|
|
void main() {
|
|
|
|
sk_FragColor = half4(0);
|
|
|
|
}
|
|
|
|
)__SkSL__");
|
|
|
|
}
|