You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.2 KiB
41 lines
1.2 KiB
/*
|
|
* 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,
|
|
const GrShaderCaps& caps,
|
|
const char* src,
|
|
SkSL::ProgramKind kind = SkSL::ProgramKind::kFragment) {
|
|
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.toMetal(*program, &output));
|
|
REPORTER_ASSERT(r, output != "");
|
|
//SkDebugf("Metal output:\n\n%s", output.c_str());
|
|
}
|
|
}
|
|
|
|
DEF_TEST(SkSLMetalTestbed, r) {
|
|
// Add in your SkSL here.
|
|
test(r,
|
|
*SkSL::ShaderCapsFactory::Default(),
|
|
R"__SkSL__(
|
|
void main() {
|
|
sk_FragColor = half4(0);
|
|
}
|
|
)__SkSL__");
|
|
}
|