staticbool validate_wgsl(ErrorReporter& reporter,
std::string_view wgsl, bool appendError,
std::string* warnings) { // Enable the WGSL optional features that Skia might rely on.
tint::wgsl::reader::Options options; for (auto extension : {tint::wgsl::Extension::kChromiumExperimentalPixelLocal,
tint::wgsl::Extension::kDualSourceBlending}) {
options.allowed_features.extensions.insert(extension);
}
options.allowed_features.features.insert(
tint::wgsl::LanguageFeature::kUnrestrictedPointerParameters);
// Verify that the WGSL we produced is valid.
tint::Source::File srcFile("", wgsl);
tint::Program program(tint::wgsl::reader::Parse(&srcFile, options));
if (program.Diagnostics().ContainsErrors()) { // The program isn't valid WGSL. if (appendError) { // Report the error via SkDEBUGFAIL and append the generated program for // ease of debugging. We don't do this for our golden test output because // it can change too often
tint::diag::Formatter diagFormatter;
std::string diagOutput = diagFormatter.Format(program.Diagnostics()).Plain();
diagOutput += "\n";
diagOutput += wgsl;
SkDEBUGFAILF("%s", diagOutput.c_str());
} else {
reporter.error(Position(),
std::string("Tint compilation failed.\n\n") + std::string(wgsl));
} returnfalse;
}
if (!program.Diagnostics().empty()) { // The program contains warnings. Report them as-is.
tint::diag::Formatter diagFormatter;
*warnings = diagFormatter.Format(program.Diagnostics()).Plain();
} returntrue;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.