Automatically run entry point IO canonicalization

Avoids the need for downstream users to manually run this transform.

Change-Id: I0c63e2fd8b6ad49b752ed1757370e386171481cb
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/47440
Commit-Queue: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
James Price 2021-04-09 13:50:38 +00:00 committed by Commit Bot service account
parent 71512e30ca
commit f8f31a458f
6 changed files with 17 additions and 23 deletions

View File

@ -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"

View File

@ -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<tint::transform::CanonicalizeEntryPointIO>());
transform_manager.append(std::make_unique<tint::transform::Msl>());
break;
#endif // TINT_BUILD_MSL_WRITER
#if TINT_BUILD_HLSL_WRITER
case Format::kHlsl:
transform_manager.append(
std::make_unique<tint::transform::CanonicalizeEntryPointIO>());
transform_manager.append(std::make_unique<tint::transform::Hlsl>());
break;
#endif // TINT_BUILD_HLSL_WRITER

View File

@ -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<CanonicalizeEntryPointIO>();
manager.Add<DecomposeStorageAccess>();
manager.Add<CalculateArrayLength>();
auto out = manager.Run(in, data);

View File

@ -17,6 +17,8 @@
#include <utility>
#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<CanonicalizeEntryPointIO>();
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

View File

@ -20,9 +20,7 @@
#include <utility>
#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<tint::transform::CanonicalizeEntryPointIO>());
transform_manager.append(std::make_unique<tint::transform::Hlsl>());
auto result = transform_manager.Run(program.get());
auto result = transform::Hlsl().Run(program.get());
[&]() {
ASSERT_TRUE(result.program.IsValid())
<< formatter.format(result.program.Diagnostics());

View File

@ -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<tint::transform::CanonicalizeEntryPointIO>());
transform_manager.append(std::make_unique<tint::transform::Msl>());
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());