dbd4e6f0c0
This change will allow these types to be forward-declared; C++ doesn't allow forward declaration of types declared inside a struct. Moving these types out of Programs resulted in a large diff. The Settings::Value helper class has been moved inside of the IRGenerator. In practice, it was actually just an implementation detail of how IRGenerator looks up caps-values by name. It seems very unlikely that this will be necessary elsewhere going forward. Change-Id: I6119417fae608f1c492a27de746d2b550ef8ca20 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/370836 Reviewed-by: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com> Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com>
51 lines
1.6 KiB
C++
51 lines
1.6 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 "src/sksl/SkSLStringStream.h"
|
|
|
|
#include "tests/Test.h"
|
|
|
|
static void test(skiatest::Reporter* r, const GrShaderCaps& caps, const char* src) {
|
|
SkSL::Program::Settings settings;
|
|
settings.fRemoveDeadFunctions = false;
|
|
SkSL::Compiler compiler(&caps);
|
|
SkSL::StringStream output;
|
|
std::unique_ptr<SkSL::Program> program = compiler.convertProgram(
|
|
SkSL::ProgramKind::kFragmentProcessor,
|
|
SkSL::String(src),
|
|
settings);
|
|
if (!program) {
|
|
SkDebugf("Unexpected error compiling %s\n%s", src, compiler.errorText().c_str());
|
|
return;
|
|
}
|
|
REPORTER_ASSERT(r, program);
|
|
bool success = compiler.toH(*program, "Test", output);
|
|
if (!success) {
|
|
SkDebugf("Unexpected error generating .h file for %s\n%s",
|
|
src, compiler.errorText().c_str());
|
|
}
|
|
REPORTER_ASSERT(r, success);
|
|
output.reset();
|
|
success = compiler.toCPP(*program, "Test", output);
|
|
if (!success) {
|
|
SkDebugf("Unexpected error generating .cpp file for %s\n%s",
|
|
src, compiler.errorText().c_str());
|
|
}
|
|
REPORTER_ASSERT(r, success);
|
|
}
|
|
|
|
DEF_TEST(SkSLFPTestbed, r) {
|
|
test(r,
|
|
*SkSL::ShaderCapsFactory::Default(),
|
|
R"__SkSL__(
|
|
half4 main(float2 coord) {
|
|
return half4(0);
|
|
}
|
|
)__SkSL__");
|
|
}
|