skia2/tests/SkSLMetalTestbed.cpp
John Stiles 34de5cb57b Convert remaining Metal tests to golden outputs.
Metal-specific tests are pretty thin on the ground here, and some of
the remaining tests no longer added value as they were already covered
pretty well by existing tests in Shared. The majority of remaining tests
were specific to Metal's lack of flexible matrix casting (and SkSL's
ability to paper over this with helper functions).

Change-Id: I7b3c445268b95320e7f46ec88d793c315d43ee8a
Bug: skia:10694
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/334956
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2020-11-16 16:32:56 +00:00

41 lines
1.2 KiB
C++

/*
* 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::Program::Kind kind = SkSL::Program::kFragment_Kind) {
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__");
}