diff --git a/include/tint/tint.h b/include/tint/tint.h index 7b55fe2ac3..d8c52336c3 100644 --- a/include/tint/tint.h +++ b/include/tint/tint.h @@ -25,7 +25,6 @@ #include "src/reader/reader.h" #include "src/transform/binding_remapper.h" #include "src/transform/bound_array_accessors.h" -#include "src/transform/canonicalize_entry_point_io.h" #include "src/transform/emit_vertex_point_size.h" #include "src/transform/first_index_offset.h" #include "src/transform/manager.h" diff --git a/samples/main.cc b/samples/main.cc index f31d8add7d..2f9f7b82ed 100644 --- a/samples/main.cc +++ b/samples/main.cc @@ -701,15 +701,11 @@ int main(int argc, const char** argv) { #endif // TINT_BUILD_SPV_WRITER #if TINT_BUILD_MSL_WRITER case Format::kMsl: - transform_manager.append( - std::make_unique()); transform_manager.append(std::make_unique()); break; #endif // TINT_BUILD_MSL_WRITER #if TINT_BUILD_HLSL_WRITER case Format::kHlsl: - transform_manager.append( - std::make_unique()); transform_manager.append(std::make_unique()); break; #endif // TINT_BUILD_HLSL_WRITER diff --git a/src/transform/hlsl.cc b/src/transform/hlsl.cc index 0fdddc9931..d2af5059b5 100644 --- a/src/transform/hlsl.cc +++ b/src/transform/hlsl.cc @@ -23,6 +23,7 @@ #include "src/semantic/statement.h" #include "src/semantic/variable.h" #include "src/transform/calculate_array_length.h" +#include "src/transform/canonicalize_entry_point_io.h" #include "src/transform/decompose_storage_access.h" #include "src/transform/manager.h" @@ -34,6 +35,7 @@ Hlsl::~Hlsl() = default; Transform::Output Hlsl::Run(const Program* in, const DataMap& data) { Manager manager; + manager.Add(); manager.Add(); manager.Add(); auto out = manager.Run(in, data); diff --git a/src/transform/msl.cc b/src/transform/msl.cc index af4bc448e6..48cebce7c0 100644 --- a/src/transform/msl.cc +++ b/src/transform/msl.cc @@ -17,6 +17,8 @@ #include #include "src/program_builder.h" +#include "src/transform/canonicalize_entry_point_io.h" +#include "src/transform/manager.h" namespace tint { namespace transform { @@ -262,12 +264,19 @@ const char* kReservedKeywords[] = {"access", Msl::Msl() = default; Msl::~Msl() = default; -Transform::Output Msl::Run(const Program* in, const DataMap&) { - ProgramBuilder out; - CloneContext ctx(&out, in); +Transform::Output Msl::Run(const Program* in, const DataMap& data) { + Manager manager; + manager.Add(); + auto out = manager.Run(in, data); + if (!out.program.IsValid()) { + return out; + } + + ProgramBuilder builder; + CloneContext ctx(&builder, &out.program); RenameReservedKeywords(&ctx, kReservedKeywords); ctx.Clone(); - return Output{Program(std::move(out))}; + return Output{Program(std::move(builder))}; } } // namespace transform diff --git a/src/writer/hlsl/test_helper.h b/src/writer/hlsl/test_helper.h index 2f5f356344..de6611c362 100644 --- a/src/writer/hlsl/test_helper.h +++ b/src/writer/hlsl/test_helper.h @@ -20,9 +20,7 @@ #include #include "gtest/gtest.h" -#include "src/transform/canonicalize_entry_point_io.h" #include "src/transform/hlsl.h" -#include "src/transform/manager.h" #include "src/writer/hlsl/generator_impl.h" namespace tint { @@ -101,11 +99,7 @@ class TestHelperBase : public BODY, public ProgramBuilder { << formatter.format(program->Diagnostics()); }(); - tint::transform::Manager transform_manager; - transform_manager.append( - std::make_unique()); - transform_manager.append(std::make_unique()); - auto result = transform_manager.Run(program.get()); + auto result = transform::Hlsl().Run(program.get()); [&]() { ASSERT_TRUE(result.program.IsValid()) << formatter.format(result.program.Diagnostics()); diff --git a/src/writer/msl/test_helper.h b/src/writer/msl/test_helper.h index a40d2c3bcf..37d5200e87 100644 --- a/src/writer/msl/test_helper.h +++ b/src/writer/msl/test_helper.h @@ -20,8 +20,6 @@ #include "gtest/gtest.h" #include "src/program_builder.h" -#include "src/transform/canonicalize_entry_point_io.h" -#include "src/transform/manager.h" #include "src/transform/msl.h" #include "src/writer/msl/generator_impl.h" @@ -76,11 +74,7 @@ class TestHelperBase : public BASE, public ProgramBuilder { << diag::Formatter().format(program->Diagnostics()); }(); - tint::transform::Manager transform_manager; - transform_manager.append( - std::make_unique()); - transform_manager.append(std::make_unique()); - auto result = transform_manager.Run(program.get()); + auto result = transform::Msl().Run(program.get()); [&]() { ASSERT_TRUE(result.program.IsValid()) << diag::Formatter().format(result.program.Diagnostics());