skia2/tests/SkSLSPIRVTestbed.cpp
John Stiles ba067aa72b Migrate dedicated SPIR-V tests to golden outputs.
There were a surprisingly small number of dedicated SPIR-V tests.
SkSLSPIRVBadOffset was the only test that didn't already exist in the
golden outputs, although it actually contained two tests.

The SPIRVTest.cpp file has been converted to SPIRVTestbed.cpp, which can
be used for local debugging of SPIR-V issues via dm (like GLSLTestbed
and MetalTestbed).

Change-Id: I978d8a7cf5735af7f537113d2b9411ce42cfcf88
Bug: skia:10694
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338756
Auto-Submit: John Stiles <johnstiles@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
2020-11-30 15:05:54 +00:00

39 lines
1.1 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.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__");
}