From 67e1de42c259336759f72cf674201950f6a790c1 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Fri, 3 Mar 2023 18:38:38 +0000 Subject: [PATCH] tint/transform: Reduce verbosity of TINT_PRINT_PROGRAM_FOR_EACH_TRANSFORM Print the input program, and the output of each run transform. Significantly reduces stdout spam, and also shows you transform input - which is what you really want. Issue: tint:1853 Change-Id: Iaea0dc16de63daffcf0b0c715af14d194b700468 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/122480 Reviewed-by: James Price Commit-Queue: Ben Clayton Kokoro: Kokoro --- src/tint/transform/manager.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/tint/transform/manager.cc b/src/tint/transform/manager.cc index f93c5d761a..ca23a4097d 100644 --- a/src/tint/transform/manager.cc +++ b/src/tint/transform/manager.cc @@ -19,6 +19,7 @@ #define TINT_PRINT_PROGRAM_FOR_EACH_TRANSFORM 0 #if TINT_PRINT_PROGRAM_FOR_EACH_TRANSFORM +#include #define TINT_IF_PRINT_PROGRAM(x) x #else // TINT_PRINT_PROGRAM_FOR_EACH_TRANSFORM #define TINT_IF_PRINT_PROGRAM(x) @@ -52,9 +53,9 @@ Transform::ApplyResult Manager::Apply(const Program* program, std::optional output; - for (const auto& transform : transforms_) { - TINT_IF_PRINT_PROGRAM(print_program("Input to", transform.get())); + TINT_IF_PRINT_PROGRAM(print_program("Input of", this)); + for (const auto& transform : transforms_) { if (auto result = transform->Apply(program, inputs, outputs)) { output.emplace(std::move(result.value())); program = &output.value(); @@ -64,15 +65,15 @@ Transform::ApplyResult Manager::Apply(const Program* program, break; } - if (transform == transforms_.back()) { - TINT_IF_PRINT_PROGRAM(print_program("Output of", transform.get())); - } + TINT_IF_PRINT_PROGRAM(print_program("Output of", transform.get())); } else { TINT_IF_PRINT_PROGRAM(std::cout << "Skipped " << transform->TypeInfo().name << std::endl); } } + TINT_IF_PRINT_PROGRAM(print_program("Final output of", this)); + return output; }