From 5d5ec24571e2d32c4af7f6ccb118ca48ccd00991 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Mon, 26 Apr 2021 20:38:36 +0000 Subject: [PATCH] src/transform: Remove deprecated APIs These have now been removed from Dawn. Change-Id: I50e784141e6eb07f4f0d3f508bb8c6199429dd63 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48044 Auto-Submit: Ben Clayton Commit-Queue: Ben Clayton Reviewed-by: Ryan Harrison --- fuzzers/tint_all_transforms_fuzzer.cc | 13 +++++------ fuzzers/tint_bound_array_accessors_fuzzer.cc | 5 ++--- fuzzers/tint_common_fuzzer.cc | 2 +- fuzzers/tint_common_fuzzer.h | 8 ++++++- fuzzers/tint_emit_vertex_point_size_fuzzer.cc | 5 ++--- fuzzers/tint_first_index_offset_fuzzer.cc | 7 +++--- samples/main.cc | 22 +++++++++---------- src/transform/first_index_offset.cc | 3 --- src/transform/first_index_offset.h | 6 +---- src/transform/first_index_offset_test.cc | 16 ++++++++++---- src/transform/transform.h | 3 --- src/transform/vertex_pulling.cc | 2 -- src/transform/vertex_pulling.h | 5 ----- 13 files changed, 46 insertions(+), 51 deletions(-) diff --git a/fuzzers/tint_all_transforms_fuzzer.cc b/fuzzers/tint_all_transforms_fuzzer.cc index 0fb4f336d6..e9af5abc59 100644 --- a/fuzzers/tint_all_transforms_fuzzer.cc +++ b/fuzzers/tint_all_transforms_fuzzer.cc @@ -19,15 +19,14 @@ namespace fuzzers { extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { tint::transform::Manager transform_manager; - transform_manager.append( - std::make_unique()); - transform_manager.append( - std::make_unique()); - transform_manager.append( - std::make_unique(0, 0)); + tint::transform::DataMap transform_inputs; + transform_inputs.Add(0, 0); + transform_manager.Add(); + transform_manager.Add(); + transform_manager.Add(); tint::fuzzers::CommonFuzzer fuzzer(InputFormat::kWGSL, OutputFormat::kSpv); - fuzzer.SetTransformManager(&transform_manager); + fuzzer.SetTransformManager(&transform_manager, std::move(transform_inputs)); return fuzzer.Run(data, size); } diff --git a/fuzzers/tint_bound_array_accessors_fuzzer.cc b/fuzzers/tint_bound_array_accessors_fuzzer.cc index 7bb09d1671..2040320928 100644 --- a/fuzzers/tint_bound_array_accessors_fuzzer.cc +++ b/fuzzers/tint_bound_array_accessors_fuzzer.cc @@ -19,11 +19,10 @@ namespace fuzzers { extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { tint::transform::Manager transform_manager; - transform_manager.append( - std::make_unique()); + transform_manager.Add(); tint::fuzzers::CommonFuzzer fuzzer(InputFormat::kWGSL, OutputFormat::kSpv); - fuzzer.SetTransformManager(&transform_manager); + fuzzer.SetTransformManager(&transform_manager, {}); return fuzzer.Run(data, size); } diff --git a/fuzzers/tint_common_fuzzer.cc b/fuzzers/tint_common_fuzzer.cc index 1d96ec04c3..bf2f02ccf3 100644 --- a/fuzzers/tint_common_fuzzer.cc +++ b/fuzzers/tint_common_fuzzer.cc @@ -147,7 +147,7 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) { } if (transform_manager_) { - auto out = transform_manager_->Run(&program); + auto out = transform_manager_->Run(&program, transform_inputs_); if (!out.program.IsValid()) { return 0; } diff --git a/fuzzers/tint_common_fuzzer.h b/fuzzers/tint_common_fuzzer.h index 5f2bcffc85..69a0ab60b2 100644 --- a/fuzzers/tint_common_fuzzer.h +++ b/fuzzers/tint_common_fuzzer.h @@ -15,6 +15,8 @@ #ifndef FUZZERS_TINT_COMMON_FUZZER_H_ #define FUZZERS_TINT_COMMON_FUZZER_H_ +#include + #include "include/tint/tint.h" namespace tint { @@ -29,7 +31,10 @@ class CommonFuzzer { explicit CommonFuzzer(InputFormat input, OutputFormat output); ~CommonFuzzer(); - void SetTransformManager(transform::Manager* tm) { transform_manager_ = tm; } + void SetTransformManager(transform::Manager* tm, transform::DataMap inputs) { + transform_manager_ = tm; + transform_inputs_ = std::move(inputs); + } void EnableInspector() { inspector_enabled_ = true; } int Run(const uint8_t* data, size_t size); @@ -38,6 +43,7 @@ class CommonFuzzer { InputFormat input_; OutputFormat output_; transform::Manager* transform_manager_; + transform::DataMap transform_inputs_; bool inspector_enabled_; }; diff --git a/fuzzers/tint_emit_vertex_point_size_fuzzer.cc b/fuzzers/tint_emit_vertex_point_size_fuzzer.cc index a2104c22eb..3b394377bd 100644 --- a/fuzzers/tint_emit_vertex_point_size_fuzzer.cc +++ b/fuzzers/tint_emit_vertex_point_size_fuzzer.cc @@ -19,11 +19,10 @@ namespace fuzzers { extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { tint::transform::Manager transform_manager; - transform_manager.append( - std::make_unique()); + transform_manager.Add(); tint::fuzzers::CommonFuzzer fuzzer(InputFormat::kWGSL, OutputFormat::kSpv); - fuzzer.SetTransformManager(&transform_manager); + fuzzer.SetTransformManager(&transform_manager, {}); return fuzzer.Run(data, size); } diff --git a/fuzzers/tint_first_index_offset_fuzzer.cc b/fuzzers/tint_first_index_offset_fuzzer.cc index eb7b74d11a..69159810bb 100644 --- a/fuzzers/tint_first_index_offset_fuzzer.cc +++ b/fuzzers/tint_first_index_offset_fuzzer.cc @@ -19,11 +19,12 @@ namespace fuzzers { extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { tint::transform::Manager transform_manager; - transform_manager.append( - std::make_unique(0, 0)); + tint::transform::DataMap transform_inputs; + transform_inputs.Add(0, 0); + transform_manager.Add(); tint::fuzzers::CommonFuzzer fuzzer(InputFormat::kWGSL, OutputFormat::kSpv); - fuzzer.SetTransformManager(&transform_manager); + fuzzer.SetTransformManager(&transform_manager, std::move(transform_inputs)); return fuzzer.Run(data, size); } diff --git a/samples/main.cc b/samples/main.cc index 056508e589..1f5e35471b 100644 --- a/samples/main.cc +++ b/samples/main.cc @@ -675,22 +675,22 @@ int main(int argc, const char** argv) { } tint::transform::Manager transform_manager; + tint::transform::DataMap transform_inputs; for (const auto& name : options.transforms) { // TODO(dsinclair): The vertex pulling transform requires setup code to // be run that needs user input. Should we find a way to support that here // maybe through a provided file? if (name == "bound_array_accessors") { - transform_manager.append( - std::make_unique()); + transform_manager.Add(); } else if (name == "emit_vertex_point_size") { - transform_manager.append( - std::make_unique()); + transform_manager.Add(); } else if (name == "first_index_offset") { - transform_manager.append( - std::make_unique(0, 0)); + transform_inputs.Add(0, + 0); + transform_manager.Add(); } else if (name == "renamer") { - transform_manager.append(std::make_unique()); + transform_manager.Add(); } else { std::cerr << "Unknown transform name: " << name << std::endl; return 1; @@ -701,7 +701,7 @@ int main(int argc, const char** argv) { #if TINT_BUILD_SPV_WRITER case Format::kSpirv: case Format::kSpvAsm: - transform_manager.append(std::make_unique()); + transform_manager.Add(); break; #endif // TINT_BUILD_SPV_WRITER #if TINT_BUILD_MSL_WRITER @@ -710,7 +710,7 @@ int main(int argc, const char** argv) { tint::transform::Renamer::Target::kMslKeywords}; transform_manager.append( std::make_unique(renamer_config)); - transform_manager.append(std::make_unique()); + transform_manager.Add(); break; } #endif // TINT_BUILD_MSL_WRITER @@ -720,7 +720,7 @@ int main(int argc, const char** argv) { tint::transform::Renamer::Target::kHlslKeywords}; transform_manager.append( std::make_unique(renamer_config)); - transform_manager.append(std::make_unique()); + transform_manager.Add(); break; } #endif // TINT_BUILD_HLSL_WRITER @@ -728,7 +728,7 @@ int main(int argc, const char** argv) { break; } - auto out = transform_manager.Run(program.get()); + auto out = transform_manager.Run(program.get(), std::move(transform_inputs)); if (!out.program.IsValid()) { diag_formatter.format(out.program.Diagnostics(), diag_printer.get()); return 1; diff --git a/src/transform/first_index_offset.cc b/src/transform/first_index_offset.cc index 920fb3bc1e..20e869db62 100644 --- a/src/transform/first_index_offset.cc +++ b/src/transform/first_index_offset.cc @@ -55,9 +55,6 @@ FirstIndexOffset::Data::Data(const Data&) = default; FirstIndexOffset::Data::~Data() = default; FirstIndexOffset::FirstIndexOffset() = default; -FirstIndexOffset::FirstIndexOffset(uint32_t binding, uint32_t group) - : binding_(binding), group_(group) {} - FirstIndexOffset::~FirstIndexOffset() = default; Output FirstIndexOffset::Run(const Program* in, const DataMap& data) { diff --git a/src/transform/first_index_offset.h b/src/transform/first_index_offset.h index 7f819bc96b..f84e9e3939 100644 --- a/src/transform/first_index_offset.h +++ b/src/transform/first_index_offset.h @@ -109,11 +109,7 @@ class FirstIndexOffset : public Transform { /// Constructor FirstIndexOffset(); - /// Constructor - /// [DEPRECATED] - pass BindingPoint as part of the `data` to Run() - /// @param binding the binding() for firstVertex/Instance uniform - /// @param group the group() for firstVertex/Instance uniform - FirstIndexOffset(uint32_t binding, uint32_t group); + /// Destructor ~FirstIndexOffset() override; /// Runs the transform on `program`, returning the transformation result. diff --git a/src/transform/first_index_offset_test.cc b/src/transform/first_index_offset_test.cc index 09221d3674..b7ebab178c 100644 --- a/src/transform/first_index_offset_test.cc +++ b/src/transform/first_index_offset_test.cc @@ -366,7 +366,9 @@ fn entry() { } )"; - auto got = Run(src, std::make_unique(1, 2)); + DataMap config; + config.Add(1, 2); + auto got = Run(src, std::move(config)); EXPECT_EQ(expect, str(got)); @@ -419,7 +421,9 @@ fn entry() { } )"; - auto got = Run(src, std::make_unique(1, 7)); + DataMap config; + config.Add(1, 7); + auto got = Run(src, std::move(config)); EXPECT_EQ(expect, str(got)); @@ -475,7 +479,9 @@ fn entry() { } )"; - auto got = Run(src, std::make_unique(1, 2)); + DataMap config; + config.Add(1, 2); + auto got = Run(src, std::move(config)); EXPECT_EQ(expect, str(got)); @@ -535,7 +541,9 @@ fn entry() { } )"; - auto got = Run(src, std::make_unique(1, 2)); + DataMap config; + config.Add(1, 2); + auto got = Run(src, std::move(config)); EXPECT_EQ(expect, str(got)); diff --git a/src/transform/transform.h b/src/transform/transform.h index 533f0f8015..95ba235cb3 100644 --- a/src/transform/transform.h +++ b/src/transform/transform.h @@ -147,9 +147,6 @@ class Output { /// Interface for Program transforms class Transform { public: - /// [DEPRECATED]: Use transform::Output - using Output = transform::Output; - /// Constructor Transform(); /// Destructor diff --git a/src/transform/vertex_pulling.cc b/src/transform/vertex_pulling.cc index 6e3af30fbb..cdcbd4d8e3 100644 --- a/src/transform/vertex_pulling.cc +++ b/src/transform/vertex_pulling.cc @@ -567,8 +567,6 @@ struct State { } // namespace VertexPulling::VertexPulling() = default; -VertexPulling::VertexPulling(const Config& config) : cfg_(config) {} - VertexPulling::~VertexPulling() = default; Output VertexPulling::Run(const Program* in, const DataMap& data) { diff --git a/src/transform/vertex_pulling.h b/src/transform/vertex_pulling.h index 576bc09c09..7dded37dee 100644 --- a/src/transform/vertex_pulling.h +++ b/src/transform/vertex_pulling.h @@ -160,11 +160,6 @@ class VertexPulling : public Transform { /// Constructor VertexPulling(); - /// Constructor - /// [DEPRECATED] - pass Config as part of the `data` to Run() - /// @param config the configuration options for the transform - explicit VertexPulling(const Config& config); - /// Destructor ~VertexPulling() override;