fuzzers: Hook up the Program::printer
When TINT_BUILD_WGSL_WRITER is enabled. This allows printing of the AST for debugging purposes. Change-Id: I92b5911c16cb1e5fd22e81def00de33e9257f575 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78541 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
parent
c28f5926be
commit
98fe545826
|
@ -114,6 +114,16 @@ CommonFuzzer::~CommonFuzzer() = default;
|
|||
int CommonFuzzer::Run(const uint8_t* data, size_t size) {
|
||||
tint::SetInternalCompilerErrorReporter(&TintInternalCompilerErrorReporter);
|
||||
|
||||
#if TINT_BUILD_WGSL_WRITER
|
||||
tint::Program::printer = [](const tint::Program* program) {
|
||||
auto result = tint::writer::wgsl::Generate(program, {});
|
||||
if (!result.error.empty()) {
|
||||
return "error: " + result.error;
|
||||
}
|
||||
return result.wgsl;
|
||||
};
|
||||
#endif // TINT_BUILD_WGSL_WRITER
|
||||
|
||||
Program program;
|
||||
|
||||
#if TINT_BUILD_SPV_READER
|
||||
|
|
Loading…
Reference in New Issue