From 0e6534e44d2c3c77ac409d787d9d5b3d449a2d0a Mon Sep 17 00:00:00 2001 From: James Price Date: Wed, 17 May 2023 01:21:45 +0000 Subject: [PATCH] [tint] Make Transform base class This will allow for both AST transforms and IR transforms to be used in the same transform manager. The transform manager is no longer a Tranform subclass. Bug: tint:1718 Change-Id: I59bd87806090fa365ce4b575710c5ffcfc657bd8 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132501 Commit-Queue: James Price Reviewed-by: Ben Clayton Kokoro: Kokoro --- src/dawn/native/ShaderModule.cpp | 18 +- src/dawn/native/ShaderModule.h | 8 +- src/dawn/native/d3d/ShaderUtils.cpp | 4 +- src/dawn/native/metal/ShaderModuleMTL.mm | 4 +- src/dawn/native/null/DeviceNull.cpp | 2 +- src/dawn/native/opengl/ShaderModuleGL.cpp | 2 +- src/dawn/native/vulkan/ShaderModuleVk.cpp | 4 +- src/tint/BUILD.gn | 84 +++-- src/tint/CMakeLists.txt | 2 + .../array_length_from_uniform_test.cc | 20 +- .../ast/transform/binding_remapper_test.cc | 18 +- .../ast/transform/builtin_polyfill_test.cc | 92 +++--- .../canonicalize_entry_point_io_test.cc | 134 ++++---- .../ast/transform/combine_samplers_test.cc | 52 ++-- .../transform/direct_variable_access_test.cc | 12 +- src/tint/ast/transform/first_index_offset.h | 4 +- .../ast/transform/first_index_offset_test.cc | 24 +- .../multiplanar_external_texture_test.cc | 48 +-- .../num_workgroups_from_uniform_test.cc | 24 +- src/tint/ast/transform/packed_vec3_test.cc | 290 +++++++++--------- src/tint/ast/transform/pad_structs_test.cc | 30 +- .../transform/promote_side_effects_to_decl.cc | 2 +- .../promote_side_effects_to_decl_test.cc | 218 ++++++------- .../remove_continue_in_switch_test.cc | 16 +- src/tint/ast/transform/renamer.h | 4 +- src/tint/ast/transform/renamer_test.cc | 10 +- src/tint/ast/transform/robustness_test.cc | 4 +- .../ast/transform/single_entry_point_test.cc | 38 +-- .../ast/transform/substitute_override_test.cc | 14 +- src/tint/ast/transform/test_helper.h | 27 +- .../ast/transform/texture_1d_to_2d_test.cc | 28 +- src/tint/ast/transform/transform.cc | 11 - src/tint/ast/transform/transform.h | 109 +------ .../truncate_interstage_variables_test.cc | 24 +- .../transform/var_for_dynamic_index_test.cc | 36 +-- src/tint/ast/transform/vertex_pulling_test.cc | 68 ++-- src/tint/cmd/main.cc | 25 +- src/tint/fuzzers/shuffle_transform.cc | 4 +- src/tint/fuzzers/shuffle_transform.h | 4 +- src/tint/fuzzers/tint_common_fuzzer.cc | 14 +- src/tint/fuzzers/tint_common_fuzzer.h | 4 +- src/tint/fuzzers/tint_reader_writer_fuzzer.h | 2 +- src/tint/fuzzers/transform_builder.h | 4 +- src/tint/reader/spirv/parser.cc | 3 +- src/tint/transform/manager.cc | 46 ++- src/tint/transform/manager.h | 16 +- src/tint/transform/transform.cc | 37 +++ src/tint/transform/transform.h | 141 +++++++++ src/tint/writer/flatten_bindings.cc | 7 +- src/tint/writer/glsl/generator_impl.cc | 7 +- src/tint/writer/hlsl/generator_impl.cc | 9 +- src/tint/writer/hlsl/test_helper.h | 11 +- src/tint/writer/msl/generator_impl.cc | 9 +- src/tint/writer/spirv/generator_impl.cc | 5 +- 54 files changed, 980 insertions(+), 853 deletions(-) create mode 100644 src/tint/transform/transform.cc create mode 100644 src/tint/transform/transform.h diff --git a/src/dawn/native/ShaderModule.cpp b/src/dawn/native/ShaderModule.cpp index c26a70959c..b10de33f23 100644 --- a/src/dawn/native/ShaderModule.cpp +++ b/src/dawn/native/ShaderModule.cpp @@ -1012,21 +1012,21 @@ RequiredBufferSizes ComputeRequiredBufferSizesForLayout(const EntryPointMetadata return bufferSizes; } -ResultOrError RunTransforms(tint::ast::transform::Transform* transform, +ResultOrError RunTransforms(tint::transform::Manager* transformManager, const tint::Program* program, - const tint::ast::transform::DataMap& inputs, - tint::ast::transform::DataMap* outputs, + const tint::transform::DataMap& inputs, + tint::transform::DataMap* outputs, OwnedCompilationMessages* outMessages) { - tint::ast::transform::Output output = transform->Run(program, inputs); + tint::transform::DataMap transform_outputs; + tint::Program result = transformManager->Run(program, inputs, transform_outputs); if (outMessages != nullptr) { - DAWN_TRY(outMessages->AddMessages(output.program.Diagnostics())); + DAWN_TRY(outMessages->AddMessages(result.Diagnostics())); } - DAWN_INVALID_IF(!output.program.IsValid(), "Tint program failure: %s\n", - output.program.Diagnostics().str()); + DAWN_INVALID_IF(!result.IsValid(), "Tint program failure: %s\n", result.Diagnostics().str()); if (outputs != nullptr) { - *outputs = std::move(output.data); + *outputs = std::move(transform_outputs); } - return std::move(output.program); + return std::move(result); } MaybeError ValidateCompatibilityWithPipelineLayout(DeviceBase* device, diff --git a/src/dawn/native/ShaderModule.h b/src/dawn/native/ShaderModule.h index 8b2e7e1ccf..da58ad9929 100644 --- a/src/dawn/native/ShaderModule.h +++ b/src/dawn/native/ShaderModule.h @@ -45,12 +45,12 @@ namespace tint { class Program; namespace ast::transform { -class DataMap; class Transform; class VertexPulling; } // namespace ast::transform namespace transform { +class DataMap; class Manager; } // namespace transform @@ -121,10 +121,10 @@ ResultOrError ValidateComputeStageWorkgroupSize( RequiredBufferSizes ComputeRequiredBufferSizesForLayout(const EntryPointMetadata& entryPoint, const PipelineLayoutBase* layout); -ResultOrError RunTransforms(tint::ast::transform::Transform* transform, +ResultOrError RunTransforms(tint::transform::Manager* transformManager, const tint::Program* program, - const tint::ast::transform::DataMap& inputs, - tint::ast::transform::DataMap* outputs, + const tint::transform::DataMap& inputs, + tint::transform::DataMap* outputs, OwnedCompilationMessages* messages); // Mirrors wgpu::SamplerBindingLayout but instead stores a single boolean diff --git a/src/dawn/native/d3d/ShaderUtils.cpp b/src/dawn/native/d3d/ShaderUtils.cpp index d16db64587..5ca49d5d2d 100644 --- a/src/dawn/native/d3d/ShaderUtils.cpp +++ b/src/dawn/native/d3d/ShaderUtils.cpp @@ -144,7 +144,7 @@ ResultOrError TranslateToHLSL( errorStream << "Tint HLSL failure:" << std::endl; tint::transform::Manager transformManager; - tint::ast::transform::DataMap transformInputs; + tint::transform::DataMap transformInputs; // Run before the renamer so that the entry point name matches `entryPointName` still. transformManager.Add(); @@ -173,7 +173,7 @@ ResultOrError TranslateToHLSL( } tint::Program transformedProgram; - tint::ast::transform::DataMap transformOutputs; + tint::transform::DataMap transformOutputs; { TRACE_EVENT0(tracePlatform.UnsafeGetValue(), General, "RunTransforms"); DAWN_TRY_ASSIGN(transformedProgram, diff --git a/src/dawn/native/metal/ShaderModuleMTL.mm b/src/dawn/native/metal/ShaderModuleMTL.mm index a253fc7e6c..e409560778 100644 --- a/src/dawn/native/metal/ShaderModuleMTL.mm +++ b/src/dawn/native/metal/ShaderModuleMTL.mm @@ -207,7 +207,7 @@ ResultOrError> TranslateToMSL( mslCompilation, device, std::move(req), MslCompilation::FromBlob, [](MslCompilationRequest r) -> ResultOrError { tint::transform::Manager transformManager; - tint::ast::transform::DataMap transformInputs; + tint::transform::DataMap transformInputs; // We only remap bindings for the target entry point, so we need to strip all other // entry points to avoid generating invalid bindings for them. @@ -238,7 +238,7 @@ ResultOrError> TranslateToMSL( } tint::Program program; - tint::ast::transform::DataMap transformOutputs; + tint::transform::DataMap transformOutputs; { TRACE_EVENT0(r.tracePlatform.UnsafeGetValue(), General, "RunTransforms"); DAWN_TRY_ASSIGN(program, diff --git a/src/dawn/native/null/DeviceNull.cpp b/src/dawn/native/null/DeviceNull.cpp index dfd799fb8f..ab96b5d023 100644 --- a/src/dawn/native/null/DeviceNull.cpp +++ b/src/dawn/native/null/DeviceNull.cpp @@ -391,7 +391,7 @@ MaybeError ComputePipeline::Initialize() { tint::Program transformedProgram; const tint::Program* program; tint::transform::Manager transformManager; - tint::ast::transform::DataMap transformInputs; + tint::transform::DataMap transformInputs; if (!computeStage.metadata->overrides.empty()) { transformManager.Add(); diff --git a/src/dawn/native/opengl/ShaderModuleGL.cpp b/src/dawn/native/opengl/ShaderModuleGL.cpp index 252d91df51..964a5517ed 100644 --- a/src/dawn/native/opengl/ShaderModuleGL.cpp +++ b/src/dawn/native/opengl/ShaderModuleGL.cpp @@ -195,7 +195,7 @@ ResultOrError ShaderModule::CompileShader(const OpenGLFunctions& gl, compilationResult, GetDevice(), std::move(req), GLSLCompilation::FromBlob, [](GLSLCompilationRequest r) -> ResultOrError { tint::transform::Manager transformManager; - tint::ast::transform::DataMap transformInputs; + tint::transform::DataMap transformInputs; if (r.substituteOverrideConfig) { transformManager.Add(); diff --git a/src/dawn/native/vulkan/ShaderModuleVk.cpp b/src/dawn/native/vulkan/ShaderModuleVk.cpp index 23931e5fdb..f06f6d2ec6 100644 --- a/src/dawn/native/vulkan/ShaderModuleVk.cpp +++ b/src/dawn/native/vulkan/ShaderModuleVk.cpp @@ -273,7 +273,7 @@ ResultOrError ShaderModule::GetHandleAndSpirv( compilation, GetDevice(), std::move(req), CompiledSpirv::FromBlob, [](SpirvCompilationRequest r) -> ResultOrError { tint::transform::Manager transformManager; - tint::ast::transform::DataMap transformInputs; + tint::transform::DataMap transformInputs; // Many Vulkan drivers can't handle multi-entrypoint shader modules. // Run before the renamer so that the entry point name matches `entryPointName` still. @@ -295,7 +295,7 @@ ResultOrError ShaderModule::GetHandleAndSpirv( } tint::Program program; - tint::ast::transform::DataMap transformOutputs; + tint::transform::DataMap transformOutputs; { TRACE_EVENT0(r.tracePlatform.UnsafeGetValue(), General, "RunTransforms"); DAWN_TRY_ASSIGN(program, diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn index c6ebd502b3..7e85a38112 100644 --- a/src/tint/BUILD.gn +++ b/src/tint/BUILD.gn @@ -355,6 +355,43 @@ libtint_source_set("libtint_inspector_src") { } libtint_source_set("libtint_transform_src") { + sources = [ + "transform/transform.cc", + "transform/transform.h", + ] + deps = [ + ":libtint_program_src", + ":libtint_utils_src", + ] +} + +libtint_source_set("libtint_ast_transform_base_src") { + sources = [ + "ast/transform/transform.cc", + "ast/transform/transform.h", + ] + public_deps = [ ":libtint_transform_src" ] + deps = [ + ":libtint_builtins_src", + ":libtint_program_src", + ":libtint_sem_src", + ":libtint_type_src", + ":libtint_utils_src", + ] +} + +libtint_source_set("libtint_transform_manager_src") { + sources = [ + "transform/manager.cc", + "transform/manager.h", + ] + deps = [ + ":libtint_ast_transform_base_src", + ":libtint_program_src", + ] +} + +libtint_source_set("libtint_ast_transform_src") { sources = [ "ast/transform/add_block_attribute.cc", "ast/transform/add_block_attribute.h", @@ -434,8 +471,6 @@ libtint_source_set("libtint_transform_src") { "ast/transform/substitute_override.h", "ast/transform/texture_1d_to_2d.cc", "ast/transform/texture_1d_to_2d.h", - "ast/transform/transform.cc", - "ast/transform/transform.h", "ast/transform/truncate_interstage_variables.cc", "ast/transform/truncate_interstage_variables.h", "ast/transform/unshadow.cc", @@ -456,15 +491,15 @@ libtint_source_set("libtint_transform_src") { "ast/transform/while_to_loop.h", "ast/transform/zero_init_workgroup_memory.cc", "ast/transform/zero_init_workgroup_memory.h", - "transform/manager.cc", - "transform/manager.h", ] + public_deps = [ ":libtint_ast_transform_base_src" ] deps = [ ":libtint_ast_src", ":libtint_builtins_src", ":libtint_program_src", ":libtint_sem_src", ":libtint_symbols_src", + ":libtint_transform_manager_src", ":libtint_type_src", ":libtint_utils_src", ] @@ -860,10 +895,7 @@ libtint_source_set("libtint_reader_src") { "reader/reader.h", ] - public_deps = [ - ":libtint_program_src", - ":libtint_transform_src", - ] + public_deps = [ ":libtint_program_src" ] } libtint_source_set("libtint_spv_reader_src") { @@ -892,11 +924,13 @@ libtint_source_set("libtint_spv_reader_src") { deps = [ ":libtint_ast_src", + ":libtint_ast_transform_src", ":libtint_builtins_src", ":libtint_program_src", ":libtint_reader_src", ":libtint_sem_src", ":libtint_symbols_src", + ":libtint_transform_manager_src", ":libtint_type_src", ":libtint_utils_src", "${tint_spirv_tools_dir}/:spvtools_opt", @@ -932,11 +966,12 @@ libtint_source_set("libtint_writer_src") { deps = [ ":libtint_ast_src", + ":libtint_ast_transform_src", ":libtint_builtins_src", ":libtint_inspector_src", ":libtint_program_src", ":libtint_sem_src", - ":libtint_transform_src", + ":libtint_transform_manager_src", ":libtint_type_src", ":libtint_utils_src", ] @@ -965,12 +1000,13 @@ libtint_source_set("libtint_spv_writer_src") { deps = [ ":libtint_ast_src", + ":libtint_ast_transform_src", ":libtint_builtins_src", ":libtint_constant_src", ":libtint_program_src", ":libtint_sem_src", ":libtint_symbols_src", - ":libtint_transform_src", + ":libtint_transform_manager_src", ":libtint_type_src", ":libtint_utils_src", ":libtint_writer_src", @@ -1044,12 +1080,13 @@ libtint_source_set("libtint_msl_writer_src") { deps = [ ":libtint_ast_src", + ":libtint_ast_transform_src", ":libtint_builtins_src", ":libtint_constant_src", ":libtint_program_src", ":libtint_sem_src", ":libtint_symbols_src", - ":libtint_transform_src", + ":libtint_transform_manager_src", ":libtint_type_src", ":libtint_utils_src", ":libtint_writer_src", @@ -1066,12 +1103,13 @@ libtint_source_set("libtint_hlsl_writer_src") { deps = [ ":libtint_ast_src", + ":libtint_ast_transform_src", ":libtint_builtins_src", ":libtint_constant_src", ":libtint_program_src", ":libtint_sem_src", ":libtint_symbols_src", - ":libtint_transform_src", + ":libtint_transform_manager_src", ":libtint_type_src", ":libtint_utils_src", ":libtint_writer_src", @@ -1088,12 +1126,13 @@ libtint_source_set("libtint_glsl_writer_src") { deps = [ ":libtint_ast_src", + ":libtint_ast_transform_src", ":libtint_builtins_src", ":libtint_constant_src", ":libtint_program_src", ":libtint_sem_src", ":libtint_symbols_src", - ":libtint_transform_src", + ":libtint_transform_manager_src", ":libtint_type_src", ":libtint_utils_src", ":libtint_writer_src", @@ -1206,13 +1245,13 @@ libtint_source_set("libtint_ir_src") { source_set("libtint") { public_deps = [ ":libtint_ast_src", + ":libtint_ast_transform_src", ":libtint_constant_src", ":libtint_initializer_src", ":libtint_inspector_src", ":libtint_program_src", ":libtint_sem_src", ":libtint_symbols_src", - ":libtint_transform_src", ":libtint_type_src", ":libtint_utils_src", ":libtint_writer_src", @@ -1470,8 +1509,8 @@ if (tint_build_unittests) { ] deps = [ ":libtint_ast_src", + ":libtint_ast_transform_src", ":libtint_builtins_src", - ":libtint_transform_src", ":libtint_unittests_ast_helper", ":libtint_utils_src", ] @@ -1587,8 +1626,8 @@ if (tint_build_unittests) { "resolver/variable_validation_test.cc", ] deps = [ + ":libtint_ast_transform_src", ":libtint_builtins_src", - ":libtint_transform_src", ":libtint_utils_src", ":tint_unittests_ast_src", ] @@ -1638,7 +1677,7 @@ if (tint_build_unittests) { deps = [ ":libtint_builtins_src" ] } - tint_unittests_source_set("tint_unittests_transform_src") { + tint_unittests_source_set("tint_unittests_ast_transform_src") { sources = [ "ast/transform/add_block_attribute_test.cc", "ast/transform/add_empty_entry_point_test.cc", @@ -1697,8 +1736,9 @@ if (tint_build_unittests) { ] deps = [ + ":libtint_ast_transform_src", ":libtint_builtins_src", - ":libtint_transform_src", + ":libtint_transform_manager_src", ":libtint_unittests_ast_helper", ":libtint_utils_src", ":libtint_wgsl_reader_src", @@ -2071,8 +2111,9 @@ if (tint_build_unittests) { ] deps = [ + ":libtint_ast_transform_src", ":libtint_hlsl_writer_src", - ":libtint_transform_src", + ":libtint_transform_manager_src", ":libtint_utils_src", ":tint_unittests_ast_src", ] @@ -2115,9 +2156,10 @@ if (tint_build_unittests) { ] deps = [ + ":libtint_ast_transform_src", ":libtint_glsl_writer_src", ":libtint_symbols_src", - ":libtint_transform_src", + ":libtint_transform_manager_src", ":libtint_utils_src", ":tint_unittests_ast_src", ] @@ -2192,6 +2234,7 @@ if (tint_build_unittests) { ":libtint_wgsl_reader_src", ":libtint_wgsl_writer_src", ":tint_unittests_ast_src", + ":tint_unittests_ast_transform_src", ":tint_unittests_builtins_src", ":tint_unittests_cmd_src", ":tint_unittests_constant_src", @@ -2201,7 +2244,6 @@ if (tint_build_unittests) { ":tint_unittests_resolver_src", ":tint_unittests_sem_src", ":tint_unittests_symbols_src", - ":tint_unittests_transform_src", ":tint_unittests_type_src", ":tint_unittests_utils_src", ":tint_unittests_writer_src", diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt index d978500c9a..7d12ae256c 100644 --- a/src/tint/CMakeLists.txt +++ b/src/tint/CMakeLists.txt @@ -452,6 +452,8 @@ list(APPEND TINT_LIB_SRCS ast/transform/zero_init_workgroup_memory.h transform/manager.cc transform/manager.h + transform/transform.cc + transform/transform.h type/abstract_float.cc type/abstract_float.h type/abstract_int.cc diff --git a/src/tint/ast/transform/array_length_from_uniform_test.cc b/src/tint/ast/transform/array_length_from_uniform_test.cc index b73463064f..844165504c 100644 --- a/src/tint/ast/transform/array_length_from_uniform_test.cc +++ b/src/tint/ast/transform/array_length_from_uniform_test.cc @@ -31,7 +31,7 @@ TEST_F(ArrayLengthFromUniformTest, ShouldRunEmptyModule) { ArrayLengthFromUniform::Config cfg({0, 30u}); cfg.bindpoint_to_size_index.emplace(sem::BindingPoint{0, 0}, 0); - DataMap data; + Transform::DataMap data; data.Add(std::move(cfg)); EXPECT_FALSE(ShouldRun(src, data)); @@ -54,7 +54,7 @@ fn main() { ArrayLengthFromUniform::Config cfg({0, 30u}); cfg.bindpoint_to_size_index.emplace(sem::BindingPoint{0, 0}, 0); - DataMap data; + Transform::DataMap data; data.Add(std::move(cfg)); EXPECT_FALSE(ShouldRun(src, data)); @@ -78,7 +78,7 @@ fn main() { ArrayLengthFromUniform::Config cfg({0, 30u}); cfg.bindpoint_to_size_index.emplace(sem::BindingPoint{0, 0}, 0); - DataMap data; + Transform::DataMap data; data.Add(std::move(cfg)); EXPECT_TRUE(ShouldRun(src, data)); @@ -134,7 +134,7 @@ fn main() { ArrayLengthFromUniform::Config cfg({0, 30u}); cfg.bindpoint_to_size_index.emplace(sem::BindingPoint{0, 0}, 0); - DataMap data; + Transform::DataMap data; data.Add(std::move(cfg)); auto got = Run(src, data); @@ -183,7 +183,7 @@ fn main() { ArrayLengthFromUniform::Config cfg({0, 30u}); cfg.bindpoint_to_size_index.emplace(sem::BindingPoint{0, 0}, 0); - DataMap data; + Transform::DataMap data; data.Add(std::move(cfg)); auto got = Run(src, data); @@ -275,7 +275,7 @@ fn main() { cfg.bindpoint_to_size_index.emplace(sem::BindingPoint{3u, 2u}, 3); cfg.bindpoint_to_size_index.emplace(sem::BindingPoint{4u, 2u}, 4); - DataMap data; + Transform::DataMap data; data.Add(std::move(cfg)); auto got = Run(src, data); @@ -361,7 +361,7 @@ fn main() { cfg.bindpoint_to_size_index.emplace(sem::BindingPoint{3u, 2u}, 3); cfg.bindpoint_to_size_index.emplace(sem::BindingPoint{4u, 2u}, 4); - DataMap data; + Transform::DataMap data; data.Add(std::move(cfg)); auto got = Run(src, data); @@ -389,7 +389,7 @@ fn main() { ArrayLengthFromUniform::Config cfg({0, 30u}); cfg.bindpoint_to_size_index.emplace(sem::BindingPoint{0, 0}, 0); - DataMap data; + Transform::DataMap data; data.Add(std::move(cfg)); auto got = Run(src, data); @@ -454,7 +454,7 @@ fn main() { ArrayLengthFromUniform::Config cfg({0, 30u}); cfg.bindpoint_to_size_index.emplace(sem::BindingPoint{0, 2}, 0); - DataMap data; + Transform::DataMap data; data.Add(std::move(cfg)); auto got = Run(src, data); @@ -502,7 +502,7 @@ struct SB { ArrayLengthFromUniform::Config cfg({0, 30u}); cfg.bindpoint_to_size_index.emplace(sem::BindingPoint{0, 0}, 0); - DataMap data; + Transform::DataMap data; data.Add(std::move(cfg)); auto got = Run(src, data); diff --git a/src/tint/ast/transform/binding_remapper_test.cc b/src/tint/ast/transform/binding_remapper_test.cc index 296bd7cbd1..023b919ec4 100644 --- a/src/tint/ast/transform/binding_remapper_test.cc +++ b/src/tint/ast/transform/binding_remapper_test.cc @@ -26,7 +26,7 @@ using BindingRemapperTest = TransformTest; TEST_F(BindingRemapperTest, ShouldRunEmptyRemappings) { auto* src = R"()"; - DataMap data; + Transform::DataMap data; data.Add(BindingRemapper::BindingPoints{}, BindingRemapper::AccessControls{}); @@ -36,7 +36,7 @@ TEST_F(BindingRemapperTest, ShouldRunEmptyRemappings) { TEST_F(BindingRemapperTest, ShouldRunBindingPointRemappings) { auto* src = R"()"; - DataMap data; + Transform::DataMap data; data.Add( BindingRemapper::BindingPoints{ {{2, 1}, {1, 2}}, @@ -49,7 +49,7 @@ TEST_F(BindingRemapperTest, ShouldRunBindingPointRemappings) { TEST_F(BindingRemapperTest, ShouldRunAccessControlRemappings) { auto* src = R"()"; - DataMap data; + Transform::DataMap data; data.Add(BindingRemapper::BindingPoints{}, BindingRemapper::AccessControls{ {{2, 1}, builtin::Access::kWrite}, @@ -75,7 +75,7 @@ fn f() { auto* expect = src; - DataMap data; + Transform::DataMap data; data.Add(BindingRemapper::BindingPoints{}, BindingRemapper::AccessControls{}); auto got = Run(src, data); @@ -112,7 +112,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; data.Add( BindingRemapper::BindingPoints{ {{2, 1}, {1, 2}}, // Remap @@ -158,7 +158,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; data.Add( BindingRemapper::BindingPoints{}, BindingRemapper::AccessControls{ @@ -200,7 +200,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; data.Add( BindingRemapper::BindingPoints{ {{2, 1}, {4, 5}}, @@ -254,7 +254,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; data.Add( BindingRemapper::BindingPoints{ {{2, 1}, {1, 1}}, @@ -316,7 +316,7 @@ fn f2() { } )"; - DataMap data; + Transform::DataMap data; data.Add( BindingRemapper::BindingPoints{ {{2, 1}, {1, 1}}, diff --git a/src/tint/ast/transform/builtin_polyfill_test.cc b/src/tint/ast/transform/builtin_polyfill_test.cc index e48ab70f5e..668c4fcbe0 100644 --- a/src/tint/ast/transform/builtin_polyfill_test.cc +++ b/src/tint/ast/transform/builtin_polyfill_test.cc @@ -41,10 +41,10 @@ TEST_F(BuiltinPolyfillTest, EmptyModule) { //////////////////////////////////////////////////////////////////////////////// // acosh //////////////////////////////////////////////////////////////////////////////// -DataMap polyfillAcosh(Level level) { +Transform::DataMap polyfillAcosh(Level level) { BuiltinPolyfill::Builtins builtins; builtins.acosh = level; - DataMap data; + Transform::DataMap data; data.Add(builtins); return data; } @@ -172,10 +172,10 @@ fn f() { //////////////////////////////////////////////////////////////////////////////// // asinh //////////////////////////////////////////////////////////////////////////////// -DataMap polyfillSinh() { +Transform::DataMap polyfillSinh() { BuiltinPolyfill::Builtins builtins; builtins.asinh = true; - DataMap data; + Transform::DataMap data; data.Add(builtins); return data; } @@ -253,10 +253,10 @@ fn f() { //////////////////////////////////////////////////////////////////////////////// // atanh //////////////////////////////////////////////////////////////////////////////// -DataMap polyfillAtanh(Level level) { +Transform::DataMap polyfillAtanh(Level level) { BuiltinPolyfill::Builtins builtins; builtins.atanh = level; - DataMap data; + Transform::DataMap data; data.Add(builtins); return data; } @@ -384,10 +384,10 @@ fn f() { //////////////////////////////////////////////////////////////////////////////// // bgra8unorm //////////////////////////////////////////////////////////////////////////////// -DataMap polyfillBgra8unorm() { +Transform::DataMap polyfillBgra8unorm() { BuiltinPolyfill::Builtins builtins; builtins.bgra8unorm = true; - DataMap data; + Transform::DataMap data; data.Add(builtins); return data; } @@ -505,7 +505,7 @@ fn f(coords : vec2, value : vec4) { BuiltinPolyfill::Builtins builtins; builtins.atanh = BuiltinPolyfill::Level::kFull; builtins.bgra8unorm = true; - DataMap data; + Transform::DataMap data; data.Add(builtins); auto got = Run(src, std::move(data)); @@ -516,10 +516,10 @@ fn f(coords : vec2, value : vec4) { //////////////////////////////////////////////////////////////////////////////// // bitshiftModulo //////////////////////////////////////////////////////////////////////////////// -DataMap polyfillBitshiftModulo() { +Transform::DataMap polyfillBitshiftModulo() { BuiltinPolyfill::Builtins builtins; builtins.bitshift_modulo = true; - DataMap data; + Transform::DataMap data; data.Add(builtins); return data; } @@ -655,10 +655,10 @@ fn f() { //////////////////////////////////////////////////////////////////////////////// // clampInteger //////////////////////////////////////////////////////////////////////////////// -DataMap polyfillClampInteger() { +Transform::DataMap polyfillClampInteger() { BuiltinPolyfill::Builtins builtins; builtins.clamp_int = true; - DataMap data; + Transform::DataMap data; data.Add(builtins); return data; } @@ -818,10 +818,10 @@ fn f() { //////////////////////////////////////////////////////////////////////////////// // conv_f32_to_iu32 //////////////////////////////////////////////////////////////////////////////// -DataMap polyfillConvF32ToIU32() { +Transform::DataMap polyfillConvF32ToIU32() { BuiltinPolyfill::Builtins builtins; builtins.conv_f32_to_iu32 = true; - DataMap data; + Transform::DataMap data; data.Add(builtins); return data; } @@ -969,10 +969,10 @@ fn f() { //////////////////////////////////////////////////////////////////////////////// // countLeadingZeros //////////////////////////////////////////////////////////////////////////////// -DataMap polyfillCountLeadingZeros() { +Transform::DataMap polyfillCountLeadingZeros() { BuiltinPolyfill::Builtins builtins; builtins.count_leading_zeros = true; - DataMap data; + Transform::DataMap data; data.Add(builtins); return data; } @@ -1142,10 +1142,10 @@ fn f() { //////////////////////////////////////////////////////////////////////////////// // countTrailingZeros //////////////////////////////////////////////////////////////////////////////// -DataMap polyfillCountTrailingZeros() { +Transform::DataMap polyfillCountTrailingZeros() { BuiltinPolyfill::Builtins builtins; builtins.count_trailing_zeros = true; - DataMap data; + Transform::DataMap data; data.Add(builtins); return data; } @@ -1315,10 +1315,10 @@ fn f() { //////////////////////////////////////////////////////////////////////////////// // extractBits //////////////////////////////////////////////////////////////////////////////// -DataMap polyfillExtractBits(Level level) { +Transform::DataMap polyfillExtractBits(Level level) { BuiltinPolyfill::Builtins builtins; builtins.extract_bits = level; - DataMap data; + Transform::DataMap data; data.Add(builtins); return data; } @@ -1570,10 +1570,10 @@ fn f() { //////////////////////////////////////////////////////////////////////////////// // firstLeadingBit //////////////////////////////////////////////////////////////////////////////// -DataMap polyfillFirstLeadingBit() { +Transform::DataMap polyfillFirstLeadingBit() { BuiltinPolyfill::Builtins builtins; builtins.first_leading_bit = true; - DataMap data; + Transform::DataMap data; data.Add(builtins); return data; } @@ -1743,10 +1743,10 @@ fn f() { //////////////////////////////////////////////////////////////////////////////// // firstTrailingBit //////////////////////////////////////////////////////////////////////////////// -DataMap polyfillFirstTrailingBit() { +Transform::DataMap polyfillFirstTrailingBit() { BuiltinPolyfill::Builtins builtins; builtins.first_trailing_bit = true; - DataMap data; + Transform::DataMap data; data.Add(builtins); return data; } @@ -1916,10 +1916,10 @@ fn f() { //////////////////////////////////////////////////////////////////////////////// // insertBits //////////////////////////////////////////////////////////////////////////////// -DataMap polyfillInsertBits(Level level) { +Transform::DataMap polyfillInsertBits(Level level) { BuiltinPolyfill::Builtins builtins; builtins.insert_bits = level; - DataMap data; + Transform::DataMap data; data.Add(builtins); return data; } @@ -2159,10 +2159,10 @@ fn f() { //////////////////////////////////////////////////////////////////////////////// // precise_float_mod //////////////////////////////////////////////////////////////////////////////// -DataMap polyfillPreciseFloatMod() { +Transform::DataMap polyfillPreciseFloatMod() { BuiltinPolyfill::Builtins builtins; builtins.precise_float_mod = true; - DataMap data; + Transform::DataMap data; data.Add(builtins); return data; } @@ -2385,10 +2385,10 @@ fn f() { //////////////////////////////////////////////////////////////////////////////// // int_div_mod //////////////////////////////////////////////////////////////////////////////// -DataMap polyfillIntDivMod() { +Transform::DataMap polyfillIntDivMod() { BuiltinPolyfill::Builtins builtins; builtins.int_div_mod = true; - DataMap data; + Transform::DataMap data; data.Add(builtins); return data; } @@ -3199,10 +3199,10 @@ fn f() { //////////////////////////////////////////////////////////////////////////////// // reflect for vec2 //////////////////////////////////////////////////////////////////////////////// -DataMap polyfillReflectVec2F32() { +Transform::DataMap polyfillReflectVec2F32() { BuiltinPolyfill::Builtins builtins; builtins.reflect_vec2_f32 = true; - DataMap data; + Transform::DataMap data; data.Add(builtins); return data; } @@ -3370,10 +3370,10 @@ fn f() { //////////////////////////////////////////////////////////////////////////////// // saturate //////////////////////////////////////////////////////////////////////////////// -DataMap polyfillSaturate() { +Transform::DataMap polyfillSaturate() { BuiltinPolyfill::Builtins builtins; builtins.saturate = true; - DataMap data; + Transform::DataMap data; data.Add(builtins); return data; } @@ -3507,10 +3507,10 @@ fn f() { //////////////////////////////////////////////////////////////////////////////// // sign_int //////////////////////////////////////////////////////////////////////////////// -DataMap polyfillSignInt() { +Transform::DataMap polyfillSignInt() { BuiltinPolyfill::Builtins builtins; builtins.sign_int = true; - DataMap data; + Transform::DataMap data; data.Add(builtins); return data; } @@ -3600,10 +3600,10 @@ fn f() { //////////////////////////////////////////////////////////////////////////////// // textureSampleBaseClampToEdge //////////////////////////////////////////////////////////////////////////////// -DataMap polyfillTextureSampleBaseClampToEdge_2d_f32() { +Transform::DataMap polyfillTextureSampleBaseClampToEdge_2d_f32() { BuiltinPolyfill::Builtins builtins; builtins.texture_sample_base_clamp_to_edge_2d_f32 = true; - DataMap data; + Transform::DataMap data; data.Add(builtins); return data; } @@ -3671,18 +3671,18 @@ fn f() { //////////////////////////////////////////////////////////////////////////////// // workgroupUniformLoad //////////////////////////////////////////////////////////////////////////////// -DataMap polyfillWorkgroupUniformLoad() { +Transform::DataMap polyfillWorkgroupUniformLoad() { BuiltinPolyfill::Builtins builtins; builtins.workgroup_uniform_load = true; - DataMap data; + Transform::DataMap data; data.Add(builtins); return data; } -DataMap polyfillWorkgroupUniformLoadWithDirectVariableAccess() { - DataMap data; +Transform::DataMap polyfillWorkgroupUniformLoadWithDirectVariableAccess() { + Transform::DataMap data; BuiltinPolyfill::Builtins builtins; builtins.workgroup_uniform_load = true; @@ -3893,10 +3893,10 @@ fn f() { //////////////////////////////////////////////////////////////////////////////// // quantizeToF16 //////////////////////////////////////////////////////////////////////////////// -DataMap polyfillQuantizeToF16_2d_f32() { +Transform::DataMap polyfillQuantizeToF16_2d_f32() { BuiltinPolyfill::Builtins builtins; builtins.quantize_to_vec_f16 = true; - DataMap data; + Transform::DataMap data; data.Add(builtins); return data; } @@ -4021,7 +4021,7 @@ fn f(x : i32, y : u32, z : u32) { BuiltinPolyfill::Builtins builtins; builtins.bitshift_modulo = true; builtins.int_div_mod = true; - DataMap data; + Transform::DataMap data; data.Add(builtins); auto got = Run(src, std::move(data)); diff --git a/src/tint/ast/transform/canonicalize_entry_point_io_test.cc b/src/tint/ast/transform/canonicalize_entry_point_io_test.cc index 98af3a7088..454fb3b4ec 100644 --- a/src/tint/ast/transform/canonicalize_entry_point_io_test.cc +++ b/src/tint/ast/transform/canonicalize_entry_point_io_test.cc @@ -48,7 +48,7 @@ fn comp_main() { auto* expect = src; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl); auto got = Run(src, data); @@ -82,7 +82,7 @@ fn frag_main() { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kSpirv); auto got = Run(src, data); @@ -117,7 +117,7 @@ fn frag_main(@builtin(position) coord : vec4, tint_symbol : tint_symbol_1) } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl); auto got = Run(src, data); @@ -154,7 +154,7 @@ fn frag_main(tint_symbol : tint_symbol_1) { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); auto got = Run(src, data); @@ -189,7 +189,7 @@ fn frag_main(tint_symbol : tint_symbol_1) { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl); auto got = Run(src, data); @@ -224,7 +224,7 @@ fn frag_main(tint_symbol : tint_symbol_1) { alias myf32 = f32; )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl); auto got = Run(src, data); @@ -277,7 +277,7 @@ fn frag_main() { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kSpirv); auto got = Run(src, data); @@ -330,7 +330,7 @@ struct FragLocations { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kSpirv); auto got = Run(src, data); @@ -384,7 +384,7 @@ fn frag_main(@builtin(position) coord : vec4, tint_symbol : tint_symbol_1) } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl); auto got = Run(src, data); @@ -438,7 +438,7 @@ struct FragLocations { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl); auto got = Run(src, data); @@ -494,7 +494,7 @@ fn frag_main(tint_symbol : tint_symbol_1) { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); auto got = Run(src, data); @@ -550,7 +550,7 @@ struct FragLocations { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); auto got = Run(src, data); @@ -579,7 +579,7 @@ fn frag_main() { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kSpirv); auto got = Run(src, data); @@ -613,7 +613,7 @@ fn frag_main() -> tint_symbol { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl); auto got = Run(src, data); @@ -647,7 +647,7 @@ fn frag_main() -> tint_symbol { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); auto got = Run(src, data); @@ -702,7 +702,7 @@ fn frag_main() { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kSpirv); auto got = Run(src, data); @@ -757,7 +757,7 @@ struct FragOutput { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kSpirv); auto got = Run(src, data); @@ -817,7 +817,7 @@ fn frag_main() -> tint_symbol { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl); auto got = Run(src, data); @@ -877,7 +877,7 @@ struct FragOutput { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl); auto got = Run(src, data); @@ -937,7 +937,7 @@ fn frag_main() -> tint_symbol { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); auto got = Run(src, data); @@ -997,7 +997,7 @@ struct FragOutput { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); auto got = Run(src, data); @@ -1063,7 +1063,7 @@ fn frag_main2() { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kSpirv); auto got = Run(src, data); @@ -1129,7 +1129,7 @@ struct FragmentInput { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kSpirv); auto got = Run(src, data); @@ -1201,7 +1201,7 @@ fn frag_main2(tint_symbol_2 : tint_symbol_3) { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl); auto got = Run(src, data); @@ -1273,7 +1273,7 @@ struct FragmentInput { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl); auto got = Run(src, data); @@ -1345,7 +1345,7 @@ fn frag_main2(tint_symbol_2 : tint_symbol_3) { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); auto got = Run(src, data); @@ -1417,7 +1417,7 @@ struct FragmentInput { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); auto got = Run(src, data); @@ -1484,7 +1484,7 @@ fn frag_main1(tint_symbol : tint_symbol_1) { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl); auto got = Run(src, data); @@ -1551,7 +1551,7 @@ struct FragmentInput { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl); auto got = Run(src, data); @@ -1637,7 +1637,7 @@ fn frag_main(tint_symbol : tint_symbol_1) -> tint_symbol_2 { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl); auto got = Run(src, data); @@ -1723,7 +1723,7 @@ struct FragmentOutput { alias myf32 = f32; )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl); auto got = Run(src, data); @@ -1814,7 +1814,7 @@ fn frag_main(tint_symbol_1 : tint_symbol_2) { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); auto got = Run(src, data); @@ -1905,7 +1905,7 @@ struct FragmentIn { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); auto got = Run(src, data); @@ -2035,7 +2035,7 @@ fn frag_main() { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kSpirv); auto got = Run(src, data); @@ -2165,7 +2165,7 @@ struct FragmentInterface { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kSpirv); auto got = Run(src, data); @@ -2229,7 +2229,7 @@ fn main2() -> tint_symbol_1 { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); auto got = Run(src, data); @@ -2293,7 +2293,7 @@ struct VertexOut { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); auto got = Run(src, data); @@ -2360,7 +2360,7 @@ fn frag_main(tint_symbol : tint_symbol_1) -> tint_symbol_2 { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); auto got = Run(src, data); @@ -2427,7 +2427,7 @@ struct FragmentOutput { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); auto got = Run(src, data); @@ -2531,7 +2531,7 @@ fn frag_main(tint_symbol_1 : tint_symbol_2) { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); auto got = Run(src, data); @@ -2635,7 +2635,7 @@ struct FragmentInputExtra { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); auto got = Run(src, data); @@ -2664,7 +2664,7 @@ fn tint_symbol_1(tint_symbol : tint_symbol_2) { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl); auto got = Run(src, data); @@ -2696,7 +2696,7 @@ fn frag_main() -> tint_symbol { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0x03u); auto got = Run(src, data); @@ -2730,7 +2730,7 @@ fn frag_main() -> tint_symbol { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0x03u); auto got = Run(src, data); @@ -2764,7 +2764,7 @@ fn frag_main() -> tint_symbol { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0x03u); auto got = Run(src, data); @@ -2801,7 +2801,7 @@ fn frag_main() -> tint_symbol { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0x03u); auto got = Run(src, data); @@ -2853,7 +2853,7 @@ fn frag_main() -> tint_symbol { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0x03u); auto got = Run(src, data); @@ -2905,7 +2905,7 @@ struct Output { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0x03u); auto got = Run(src, data); @@ -2955,7 +2955,7 @@ fn frag_main() -> tint_symbol { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0x03u); auto got = Run(src, data); @@ -3005,7 +3005,7 @@ struct Output { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0x03u); auto got = Run(src, data); @@ -3094,7 +3094,7 @@ fn comp_main1() { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0x03u); auto got = Run(src, data); @@ -3144,7 +3144,7 @@ fn frag_main() -> tint_symbol { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0x03); auto got = Run(src, data); @@ -3176,7 +3176,7 @@ fn vert_main() { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kSpirv, 0xFFFFFFFF, true); auto got = Run(src, data); @@ -3214,7 +3214,7 @@ fn vert_main() -> tint_symbol { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0xFFFFFFFF, true); auto got = Run(src, data); @@ -3255,7 +3255,7 @@ fn vert_main() { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kSpirv, 0xFFFFFFFF, true); auto got = Run(src, data); @@ -3296,7 +3296,7 @@ struct VertOut { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kSpirv, 0xFFFFFFFF, true); auto got = Run(src, data); @@ -3342,7 +3342,7 @@ fn vert_main() -> tint_symbol { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0xFFFFFFFF, true); auto got = Run(src, data); @@ -3388,7 +3388,7 @@ struct VertOut { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0xFFFFFFFF, true); auto got = Run(src, data); @@ -3466,7 +3466,7 @@ fn vert_main() { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kSpirv, 0xFFFFFFFF, true); auto got = Run(src, data); @@ -3544,7 +3544,7 @@ struct VertOut { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kSpirv, 0xFFFFFFFF, true); auto got = Run(src, data); @@ -3620,7 +3620,7 @@ fn vert_main(tint_symbol : tint_symbol_1) -> tint_symbol_2 { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0xFFFFFFFF, true); auto got = Run(src, data); @@ -3696,7 +3696,7 @@ struct VertOut { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0xFFFFFFFF, true); auto got = Run(src, data); @@ -3772,7 +3772,7 @@ fn vert_main(tint_symbol : tint_symbol_1) -> tint_symbol_2 { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl, 0xFFFFFFFF, true); auto got = Run(src, data); @@ -3848,7 +3848,7 @@ struct VertOut { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl, 0xFFFFFFFF, true); auto got = Run(src, data); @@ -3884,7 +3884,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kSpirv); auto got = Run(src, data); @@ -3919,7 +3919,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kGlsl); auto got = Run(src, data); @@ -3956,7 +3956,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kGlsl); auto got = Run(src, data); diff --git a/src/tint/ast/transform/combine_samplers_test.cc b/src/tint/ast/transform/combine_samplers_test.cc index f658493450..fa74b8a83c 100644 --- a/src/tint/ast/transform/combine_samplers_test.cc +++ b/src/tint/ast/transform/combine_samplers_test.cc @@ -28,7 +28,7 @@ TEST_F(CombineSamplersTest, EmptyModule) { auto* src = ""; auto* expect = ""; - DataMap data; + Transform::DataMap data; data.Add(CombineSamplers::BindingMap(), sem::BindingPoint()); auto got = Run(src, data); @@ -55,7 +55,7 @@ fn main() -> vec4 { } )"; - DataMap data; + Transform::DataMap data; data.Add(CombineSamplers::BindingMap(), sem::BindingPoint()); auto got = Run(src, data); @@ -82,7 +82,7 @@ fn main() -> vec4 { } )"; - DataMap data; + Transform::DataMap data; data.Add(CombineSamplers::BindingMap(), sem::BindingPoint()); auto got = Run(src, data); @@ -117,7 +117,7 @@ fn main() -> vec4 { } )"; - DataMap data; + Transform::DataMap data; data.Add(CombineSamplers::BindingMap(), sem::BindingPoint()); auto got = Run(src, data); @@ -152,7 +152,7 @@ fn sample(t_s_1 : texture_2d, coords : vec2) -> vec4 { } )"; - DataMap data; + Transform::DataMap data; data.Add(CombineSamplers::BindingMap(), sem::BindingPoint()); auto got = Run(src, data); @@ -179,7 +179,7 @@ fn main() -> vec4 { } )"; - DataMap data; + Transform::DataMap data; CombineSamplers::BindingMap map; sem::SamplerTexturePair pair; pair.texture_binding_point.group = 0; @@ -214,7 +214,7 @@ fn main() -> vec4 { } )"; - DataMap data; + Transform::DataMap data; CombineSamplers::BindingMap map; sem::SamplerTexturePair pair; pair.texture_binding_point.group = 3; @@ -262,7 +262,7 @@ fn main() -> vec4 { } )"; - DataMap data; + Transform::DataMap data; data.Add(CombineSamplers::BindingMap(), sem::BindingPoint()); auto got = Run(src, data); @@ -300,7 +300,7 @@ fn sample(t_s_1 : texture_2d, coords : vec2) -> vec4 { alias Tex2d = texture_2d; )"; - DataMap data; + Transform::DataMap data; data.Add(CombineSamplers::BindingMap(), sem::BindingPoint()); auto got = Run(src, data); @@ -343,7 +343,7 @@ fn main() -> vec4 { } )"; - DataMap data; + Transform::DataMap data; data.Add(CombineSamplers::BindingMap(), sem::BindingPoint()); auto got = Run(src, data); @@ -385,7 +385,7 @@ fn g(t_s_2 : texture_2d, coords : vec2) -> vec4 { } )"; - DataMap data; + Transform::DataMap data; data.Add(CombineSamplers::BindingMap(), sem::BindingPoint()); auto got = Run(src, data); @@ -428,7 +428,7 @@ fn main() -> vec4 { } )"; - DataMap data; + Transform::DataMap data; data.Add(CombineSamplers::BindingMap(), sem::BindingPoint()); auto got = Run(src, data); @@ -491,7 +491,7 @@ fn main() -> vec4 { } )"; - DataMap data; + Transform::DataMap data; data.Add(CombineSamplers::BindingMap(), sem::BindingPoint()); auto got = Run(src, data); @@ -538,7 +538,7 @@ fn main() -> vec4 { } )"; - DataMap data; + Transform::DataMap data; data.Add(CombineSamplers::BindingMap(), sem::BindingPoint()); auto got = Run(src, data); @@ -585,7 +585,7 @@ fn main() -> vec4 { } )"; - DataMap data; + Transform::DataMap data; data.Add(CombineSamplers::BindingMap(), sem::BindingPoint()); auto got = Run(src, data); @@ -624,7 +624,7 @@ fn main() -> vec4 { } )"; - DataMap data; + Transform::DataMap data; data.Add(CombineSamplers::BindingMap(), sem::BindingPoint()); auto got = Run(src, data); @@ -661,7 +661,7 @@ fn f(tex_s1 : texture_2d, tex_s2 : texture_2d, coords : vec2) -> } )"; - DataMap data; + Transform::DataMap data; data.Add(CombineSamplers::BindingMap(), sem::BindingPoint()); auto got = Run(src, data); @@ -700,7 +700,7 @@ fn main() -> vec4 { } )"; - DataMap data; + Transform::DataMap data; data.Add(CombineSamplers::BindingMap(), sem::BindingPoint()); auto got = Run(src, data); @@ -737,7 +737,7 @@ fn f(t1_samp : texture_2d, t2_samp : texture_2d, coords : vec2) - } )"; - DataMap data; + Transform::DataMap data; data.Add(CombineSamplers::BindingMap(), sem::BindingPoint()); auto got = Run(src, data); @@ -776,7 +776,7 @@ fn main() -> vec4 { pair.sampler_binding_point.binding = placeholder.binding; CombineSamplers::BindingMap map; map[pair] = "fred"; - DataMap data; + Transform::DataMap data; data.Add(map, placeholder); auto got = Run(src, data); @@ -820,7 +820,7 @@ fn main() -> vec4 { CombineSamplers::BindingMap map; map[pair] = "barney"; map[placeholder_pair] = "fred"; - DataMap data; + Transform::DataMap data; data.Add(map, placeholder); auto got = Run(src, data); @@ -847,7 +847,7 @@ fn main() -> vec4 { } )"; - DataMap data; + Transform::DataMap data; data.Add(CombineSamplers::BindingMap(), sem::BindingPoint()); auto got = Run(src, data); @@ -882,7 +882,7 @@ fn main() -> vec4 { } )"; - DataMap data; + Transform::DataMap data; data.Add(CombineSamplers::BindingMap(), sem::BindingPoint()); auto got = Run(src, data); @@ -916,7 +916,7 @@ fn f(t_s : texture_depth_2d, coords : vec2) -> f32 { } )"; - DataMap data; + Transform::DataMap data; data.Add(CombineSamplers::BindingMap(), sem::BindingPoint()); auto got = Run(src, data); @@ -947,7 +947,7 @@ fn main() -> vec4 { } )"; - DataMap data; + Transform::DataMap data; data.Add(CombineSamplers::BindingMap(), sem::BindingPoint()); auto got = Run(src, data); @@ -977,7 +977,7 @@ fn main() -> vec4 { @internal(disable_validation__binding_point_collision) @group(0) @binding(0) var gcoords : vec2; )"; - DataMap data; + Transform::DataMap data; data.Add(CombineSamplers::BindingMap(), sem::BindingPoint()); auto got = Run(src, data); diff --git a/src/tint/ast/transform/direct_variable_access_test.cc b/src/tint/ast/transform/direct_variable_access_test.cc index b7359910df..ecc884354d 100644 --- a/src/tint/ast/transform/direct_variable_access_test.cc +++ b/src/tint/ast/transform/direct_variable_access_test.cc @@ -23,22 +23,22 @@ namespace tint::ast::transform { namespace { -/// @returns a DataMap with DirectVariableAccess::Config::transform_private enabled. -static DataMap EnablePrivate() { +/// @returns a Transform::DataMap with DirectVariableAccess::Config::transform_private enabled. +static Transform::DataMap EnablePrivate() { DirectVariableAccess::Options opts; opts.transform_private = true; - DataMap inputs; + Transform::DataMap inputs; inputs.Add(opts); return inputs; } -/// @returns a DataMap with DirectVariableAccess::Config::transform_function enabled. -static DataMap EnableFunction() { +/// @returns a Transform::DataMap with DirectVariableAccess::Config::transform_function enabled. +static Transform::DataMap EnableFunction() { DirectVariableAccess::Options opts; opts.transform_function = true; - DataMap inputs; + Transform::DataMap inputs; inputs.Add(opts); return inputs; } diff --git a/src/tint/ast/transform/first_index_offset.h b/src/tint/ast/transform/first_index_offset.h index cb5e3f3a43..44a3a63d4e 100644 --- a/src/tint/ast/transform/first_index_offset.h +++ b/src/tint/ast/transform/first_index_offset.h @@ -62,7 +62,7 @@ class FirstIndexOffset final : public utils::Castable { + struct BindingPoint final : public utils::Castable { /// Constructor BindingPoint(); @@ -82,7 +82,7 @@ class FirstIndexOffset final : public utils::Castable { + struct Data final : public utils::Castable { /// Constructor /// @param has_vtx_or_inst_index True if the shader uses vertex_index or /// instance_index diff --git a/src/tint/ast/transform/first_index_offset_test.cc b/src/tint/ast/transform/first_index_offset_test.cc index 1be6474f34..8dc441f79f 100644 --- a/src/tint/ast/transform/first_index_offset_test.cc +++ b/src/tint/ast/transform/first_index_offset_test.cc @@ -57,7 +57,7 @@ TEST_F(FirstIndexOffsetTest, EmptyModule) { auto* src = ""; auto* expect = ""; - DataMap config; + Transform::DataMap config; config.Add(0, 0); auto got = Run(src, std::move(config)); @@ -77,7 +77,7 @@ fn entry() -> @builtin(position) vec4 { )"; auto* expect = src; - DataMap config; + Transform::DataMap config; config.Add(0, 0); auto got = Run(src, std::move(config)); @@ -121,7 +121,7 @@ fn entry(@builtin(vertex_index) vert_idx : u32) -> @builtin(position) vec4 } )"; - DataMap config; + Transform::DataMap config; config.Add(1, 2); auto got = Run(src, std::move(config)); @@ -165,7 +165,7 @@ fn test(vert_idx : u32) -> u32 { } )"; - DataMap config; + Transform::DataMap config; config.Add(1, 2); auto got = Run(src, std::move(config)); @@ -209,7 +209,7 @@ fn entry(@builtin(instance_index) inst_idx : u32) -> @builtin(position) vec4(1, 7); auto got = Run(src, std::move(config)); @@ -253,7 +253,7 @@ fn test(inst_idx : u32) -> u32 { } )"; - DataMap config; + Transform::DataMap config; config.Add(1, 7); auto got = Run(src, std::move(config)); @@ -309,7 +309,7 @@ fn entry(inputs : Inputs) -> @builtin(position) vec4 { } )"; - DataMap config; + Transform::DataMap config; config.Add(1, 2); auto got = Run(src, std::move(config)); @@ -365,7 +365,7 @@ fn test(instance_idx : u32, vert_idx : u32) -> u32 { } )"; - DataMap config; + Transform::DataMap config; config.Add(1, 2); auto got = Run(src, std::move(config)); @@ -417,7 +417,7 @@ fn entry(@builtin(vertex_index) vert_idx : u32) -> @builtin(position) vec4 } )"; - DataMap config; + Transform::DataMap config; config.Add(1, 2); auto got = Run(src, std::move(config)); @@ -469,7 +469,7 @@ fn func1(vert_idx : u32) -> u32 { } )"; - DataMap config; + Transform::DataMap config; config.Add(1, 2); auto got = Run(src, std::move(config)); @@ -537,7 +537,7 @@ fn entry_c(@builtin(instance_index) inst_idx : u32) -> @builtin(position) vec4(1, 2); auto got = Run(src, std::move(config)); @@ -605,7 +605,7 @@ fn func(i : u32) -> u32 { } )"; - DataMap config; + Transform::DataMap config; config.Add(1, 2); auto got = Run(src, std::move(config)); diff --git a/src/tint/ast/transform/multiplanar_external_texture_test.cc b/src/tint/ast/transform/multiplanar_external_texture_test.cc index 25c77653a9..8acf25459f 100644 --- a/src/tint/ast/transform/multiplanar_external_texture_test.cc +++ b/src/tint/ast/transform/multiplanar_external_texture_test.cc @@ -23,7 +23,7 @@ using MultiplanarExternalTextureTest = TransformTest; TEST_F(MultiplanarExternalTextureTest, ShouldRunEmptyModule) { auto* src = R"()"; - DataMap data; + Transform::DataMap data; data.Add( MultiplanarExternalTexture::BindingsMap{{{0, 0}, {{0, 1}, {0, 2}}}}); @@ -35,7 +35,7 @@ TEST_F(MultiplanarExternalTextureTest, ShouldRunHasExternalTextureAlias) { alias ET = texture_external; )"; - DataMap data; + Transform::DataMap data; data.Add( MultiplanarExternalTexture::BindingsMap{{{0, 0}, {{0, 1}, {0, 2}}}}); @@ -46,7 +46,7 @@ TEST_F(MultiplanarExternalTextureTest, ShouldRunHasExternalTextureGlobal) { @group(0) @binding(0) var ext_tex : texture_external; )"; - DataMap data; + Transform::DataMap data; data.Add( MultiplanarExternalTexture::BindingsMap{{{0, 0}, {{0, 1}, {0, 2}}}}); @@ -58,7 +58,7 @@ TEST_F(MultiplanarExternalTextureTest, ShouldRunHasExternalTextureParam) { fn f(ext_tex : texture_external) {} )"; - DataMap data; + Transform::DataMap data; data.Add( MultiplanarExternalTexture::BindingsMap{{{0, 0}, {{0, 1}, {0, 2}}}}); @@ -98,7 +98,7 @@ fn main(@builtin(position) coord : vec4) -> @location(0) vec4 { auto* expect = R"(error: missing new binding points for texture_external at binding {0,1})"; - DataMap data; + Transform::DataMap data; // This bindings map specifies 0,0 as the location of the texture_external, // which is incorrect. data.Add( @@ -156,7 +156,7 @@ fn main(@builtin(position) coord : vec4) -> @location(0) vec4 { } )"; - DataMap data; + Transform::DataMap data; data.Add( MultiplanarExternalTexture::BindingsMap{{{0, 0}, {{0, 1}, {0, 2}}}}); auto got = Run(src, data); @@ -212,7 +212,7 @@ fn main(@builtin(position) coord : vec4) -> @location(0) vec4 { @group(0) @binding(0) var ext_tex : texture_2d; )"; - DataMap data; + Transform::DataMap data; data.Add( MultiplanarExternalTexture::BindingsMap{{{0, 0}, {{0, 1}, {0, 2}}}}); auto got = Run(src, data); @@ -296,7 +296,7 @@ fn main(@builtin(position) coord : vec4) -> @location(0) vec4 { } )"; - DataMap data; + Transform::DataMap data; data.Add( MultiplanarExternalTexture::BindingsMap{{{0, 1}, {{0, 2}, {0, 3}}}}); auto got = Run(src, data); @@ -380,7 +380,7 @@ fn main(@builtin(position) coord : vec4) -> @location(0) vec4 { @group(0) @binding(0) var s : sampler; )"; - DataMap data; + Transform::DataMap data; data.Add( MultiplanarExternalTexture::BindingsMap{{{0, 1}, {{0, 2}, {0, 3}}}}); auto got = Run(src, data); @@ -475,7 +475,7 @@ fn main(@builtin(position) coord : vec4) -> @location(0) vec4 { } )"; - DataMap data; + Transform::DataMap data; data.Add( MultiplanarExternalTexture::BindingsMap{{{0, 0}, {{0, 1}, {0, 2}}}}); auto got = Run(src, data); @@ -570,7 +570,7 @@ fn main(@builtin(position) coord : vec4) -> @location(0) vec4 { @group(0) @binding(0) var ext_tex : texture_2d; )"; - DataMap data; + Transform::DataMap data; data.Add( MultiplanarExternalTexture::BindingsMap{{{0, 0}, {{0, 1}, {0, 2}}}}); auto got = Run(src, data); @@ -670,7 +670,7 @@ fn main(@builtin(position) coord : vec4) -> @location(0) vec4 { } )"; - DataMap data; + Transform::DataMap data; data.Add( MultiplanarExternalTexture::BindingsMap{{{0, 1}, {{0, 2}, {0, 3}}}}); auto got = Run(src, data); @@ -770,7 +770,7 @@ fn main(@builtin(position) coord : vec4) -> @location(0) vec4 { @group(0) @binding(1) var ext_tex : texture_2d; )"; - DataMap data; + Transform::DataMap data; data.Add( MultiplanarExternalTexture::BindingsMap{{{0, 1}, {{0, 2}, {0, 3}}}}); auto got = Run(src, data); @@ -878,7 +878,7 @@ fn main(@builtin(position) coord : vec4) -> @location(0) vec4 { } )"; - DataMap data; + Transform::DataMap data; data.Add(MultiplanarExternalTexture::BindingsMap{ {{0, 1}, {{0, 4}, {0, 5}}}, {{0, 2}, {{0, 6}, {0, 7}}}, @@ -974,7 +974,7 @@ fn main() { f(ext_tex, ext_tex_plane_1, ext_tex_params, smp); } )"; - DataMap data; + Transform::DataMap data; data.Add(MultiplanarExternalTexture::BindingsMap{ {{0, 0}, {{0, 2}, {0, 3}}}, }); @@ -1067,7 +1067,7 @@ fn f(t : texture_2d, ext_tex_plane_1_1 : texture_2d, ext_tex_params_1 @group(0) @binding(1) var smp : sampler; )"; - DataMap data; + Transform::DataMap data; data.Add(MultiplanarExternalTexture::BindingsMap{ {{0, 0}, {{0, 2}, {0, 3}}}, }); @@ -1160,7 +1160,7 @@ fn main() { f(smp, ext_tex, ext_tex_plane_1, ext_tex_params); } )"; - DataMap data; + Transform::DataMap data; data.Add(MultiplanarExternalTexture::BindingsMap{ {{0, 0}, {{0, 2}, {0, 3}}}, }); @@ -1262,7 +1262,7 @@ fn main() { f(ext_tex, ext_tex_plane_1, ext_tex_params, smp, ext_tex2, ext_tex_plane_1_1, ext_tex_params_1); } )"; - DataMap data; + Transform::DataMap data; data.Add(MultiplanarExternalTexture::BindingsMap{ {{0, 0}, {{0, 3}, {0, 4}}}, {{0, 2}, {{0, 5}, {0, 6}}}, @@ -1366,7 +1366,7 @@ fn f(t : texture_2d, ext_tex_plane_1_2 : texture_2d, ext_tex_params_2 @group(0) @binding(2) var ext_tex2 : texture_2d; )"; - DataMap data; + Transform::DataMap data; data.Add(MultiplanarExternalTexture::BindingsMap{ {{0, 0}, {{0, 3}, {0, 4}}}, {{0, 2}, {{0, 5}, {0, 6}}}, @@ -1468,7 +1468,7 @@ fn main() { f(ext_tex, ext_tex_plane_1, ext_tex_params, smp); } )"; - DataMap data; + Transform::DataMap data; data.Add(MultiplanarExternalTexture::BindingsMap{ {{0, 0}, {{0, 2}, {0, 3}}}, }); @@ -1569,7 +1569,7 @@ fn main() { f(ext_tex, ext_tex_plane_1, ext_tex_params, smp); } )"; - DataMap data; + Transform::DataMap data; data.Add(MultiplanarExternalTexture::BindingsMap{ {{0, 0}, {{0, 2}, {0, 3}}}, }); @@ -1613,7 +1613,7 @@ fn f(ext_tex : texture_2d, ext_tex_plane_1 : texture_2d, ext_tex_param } )"; - DataMap data; + Transform::DataMap data; data.Add( MultiplanarExternalTexture::BindingsMap{{{0, 0}, {{0, 1}, {0, 2}}}}); auto got = Run(src, data); @@ -1708,7 +1708,7 @@ fn main() { f(ext_tex, ext_tex_plane_1, ext_tex_params, smp); } )"; - DataMap data; + Transform::DataMap data; data.Add(MultiplanarExternalTexture::BindingsMap{ {{0, 0}, {{0, 2}, {0, 3}}}, }); @@ -1804,7 +1804,7 @@ fn f(t : texture_2d, ext_tex_plane_1_1 : texture_2d, ext_tex_params_1 alias ET = texture_external; )"; - DataMap data; + Transform::DataMap data; data.Add(MultiplanarExternalTexture::BindingsMap{ {{0, 0}, {{0, 2}, {0, 3}}}, }); diff --git a/src/tint/ast/transform/num_workgroups_from_uniform_test.cc b/src/tint/ast/transform/num_workgroups_from_uniform_test.cc index b46f6ab3b7..2910655c2c 100644 --- a/src/tint/ast/transform/num_workgroups_from_uniform_test.cc +++ b/src/tint/ast/transform/num_workgroups_from_uniform_test.cc @@ -28,7 +28,7 @@ using NumWorkgroupsFromUniformTest = TransformTest; TEST_F(NumWorkgroupsFromUniformTest, ShouldRunEmptyModule) { auto* src = R"()"; - DataMap data; + Transform::DataMap data; data.Add(sem::BindingPoint{0, 30u}); EXPECT_FALSE(ShouldRun(src, data)); } @@ -40,7 +40,7 @@ fn main(@builtin(num_workgroups) num_wgs : vec3) { } )"; - DataMap data; + Transform::DataMap data; data.Add(sem::BindingPoint{0, 30u}); EXPECT_TRUE(ShouldRun(src, data)); } @@ -55,7 +55,7 @@ fn main(@builtin(num_workgroups) num_wgs : vec3) { auto* expect = "error: missing transform data for tint::ast::transform::NumWorkgroupsFromUniform"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -90,7 +90,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); data.Add(sem::BindingPoint{0, 30u}); auto got = Run(src, data); @@ -134,7 +134,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); data.Add(sem::BindingPoint{0, 30u}); auto got = Run(src, data); @@ -178,7 +178,7 @@ struct Builtins { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); data.Add(sem::BindingPoint{0, 30u}); auto got = Run(src, data); @@ -233,7 +233,7 @@ fn main(tint_symbol : tint_symbol_1) { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); data.Add(sem::BindingPoint{0, 30u}); auto got = Run(src, data); @@ -289,7 +289,7 @@ struct Builtins { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); data.Add(sem::BindingPoint{0, 30u}); auto got = Run(src, data); @@ -388,7 +388,7 @@ fn main3() { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); data.Add(sem::BindingPoint{0, 30u}); auto got = Run(src, data); @@ -429,7 +429,7 @@ fn main(tint_symbol : tint_symbol_1) { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); data.Add(sem::BindingPoint{0, 30u}); auto got = Run(src, data); @@ -530,7 +530,7 @@ fn main3() { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); // Make binding point unspecified. data.Add(std::nullopt); @@ -684,7 +684,7 @@ fn main3() { } )"; - DataMap data; + Transform::DataMap data; data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); // Make binding point unspecified. data.Add(std::nullopt); diff --git a/src/tint/ast/transform/packed_vec3_test.cc b/src/tint/ast/transform/packed_vec3_test.cc index 29d99199ee..6ad0b0aafe 100644 --- a/src/tint/ast/transform/packed_vec3_test.cc +++ b/src/tint/ast/transform/packed_vec3_test.cc @@ -218,7 +218,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -243,7 +243,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -268,7 +268,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -293,7 +293,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -321,7 +321,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -346,7 +346,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -371,7 +371,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -409,7 +409,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -439,7 +439,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -469,7 +469,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -499,7 +499,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -537,7 +537,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -570,7 +570,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -600,7 +600,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -638,7 +638,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -668,7 +668,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -698,7 +698,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -736,7 +736,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -766,7 +766,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -796,7 +796,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -826,7 +826,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -864,7 +864,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -897,7 +897,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -927,7 +927,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -965,7 +965,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -995,7 +995,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1025,7 +1025,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1071,7 +1071,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1109,7 +1109,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1139,7 +1139,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1169,7 +1169,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1199,7 +1199,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1245,7 +1245,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1278,7 +1278,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1316,7 +1316,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1354,7 +1354,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1384,7 +1384,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1427,7 +1427,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1457,7 +1457,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1487,7 +1487,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1531,7 +1531,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1569,7 +1569,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1607,7 +1607,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1645,7 +1645,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1689,7 +1689,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1730,7 +1730,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1768,7 +1768,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1818,7 +1818,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1856,7 +1856,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1894,7 +1894,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1951,7 +1951,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2002,7 +2002,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2045,7 +2045,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2088,7 +2088,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2131,7 +2131,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2189,7 +2189,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2235,7 +2235,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2286,7 +2286,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2341,7 +2341,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2384,7 +2384,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2440,7 +2440,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2483,7 +2483,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2526,7 +2526,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2583,7 +2583,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2634,7 +2634,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2677,7 +2677,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2720,7 +2720,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2763,7 +2763,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2821,7 +2821,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2867,7 +2867,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2918,7 +2918,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2973,7 +2973,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3016,7 +3016,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3072,7 +3072,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3115,7 +3115,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3158,7 +3158,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3223,7 +3223,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3282,7 +3282,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3333,7 +3333,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3376,7 +3376,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3419,7 +3419,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3462,7 +3462,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3528,7 +3528,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3574,7 +3574,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3633,7 +3633,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3688,7 +3688,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3739,7 +3739,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3795,7 +3795,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3838,7 +3838,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3899,7 +3899,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3942,7 +3942,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3985,7 +3985,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -4039,7 +4039,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -4089,7 +4089,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -4144,7 +4144,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -4211,7 +4211,7 @@ struct S { @group(0) @binding(0) var P : S_tint_packed_vec3; )"; - DataMap data; + Transform::DataMap data; auto got = Run(std::move(src), data); EXPECT_EQ(expect, str(got)); @@ -4264,7 +4264,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -4317,7 +4317,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); auto& vars = got.program.AST().GlobalVariables(); @@ -4436,7 +4436,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -4485,7 +4485,7 @@ fn main(s1 : S1) -> S2 { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -4517,7 +4517,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -4578,7 +4578,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -4671,7 +4671,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -4791,7 +4791,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -4885,7 +4885,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -4958,7 +4958,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -5047,7 +5047,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -5172,7 +5172,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -5288,7 +5288,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -5390,7 +5390,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -5477,7 +5477,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -5580,7 +5580,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -5722,7 +5722,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -5790,7 +5790,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -5881,7 +5881,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -5978,7 +5978,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -6084,7 +6084,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -6190,7 +6190,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -6263,7 +6263,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -6336,7 +6336,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -6414,7 +6414,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -6482,7 +6482,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -6550,7 +6550,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -6647,7 +6647,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -6672,7 +6672,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -6697,7 +6697,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -6743,7 +6743,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -6795,7 +6795,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -6860,7 +6860,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -6937,7 +6937,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -7002,7 +7002,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -7075,7 +7075,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -7197,7 +7197,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -7320,7 +7320,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -7466,7 +7466,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -7513,7 +7513,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -7559,7 +7559,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -7619,7 +7619,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -7683,7 +7683,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -7748,7 +7748,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -7788,7 +7788,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -7870,7 +7870,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -7944,7 +7944,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -8038,7 +8038,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -8085,7 +8085,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); diff --git a/src/tint/ast/transform/pad_structs_test.cc b/src/tint/ast/transform/pad_structs_test.cc index 89ce34cfe0..f7dc437c27 100644 --- a/src/tint/ast/transform/pad_structs_test.cc +++ b/src/tint/ast/transform/pad_structs_test.cc @@ -28,7 +28,7 @@ TEST_F(PadStructsTest, EmptyModule) { auto* src = ""; auto* expect = src; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -61,7 +61,7 @@ fn main() { let x = u.x; } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -97,7 +97,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -137,7 +137,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -179,7 +179,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -219,7 +219,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -254,7 +254,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -300,7 +300,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -350,7 +350,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -396,7 +396,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -433,7 +433,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -477,7 +477,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -524,7 +524,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -561,7 +561,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -598,7 +598,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); diff --git a/src/tint/ast/transform/promote_side_effects_to_decl.cc b/src/tint/ast/transform/promote_side_effects_to_decl.cc index 345caf1fdc..19136ddf7b 100644 --- a/src/tint/ast/transform/promote_side_effects_to_decl.cc +++ b/src/tint/ast/transform/promote_side_effects_to_decl.cc @@ -672,7 +672,7 @@ Transform::ApplyResult PromoteSideEffectsToDecl::Apply(const Program* src, tint::transform::Manager manager; manager.Add(); manager.Add(); - return manager.Apply(src, inputs, outputs); + return manager.Run(src, inputs, outputs); } } // namespace tint::ast::transform diff --git a/src/tint/ast/transform/promote_side_effects_to_decl_test.cc b/src/tint/ast/transform/promote_side_effects_to_decl_test.cc index 9cd2e0faf0..f8ce8600e6 100644 --- a/src/tint/ast/transform/promote_side_effects_to_decl_test.cc +++ b/src/tint/ast/transform/promote_side_effects_to_decl_test.cc @@ -25,7 +25,7 @@ TEST_F(PromoteSideEffectsToDeclTest, EmptyModule) { auto* src = ""; auto* expect = ""; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -44,7 +44,7 @@ fn f() { auto* expect = src; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -81,7 +81,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -111,7 +111,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -142,7 +142,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -176,7 +176,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -211,7 +211,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -248,7 +248,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -278,7 +278,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -306,7 +306,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -338,7 +338,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -370,7 +370,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -401,7 +401,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -433,7 +433,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -467,7 +467,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -489,7 +489,7 @@ fn f() { auto* expect = src; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -532,7 +532,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -566,7 +566,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -608,7 +608,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -645,7 +645,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -679,7 +679,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -716,7 +716,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -757,7 +757,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -789,7 +789,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -820,7 +820,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -861,7 +861,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -900,7 +900,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -944,7 +944,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -998,7 +998,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1037,7 +1037,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1077,7 +1077,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1137,7 +1137,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1168,7 +1168,7 @@ fn f() -> i32 { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1205,7 +1205,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1238,7 +1238,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1271,7 +1271,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1302,7 +1302,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1347,7 +1347,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1384,7 +1384,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1429,7 +1429,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1468,7 +1468,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1509,7 +1509,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1548,7 +1548,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1585,7 +1585,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1628,7 +1628,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1685,7 +1685,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1732,7 +1732,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1779,7 +1779,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1818,7 +1818,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1859,7 +1859,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1906,7 +1906,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1946,7 +1946,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -1984,7 +1984,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2031,7 +2031,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2079,7 +2079,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2113,7 +2113,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2146,7 +2146,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2190,7 +2190,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2232,7 +2232,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2279,7 +2279,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2342,7 +2342,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2384,7 +2384,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2427,7 +2427,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2492,7 +2492,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2517,7 +2517,7 @@ fn f() { auto* expect = src; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2555,7 +2555,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2593,7 +2593,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2634,7 +2634,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2680,7 +2680,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2712,7 +2712,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2747,7 +2747,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2778,7 +2778,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2805,7 +2805,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2835,7 +2835,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2866,7 +2866,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2898,7 +2898,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2933,7 +2933,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2963,7 +2963,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -2995,7 +2995,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3027,7 +3027,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3069,7 +3069,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3099,7 +3099,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3132,7 +3132,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3161,7 +3161,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3200,7 +3200,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3264,7 +3264,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3295,7 +3295,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3325,7 +3325,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3355,7 +3355,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3385,7 +3385,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3417,7 +3417,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3450,7 +3450,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3484,7 +3484,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3515,7 +3515,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3547,7 +3547,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3580,7 +3580,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3614,7 +3614,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3651,7 +3651,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3688,7 +3688,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3724,7 +3724,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3760,7 +3760,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3806,7 +3806,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3824,7 +3824,7 @@ fn f() { auto* expect = src; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3873,7 +3873,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3922,7 +3922,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -3970,7 +3970,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -4018,7 +4018,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -4079,7 +4079,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -4127,7 +4127,7 @@ fn m() -> vec4 { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); diff --git a/src/tint/ast/transform/remove_continue_in_switch_test.cc b/src/tint/ast/transform/remove_continue_in_switch_test.cc index 84ad5cd25e..237ceeafac 100644 --- a/src/tint/ast/transform/remove_continue_in_switch_test.cc +++ b/src/tint/ast/transform/remove_continue_in_switch_test.cc @@ -101,7 +101,7 @@ TEST_F(RemoveContinueInSwitchTest, EmptyModule) { auto* src = ""; auto* expect = src; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -163,7 +163,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -247,7 +247,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -332,7 +332,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -423,7 +423,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -501,7 +501,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -553,7 +553,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -607,7 +607,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); diff --git a/src/tint/ast/transform/renamer.h b/src/tint/ast/transform/renamer.h index fb839c214d..5e7c92d221 100644 --- a/src/tint/ast/transform/renamer.h +++ b/src/tint/ast/transform/renamer.h @@ -27,7 +27,7 @@ class Renamer final : public utils::Castable { public: /// Data is outputted by the Renamer transform. /// Data holds information about shader usage and constant buffer offsets. - struct Data final : public utils::Castable { + struct Data final : public utils::Castable { /// Remappings is a map of old symbol name to new symbol name using Remappings = std::unordered_map; @@ -59,7 +59,7 @@ class Renamer final : public utils::Castable { /// Optional configuration options for the transform. /// If omitted, then the renamer will use Target::kAll. - struct Config final : public utils::Castable { + struct Config final : public utils::Castable { /// Constructor /// @param tgt the targets to rename /// @param keep_unicode if false, symbols with non-ascii code-points are diff --git a/src/tint/ast/transform/renamer_test.cc b/src/tint/ast/transform/renamer_test.cc index fe7e845061..4e97c6f112 100644 --- a/src/tint/ast/transform/renamer_test.cc +++ b/src/tint/ast/transform/renamer_test.cc @@ -245,7 +245,7 @@ fn frag_main() { auto expect = src; - DataMap inputs; + Transform::DataMap inputs; inputs.Add(Renamer::Target::kMslKeywords, /* preserve_unicode */ true); auto got = Run(src, inputs); @@ -269,7 +269,7 @@ fn tint_symbol() { } )"; - DataMap inputs; + Transform::DataMap inputs; inputs.Add(Renamer::Target::kAll, /* preserve_unicode */ true); auto got = Run(src, inputs); @@ -379,7 +379,7 @@ fn frag_main() { } )"; - DataMap inputs; + Transform::DataMap inputs; inputs.Add(Renamer::Target::kGlslKeywords, /* preserve_unicode */ false); auto got = Run(src, inputs); @@ -405,7 +405,7 @@ fn frag_main() { } )"; - DataMap inputs; + Transform::DataMap inputs; inputs.Add(Renamer::Target::kHlslKeywords, /* preserve_unicode */ false); auto got = Run(src, inputs); @@ -431,7 +431,7 @@ fn frag_main() { } )"; - DataMap inputs; + Transform::DataMap inputs; inputs.Add(Renamer::Target::kMslKeywords, /* preserve_unicode */ false); auto got = Run(src, inputs); diff --git a/src/tint/ast/transform/robustness_test.cc b/src/tint/ast/transform/robustness_test.cc index 1200bb4f13..ebe7dc21a5 100644 --- a/src/tint/ast/transform/robustness_test.cc +++ b/src/tint/ast/transform/robustness_test.cc @@ -32,7 +32,7 @@ static std::ostream& operator<<(std::ostream& out, Robustness::Action action) { namespace { -DataMap Config(Robustness::Action action) { +Transform::DataMap Config(Robustness::Action action) { Robustness::Config cfg; cfg.value_action = action; cfg.texture_action = action; @@ -42,7 +42,7 @@ DataMap Config(Robustness::Action action) { cfg.storage_action = action; cfg.uniform_action = action; cfg.workgroup_action = action; - DataMap data; + Transform::DataMap data; data.Add(cfg); return data; } diff --git a/src/tint/ast/transform/single_entry_point_test.cc b/src/tint/ast/transform/single_entry_point_test.cc index 54c730f4a1..6a4ebf24a7 100644 --- a/src/tint/ast/transform/single_entry_point_test.cc +++ b/src/tint/ast/transform/single_entry_point_test.cc @@ -38,7 +38,7 @@ TEST_F(SingleEntryPointTest, Error_NoEntryPoints) { auto* expect = "error: entry point 'main' not found"; - DataMap data; + Transform::DataMap data; data.Add("main"); auto got = Run(src, data); @@ -57,7 +57,7 @@ fn main() -> @builtin(position) vec4 { SingleEntryPoint::Config cfg("_"); - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -76,7 +76,7 @@ fn main() {} SingleEntryPoint::Config cfg("foo"); - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -92,7 +92,7 @@ fn main() { SingleEntryPoint::Config cfg("main"); - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -127,7 +127,7 @@ fn comp_main1() { SingleEntryPoint::Config cfg("comp_main1"); - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -177,7 +177,7 @@ fn comp_main1() { SingleEntryPoint::Config cfg("comp_main1"); - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -233,7 +233,7 @@ fn comp_main1() { SingleEntryPoint::Config cfg("comp_main1"); - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -253,7 +253,7 @@ fn main() { SingleEntryPoint::Config cfg("main"); - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -303,7 +303,7 @@ fn comp_main1() { let local_d = c1; } )"; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -321,7 +321,7 @@ fn comp_main2() { let local_d = c2; } )"; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -337,7 +337,7 @@ fn comp_main3() { let local_d = c3; } )"; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -353,7 +353,7 @@ fn comp_main4() { let local_d = c4; } )"; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -367,7 +367,7 @@ fn comp_main5() { let local_d = 1u; } )"; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -403,7 +403,7 @@ fn main() { auto* expect = src; SingleEntryPoint::Config cfg("main"); - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -440,7 +440,7 @@ fn main() { )"; SingleEntryPoint::Config cfg("main"); - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -498,7 +498,7 @@ fn comp_main1() { SingleEntryPoint::Config cfg("comp_main1"); - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -581,7 +581,7 @@ fn comp_main1() { SingleEntryPoint::Config cfg("comp_main1"); - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -604,7 +604,7 @@ fn main() { SingleEntryPoint::Config cfg("main"); - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -624,7 +624,7 @@ fn main() { SingleEntryPoint::Config cfg("main"); - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); diff --git a/src/tint/ast/transform/substitute_override_test.cc b/src/tint/ast/transform/substitute_override_test.cc index 01d9597ee8..9f3cd63020 100644 --- a/src/tint/ast/transform/substitute_override_test.cc +++ b/src/tint/ast/transform/substitute_override_test.cc @@ -32,7 +32,7 @@ fn main() -> @builtin(position) vec4 { auto* expect = "error: Missing override substitution data"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -50,7 +50,7 @@ fn main() -> @builtin(position) vec4 { auto* expect = "error: Initializer not provided for override, and override not overridden."; SubstituteOverride::Config cfg; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -75,7 +75,7 @@ fn main() -> @builtin(position) vec4 { SubstituteOverride::Config cfg; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -143,7 +143,7 @@ fn main() -> @builtin(position) vec4 { cfg.map.insert({OverrideId{6}, 1.0}); cfg.map.insert({OverrideId{7}, 0.0}); - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -212,7 +212,7 @@ fn main() -> @builtin(position) vec4 { cfg.map.insert({OverrideId{7}, 0.0}); cfg.map.insert({OverrideId{5}, 13}); - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -241,7 +241,7 @@ fn main() -> @builtin(position) vec4 { SubstituteOverride::Config cfg; cfg.map.insert({OverrideId{0}, 11.0}); - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -282,7 +282,7 @@ fn f() { SubstituteOverride::Config cfg; cfg.map.insert({OverrideId{0}, 0.0}); - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); diff --git a/src/tint/ast/transform/test_helper.h b/src/tint/ast/transform/test_helper.h index 08b8e30c39..0ec2ec2010 100644 --- a/src/tint/ast/transform/test_helper.h +++ b/src/tint/ast/transform/test_helper.h @@ -21,6 +21,7 @@ #include #include "gtest/gtest.h" +#include "src/tint/ast/transform/transform.h" #include "src/tint/reader/wgsl/parser.h" #include "src/tint/transform/manager.h" #include "src/tint/writer/wgsl/generator.h" @@ -66,11 +67,11 @@ class TransformTestBase : public BASE { /// `transform`. /// @param transform the transform to apply /// @param in the input WGSL source - /// @param data the optional DataMap to pass to Transform::Run() + /// @param data the optional Transform::DataMap to pass to Transform::Run() /// @return the transformed output Output Run(std::string in, std::unique_ptr transform, - const DataMap& data = {}) { + const tint::transform::DataMap& data = {}) { std::vector> transforms; transforms.emplace_back(std::move(transform)); return Run(std::move(in), std::move(transforms), data); @@ -79,10 +80,10 @@ class TransformTestBase : public BASE { /// Transforms and returns the WGSL source `in`, transformed using /// a transform of type `TRANSFORM`. /// @param in the input WGSL source - /// @param data the optional DataMap to pass to Transform::Run() + /// @param data the optional Transform::DataMap to pass to Transform::Run() /// @return the transformed output template - Output Run(std::string in, const DataMap& data = {}) { + Output Run(std::string in, const tint::transform::DataMap& data = {}) { auto file = std::make_unique("test", in); auto program = reader::wgsl::Parse(file.get()); @@ -95,26 +96,28 @@ class TransformTestBase : public BASE { /// Transforms and returns program `program`, transformed using a transform of /// type `TRANSFORM`. /// @param program the input Program - /// @param data the optional DataMap to pass to Transform::Run() + /// @param data the optional Transform::DataMap to pass to Transform::Run() /// @return the transformed output template - Output Run(Program&& program, const DataMap& data = {}) { + Output Run(Program&& program, const tint::transform::DataMap& data = {}) { if (!program.IsValid()) { return Output(std::move(program)); } tint::transform::Manager manager; + tint::transform::DataMap outputs; for (auto* transform_ptr : std::initializer_list{new TRANSFORMS()...}) { manager.append(std::unique_ptr(transform_ptr)); } - return manager.Run(&program, data); + auto result = manager.Run(&program, data, outputs); + return {std::move(result), std::move(outputs)}; } /// @param program the input program - /// @param data the optional DataMap to pass to Transform::Run() + /// @param data the optional Transform::DataMap to pass to Transform::Run() /// @return true if the transform should be run for the given input. template - bool ShouldRun(Program&& program, const DataMap& data = {}) { + bool ShouldRun(Program&& program, const tint::transform::DataMap& data = {}) { if (!program.IsValid()) { ADD_FAILURE() << "ShouldRun() called with invalid program: " << program.Diagnostics().str(); @@ -123,7 +126,7 @@ class TransformTestBase : public BASE { const Transform& t = TRANSFORM(); - DataMap outputs; + tint::transform::DataMap outputs; auto result = t.Apply(&program, data, outputs); if (!result) { return false; @@ -137,10 +140,10 @@ class TransformTestBase : public BASE { } /// @param in the input WGSL source - /// @param data the optional DataMap to pass to Transform::Run() + /// @param data the optional Transform::DataMap to pass to Transform::Run() /// @return true if the transform should be run for the given input. template - bool ShouldRun(std::string in, const DataMap& data = {}) { + bool ShouldRun(std::string in, const tint::transform::DataMap& data = {}) { auto file = std::make_unique("test", in); auto program = reader::wgsl::Parse(file.get()); return ShouldRun(std::move(program), data); diff --git a/src/tint/ast/transform/texture_1d_to_2d_test.cc b/src/tint/ast/transform/texture_1d_to_2d_test.cc index 75da6fc633..4189385404 100644 --- a/src/tint/ast/transform/texture_1d_to_2d_test.cc +++ b/src/tint/ast/transform/texture_1d_to_2d_test.cc @@ -23,7 +23,7 @@ using Texture1DTo2DTest = TransformTest; TEST_F(Texture1DTo2DTest, EmptyModule) { auto* src = ""; - DataMap data; + Transform::DataMap data; EXPECT_FALSE(ShouldRun(src, data)); } @@ -39,7 +39,7 @@ TEST_F(Texture1DTo2DTest, Global1DDecl) { @group(0) @binding(1) var s : sampler; )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -65,7 +65,7 @@ fn main() -> vec4 { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -87,7 +87,7 @@ fn main() -> vec4 { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -109,7 +109,7 @@ fn main() -> u32 { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -131,7 +131,7 @@ fn main() -> u32 { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -153,7 +153,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -167,7 +167,7 @@ TEST_F(Texture1DTo2DTest, GlobalStorage1DDecl) { @group(0) @binding(0) var t : texture_storage_2d; )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -184,7 +184,7 @@ fn main() -> vec4 { } )"; - DataMap data; + Transform::DataMap data; EXPECT_FALSE(ShouldRun(src, data)); } @@ -193,7 +193,7 @@ TEST_F(Texture1DTo2DTest, PrivateIntNoop) { var i : i32; )"; - DataMap data; + Transform::DataMap data; EXPECT_FALSE(ShouldRun(src, data)); } @@ -202,7 +202,7 @@ TEST_F(Texture1DTo2DTest, GlobalMatrixNoop) { @group(0) @binding(0) var m : mat2x2; )"; - DataMap data; + Transform::DataMap data; EXPECT_FALSE(ShouldRun(src, data)); } @@ -234,7 +234,7 @@ fn main() -> vec4 { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -265,7 +265,7 @@ fn main() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -290,7 +290,7 @@ fn d() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); diff --git a/src/tint/ast/transform/transform.cc b/src/tint/ast/transform/transform.cc index 2270aff952..bee1f392c2 100644 --- a/src/tint/ast/transform/transform.cc +++ b/src/tint/ast/transform/transform.cc @@ -28,20 +28,9 @@ #include "src/tint/type/sampler.h" TINT_INSTANTIATE_TYPEINFO(tint::ast::transform::Transform); -TINT_INSTANTIATE_TYPEINFO(tint::ast::transform::Data); namespace tint::ast::transform { -Data::Data() = default; -Data::Data(const Data&) = default; -Data::~Data() = default; -Data& Data::operator=(const Data&) = default; - -DataMap::DataMap() = default; -DataMap::DataMap(DataMap&&) = default; -DataMap::~DataMap() = default; -DataMap& DataMap::operator=(DataMap&&) = default; - Output::Output() = default; Output::Output(Program&& p) : program(std::move(p)) {} Transform::Transform() = default; diff --git a/src/tint/ast/transform/transform.h b/src/tint/ast/transform/transform.h index 82cadceed5..2ad37011dd 100644 --- a/src/tint/ast/transform/transform.h +++ b/src/tint/ast/transform/transform.h @@ -15,8 +15,8 @@ #ifndef SRC_TINT_AST_TRANSFORM_TRANSFORM_H_ #define SRC_TINT_AST_TRANSFORM_TRANSFORM_H_ -#include -#include +#include "src/tint/transform/transform.h" + #include #include "src/tint/program.h" @@ -24,107 +24,6 @@ namespace tint::ast::transform { -/// Data is the base class for transforms that accept extra input or emit extra -/// output information along with a Program. -class Data : public utils::Castable { - public: - /// Constructor - Data(); - - /// Copy constructor - Data(const Data&); - - /// Destructor - ~Data() override; - - /// Assignment operator - /// @returns this Data - Data& operator=(const Data&); -}; - -/// DataMap is a map of Data unique pointers keyed by the Data's ClassID. -class DataMap { - public: - /// Constructor - DataMap(); - - /// Move constructor - DataMap(DataMap&&); - - /// Constructor - /// @param data_unique_ptrs a variadic list of additional data unique_ptrs - /// produced by the transform - template - explicit DataMap(DATA... data_unique_ptrs) { - PutAll(std::forward(data_unique_ptrs)...); - } - - /// Destructor - ~DataMap(); - - /// Move assignment operator - /// @param rhs the DataMap to move into this DataMap - /// @return this DataMap - DataMap& operator=(DataMap&& rhs); - - /// Adds the data into DataMap keyed by the ClassID of type T. - /// @param data the data to add to the DataMap - template - void Put(std::unique_ptr&& data) { - static_assert(std::is_base_of::value, "T does not derive from Data"); - map_[&utils::TypeInfo::Of()] = std::move(data); - } - - /// Creates the data of type `T` with the provided arguments and adds it into - /// DataMap keyed by the ClassID of type T. - /// @param args the arguments forwarded to the initializer for type T - template - void Add(ARGS&&... args) { - Put(std::make_unique(std::forward(args)...)); - } - - /// @returns a pointer to the Data placed into the DataMap with a call to - /// Put() - template - T const* Get() const { - return const_cast(this)->Get(); - } - - /// @returns a pointer to the Data placed into the DataMap with a call to - /// Put() - template - T* Get() { - auto it = map_.find(&utils::TypeInfo::Of()); - if (it == map_.end()) { - return nullptr; - } - return static_cast(it->second.get()); - } - - /// Add moves all the data from other into this DataMap - /// @param other the DataMap to move into this DataMap - void Add(DataMap&& other) { - for (auto& it : other.map_) { - map_.emplace(it.first, std::move(it.second)); - } - other.map_.clear(); - } - - private: - template - void PutAll(T0&& first) { - Put(std::forward(first)); - } - - template - void PutAll(T0&& first, Tn&&... remainder) { - Put(std::forward(first)); - PutAll(std::forward(remainder)...); - } - - std::unordered_map> map_; -}; - /// The return type of Run() class Output { public: @@ -147,11 +46,11 @@ class Output { Program program; /// Extra output generated by the transforms. - DataMap data; + tint::transform::DataMap data; }; /// Interface for Program transforms -class Transform : public utils::Castable { +class Transform : public utils::Castable { public: /// Constructor Transform(); diff --git a/src/tint/ast/transform/truncate_interstage_variables_test.cc b/src/tint/ast/transform/truncate_interstage_variables_test.cc index 14e546cc5c..ecd691e77a 100644 --- a/src/tint/ast/transform/truncate_interstage_variables_test.cc +++ b/src/tint/ast/transform/truncate_interstage_variables_test.cc @@ -51,7 +51,7 @@ fn f() -> ShaderIO { { // Empty interstage_locations: truncate all interstage variables, should run TruncateInterstageVariables::Config cfg; - DataMap data; + Transform::DataMap data; data.Add(cfg); EXPECT_TRUE(ShouldRun(src, data)); } @@ -61,7 +61,7 @@ fn f() -> ShaderIO { TruncateInterstageVariables::Config cfg; cfg.interstage_locations[0] = true; cfg.interstage_locations[2] = true; - DataMap data; + Transform::DataMap data; data.Add(cfg); EXPECT_FALSE(ShouldRun(src, data)); } @@ -70,7 +70,7 @@ fn f() -> ShaderIO { // Partial interstage_locations are marked: should run TruncateInterstageVariables::Config cfg; cfg.interstage_locations[2] = true; - DataMap data; + Transform::DataMap data; data.Add(cfg); EXPECT_TRUE(ShouldRun(src, data)); } @@ -91,7 +91,7 @@ fn f(io: ShaderIO) -> @location(1) vec4 { TruncateInterstageVariables::Config cfg; cfg.interstage_locations[2] = true; - DataMap data; + Transform::DataMap data; data.Add(cfg); EXPECT_FALSE(ShouldRun(src, data)); @@ -109,7 +109,7 @@ fn f() -> @builtin(position) vec4 { TruncateInterstageVariables::Config cfg; cfg.interstage_locations[0] = true; - DataMap data; + Transform::DataMap data; data.Add(cfg); data.Add(CanonicalizeEntryPointIO::ShaderStyle::kHlsl); @@ -169,7 +169,7 @@ fn f() -> tint_symbol { // fragment has input at @location(1) cfg.interstage_locations[1] = true; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -226,7 +226,7 @@ fn f() -> tint_symbol { // fragment has input at @location(3) cfg.interstage_locations[3] = true; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -279,7 +279,7 @@ fn f() -> tint_symbol { )"; TruncateInterstageVariables::Config cfg; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -349,7 +349,7 @@ fn f() -> tint_symbol { cfg.interstage_locations[3] = true; cfg.interstage_locations[5] = true; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -426,7 +426,7 @@ fn f2() -> tint_symbol { // fragment has input at @location(3) cfg.interstage_locations[3] = true; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -521,7 +521,7 @@ fn f2() -> tint_symbol_1 { // fragment has input at @location(3) cfg.interstage_locations[3] = true; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -586,7 +586,7 @@ fn f(@builtin(vertex_index) vid : u32) -> tint_symbol { // fragment has input at @location(3) cfg.interstage_locations[3] = true; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); diff --git a/src/tint/ast/transform/var_for_dynamic_index_test.cc b/src/tint/ast/transform/var_for_dynamic_index_test.cc index 4cfb15e2cb..34d781fea6 100644 --- a/src/tint/ast/transform/var_for_dynamic_index_test.cc +++ b/src/tint/ast/transform/var_for_dynamic_index_test.cc @@ -49,7 +49,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -73,7 +73,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -105,7 +105,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -138,7 +138,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -171,7 +171,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -204,7 +204,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -237,7 +237,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -277,7 +277,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -311,7 +311,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -364,7 +364,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -398,7 +398,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -451,7 +451,7 @@ fn f() { } )"; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -467,7 +467,7 @@ fn f() { auto* expect = src; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -483,7 +483,7 @@ fn f() { auto* expect = src; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -501,7 +501,7 @@ fn f() { auto* expect = src; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -519,7 +519,7 @@ fn f() { auto* expect = src; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -537,7 +537,7 @@ fn f() { auto* expect = src; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); @@ -553,7 +553,7 @@ fn f() { auto* expect = src; - DataMap data; + Transform::DataMap data; auto got = Run(src, data); EXPECT_EQ(expect, str(got)); diff --git a/src/tint/ast/transform/vertex_pulling_test.cc b/src/tint/ast/transform/vertex_pulling_test.cc index eb46dd5953..a0640e8a33 100644 --- a/src/tint/ast/transform/vertex_pulling_test.cc +++ b/src/tint/ast/transform/vertex_pulling_test.cc @@ -28,7 +28,7 @@ TEST_F(VertexPullingTest, Error_NoEntryPoint) { auto* expect = "error: Vertex stage entry point not found"; - DataMap data; + Transform::DataMap data; data.Add(); auto got = Run(src, data); @@ -51,7 +51,7 @@ fn main2() -> @builtin(position) vec4 { VertexPulling::Config cfg; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -68,7 +68,7 @@ fn main() {} VertexPulling::Config cfg; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -90,7 +90,7 @@ fn main(@location(0) var_a : f32) -> @builtin(position) vec4 { VertexPulling::Config cfg; cfg.vertex_state = {{{15, VertexStepMode::kVertex, {{VertexFormat::kFloat32, 0, 0}}}}}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -118,7 +118,7 @@ fn main() -> @builtin(position) vec4 { VertexPulling::Config cfg; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -154,7 +154,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi VertexPulling::Config cfg; cfg.vertex_state = {{{4, VertexStepMode::kVertex, {{VertexFormat::kFloat32, 0, 0}}}}}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -190,7 +190,7 @@ fn main(@builtin(instance_index) tint_pulling_instance_index : u32) -> @builtin( VertexPulling::Config cfg; cfg.vertex_state = {{{4, VertexStepMode::kInstance, {{VertexFormat::kFloat32, 0, 0}}}}}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -227,7 +227,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi cfg.vertex_state = {{{4, VertexStepMode::kVertex, {{VertexFormat::kFloat32, 0, 0}}}}}; cfg.pulling_group = 5; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -272,7 +272,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi VertexPulling::Config cfg; cfg.vertex_state = {{{4, VertexStepMode::kVertex, {{VertexFormat::kFloat32, 0, 0}}}}}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -329,7 +329,7 @@ fn main(@builtin(vertex_index) custom_vertex_index : u32, @builtin(instance_inde }, }}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -407,7 +407,7 @@ fn main(tint_symbol_1 : tint_symbol) -> @builtin(position) vec4 { }, }}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -485,7 +485,7 @@ struct Inputs { }, }}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -560,7 +560,7 @@ fn main(indices : Indices) -> @builtin(position) vec4 { }, }}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -635,7 +635,7 @@ struct Indices { }, }}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -676,7 +676,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi VertexStepMode::kVertex, {{VertexFormat::kFloat32, 0, 0}, {VertexFormat::kFloat32x4, 0, 1}}}}}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -729,7 +729,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi {16, VertexStepMode::kVertex, {{VertexFormat::kFloat32x4, 0, 2}}}, }}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -786,7 +786,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi {16, VertexStepMode::kVertex, {{VertexFormat::kFloat16x4, 0, 2}}}, }}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -835,7 +835,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index_1 : u32) -> @builtin(po VertexStepMode::kVertex, {{VertexFormat::kFloat32, 0, 0}, {VertexFormat::kFloat32x4, 0, 1}}}}}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, std::move(data)); @@ -905,7 +905,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi {VertexFormat::kSint32x4, 64, 7}, }}}}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -975,7 +975,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi {VertexFormat::kUint32x4, 64, 7}, }}}}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -1069,7 +1069,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi {VertexFormat::kFloat32x4, 64, 13}, }}}}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -1167,7 +1167,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi {VertexFormat::kFloat32x4, 64, 13}, }}}}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -1237,7 +1237,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi {VertexFormat::kSint32x4, 63, 7}, }}}}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -1307,7 +1307,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi {VertexFormat::kUint32x4, 63, 7}, }}}}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -1401,7 +1401,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi {VertexFormat::kFloat32x4, 63, 13}, }}}}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -1499,7 +1499,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi {VertexFormat::kFloat32x4, 63, 13}, }}}}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -1577,7 +1577,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi {VertexFormat::kSint32x3, 64, 9}, }}}}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -1655,7 +1655,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi {VertexFormat::kUint32x3, 64, 9}, }}}}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -1757,7 +1757,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi {VertexFormat::kFloat32x3, 64, 15}, }}}}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -1863,7 +1863,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi {VertexFormat::kFloat32x3, 64, 15}, }}}}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -1957,7 +1957,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi {VertexFormat::kSint32x4, 64, 13}, }}}}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -2051,7 +2051,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi {VertexFormat::kUint32x4, 64, 13}, }}}}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -2181,7 +2181,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi {VertexFormat::kFloat32x4, 64, 24}, {VertexFormat::kFloat32x4, 64, 25}, }}}}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); @@ -2315,7 +2315,7 @@ fn main(@builtin(vertex_index) tint_pulling_vertex_index : u32) -> @builtin(posi {VertexFormat::kFloat32x4, 64, 24}, {VertexFormat::kFloat32x4, 64, 25}, }}}}; - DataMap data; + Transform::DataMap data; data.Add(cfg); auto got = Run(src, data); diff --git a/src/tint/cmd/main.cc b/src/tint/cmd/main.cc index 9f7fa36a7a..bfdc41fd18 100644 --- a/src/tint/cmd/main.cc +++ b/src/tint/cmd/main.cc @@ -947,32 +947,30 @@ int main(int argc, const char** argv) { /// Returns true on success, false on error (program will immediately exit) std::function + tint::transform::DataMap& inputs)> make; }; std::vector transforms = { {"first_index_offset", - [](tint::inspector::Inspector&, tint::transform::Manager& m, - tint::ast::transform::DataMap& i) { + [](tint::inspector::Inspector&, tint::transform::Manager& m, tint::transform::DataMap& i) { i.Add(0, 0); m.Add(); return true; }}, {"renamer", - [](tint::inspector::Inspector&, tint::transform::Manager& m, - tint::ast::transform::DataMap&) { + [](tint::inspector::Inspector&, tint::transform::Manager& m, tint::transform::DataMap&) { m.Add(); return true; }}, {"robustness", [&](tint::inspector::Inspector&, tint::transform::Manager&, - tint::ast::transform::DataMap&) { // enabled via writer option + tint::transform::DataMap&) { // enabled via writer option options.enable_robustness = true; return true; }}, {"substitute_override", [&](tint::inspector::Inspector& inspector, tint::transform::Manager& m, - tint::ast::transform::DataMap& i) { + tint::transform::DataMap& i) { tint::ast::transform::SubstituteOverride::Config cfg; std::unordered_map values; @@ -1098,7 +1096,7 @@ int main(int argc, const char** argv) { } tint::transform::Manager transform_manager; - tint::ast::transform::DataMap transform_inputs; + tint::transform::DataMap transform_inputs; // Renaming must always come first switch (options.format) { @@ -1173,14 +1171,15 @@ int main(int argc, const char** argv) { transform_inputs.Add(options.ep_name); } - auto out = transform_manager.Run(program.get(), std::move(transform_inputs)); - if (!out.program.IsValid()) { - tint::cmd::PrintWGSL(std::cerr, out.program); - diag_formatter.format(out.program.Diagnostics(), diag_printer.get()); + tint::transform::DataMap outputs; + auto out = transform_manager.Run(program.get(), std::move(transform_inputs), outputs); + if (!out.IsValid()) { + tint::cmd::PrintWGSL(std::cerr, out); + diag_formatter.format(out.Diagnostics(), diag_printer.get()); return 1; } - *program = std::move(out.program); + *program = std::move(out); bool success = false; switch (options.format) { diff --git a/src/tint/fuzzers/shuffle_transform.cc b/src/tint/fuzzers/shuffle_transform.cc index 9a075c210e..6d0dfd7b98 100644 --- a/src/tint/fuzzers/shuffle_transform.cc +++ b/src/tint/fuzzers/shuffle_transform.cc @@ -24,8 +24,8 @@ namespace tint::fuzzers { ShuffleTransform::ShuffleTransform(size_t seed) : seed_(seed) {} ast::transform::Transform::ApplyResult ShuffleTransform::Apply(const Program* src, - const ast::transform::DataMap&, - ast::transform::DataMap&) const { + const transform::DataMap&, + transform::DataMap&) const { ProgramBuilder b; CloneContext ctx{&b, src, /* auto_clone_symbols */ true}; diff --git a/src/tint/fuzzers/shuffle_transform.h b/src/tint/fuzzers/shuffle_transform.h index 6edbfd76ee..8a5ceeb140 100644 --- a/src/tint/fuzzers/shuffle_transform.h +++ b/src/tint/fuzzers/shuffle_transform.h @@ -28,8 +28,8 @@ class ShuffleTransform : public ast::transform::Transform { /// @copydoc ast::transform::Transform::Apply ApplyResult Apply(const Program* program, - const ast::transform::DataMap& inputs, - ast::transform::DataMap& outputs) const override; + const transform::DataMap& inputs, + transform::DataMap& outputs) const override; private: size_t seed_; diff --git a/src/tint/fuzzers/tint_common_fuzzer.cc b/src/tint/fuzzers/tint_common_fuzzer.cc index 122ab87e8c..5595d101d1 100644 --- a/src/tint/fuzzers/tint_common_fuzzer.cc +++ b/src/tint/fuzzers/tint_common_fuzzer.cc @@ -205,10 +205,10 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) { diagnostics_ = program.Diagnostics(); auto validate_program = [&](auto& out) { - if (!out.program.IsValid()) { + if (!out.IsValid()) { // Transforms can produce error messages for bad input. // Catch ICEs and errors from non transform systems. - for (const auto& diag : out.program.Diagnostics()) { + for (const auto& diag : out.Diagnostics()) { if (diag.severity > diag::Severity::Error || diag.system != diag::System::Transform) { VALIDITY_ERROR(program.Diagnostics(), @@ -219,13 +219,14 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) { return 0; } - program = std::move(out.program); + program = std::move(out); RunInspector(&program); return 1; }; if (transform_manager_) { - auto out = transform_manager_->Run(&program, *transform_inputs_); + transform::DataMap outputs; + auto out = transform_manager_->Run(&program, *transform_inputs_, outputs); if (!validate_program(out)) { return 0; } @@ -248,13 +249,14 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) { } if (!cfg.map.empty()) { - ast::transform::DataMap override_data; + transform::DataMap override_data; override_data.Add(cfg); transform::Manager mgr; mgr.append(std::make_unique()); - auto out = mgr.Run(&program, override_data); + transform::DataMap outputs; + auto out = mgr.Run(&program, override_data, outputs); if (!validate_program(out)) { return 0; } diff --git a/src/tint/fuzzers/tint_common_fuzzer.h b/src/tint/fuzzers/tint_common_fuzzer.h index fdf50d5a13..c1cb656e8a 100644 --- a/src/tint/fuzzers/tint_common_fuzzer.h +++ b/src/tint/fuzzers/tint_common_fuzzer.h @@ -63,7 +63,7 @@ class CommonFuzzer { /// @param tm manager for transforms to run /// @param inputs data for transforms to run - void SetTransformManager(transform::Manager* tm, ast::transform::DataMap* inputs) { + void SetTransformManager(transform::Manager* tm, transform::DataMap* inputs) { assert((!tm || inputs) && "DataMap must be !nullptr if Manager !nullptr"); transform_manager_ = tm; transform_inputs_ = inputs; @@ -121,7 +121,7 @@ class CommonFuzzer { InputFormat input_; OutputFormat output_; transform::Manager* transform_manager_ = nullptr; - ast::transform::DataMap* transform_inputs_ = nullptr; + transform::DataMap* transform_inputs_ = nullptr; bool dump_input_ = false; tint::diag::List diagnostics_; bool enforce_validity = false; diff --git a/src/tint/fuzzers/tint_reader_writer_fuzzer.h b/src/tint/fuzzers/tint_reader_writer_fuzzer.h index 94c4fc4603..b5d0a9590f 100644 --- a/src/tint/fuzzers/tint_reader_writer_fuzzer.h +++ b/src/tint/fuzzers/tint_reader_writer_fuzzer.h @@ -38,7 +38,7 @@ class ReaderWriterFuzzer : public CommonFuzzer { /// invoked. /// @param tm manager for transforms to run /// @param inputs data for transforms to run - void SetTransformManager(transform::Manager* tm, ast::transform::DataMap* inputs) { + void SetTransformManager(transform::Manager* tm, transform::DataMap* inputs) { tm_set_ = true; CommonFuzzer::SetTransformManager(tm, inputs); } diff --git a/src/tint/fuzzers/transform_builder.h b/src/tint/fuzzers/transform_builder.h index 037568faca..a8bcb6da34 100644 --- a/src/tint/fuzzers/transform_builder.h +++ b/src/tint/fuzzers/transform_builder.h @@ -48,7 +48,7 @@ class TransformBuilder { transform::Manager* manager() { return &manager_; } /// @returns data for transforms - ast::transform::DataMap* data_map() { return &data_map_; } + transform::DataMap* data_map() { return &data_map_; } /// Adds a transform and needed data to |manager_| and |data_map_|. /// @tparam T - A class that inherits from ast::transform::Transform and has an @@ -73,7 +73,7 @@ class TransformBuilder { private: DataBuilder builder_; transform::Manager manager_; - ast::transform::DataMap data_map_; + transform::DataMap data_map_; DataBuilder* builder() { return &builder_; } diff --git a/src/tint/reader/spirv/parser.cc b/src/tint/reader/spirv/parser.cc index bc0f2584c2..1699d2c550 100644 --- a/src/tint/reader/spirv/parser.cc +++ b/src/tint/reader/spirv/parser.cc @@ -57,13 +57,14 @@ Program Parse(const std::vector& input, const Options& options) { } transform::Manager manager; + transform::DataMap outputs; manager.Add(); manager.Add(); manager.Add(); manager.Add(); manager.Add(); manager.Add(); - return manager.Run(&program).program; + return manager.Run(&program, {}, outputs); } } // namespace tint::reader::spirv diff --git a/src/tint/transform/manager.cc b/src/tint/transform/manager.cc index b2e6c80759..eff3a0c665 100644 --- a/src/tint/transform/manager.cc +++ b/src/tint/transform/manager.cc @@ -14,6 +14,9 @@ #include "src/tint/transform/manager.h" +#include "src/tint/ast/transform/transform.h" +#include "src/tint/program_builder.h" + /// If set to 1 then the transform::Manager will dump the WGSL of the program /// before and after each transform. Helpful for debugging bad output. #define TINT_PRINT_PROGRAM_FOR_EACH_TRANSFORM 0 @@ -25,16 +28,14 @@ #define TINT_IF_PRINT_PROGRAM(x) #endif // TINT_PRINT_PROGRAM_FOR_EACH_TRANSFORM -TINT_INSTANTIATE_TYPEINFO(tint::transform::Manager); - namespace tint::transform { Manager::Manager() = default; Manager::~Manager() = default; -ast::transform::Transform::ApplyResult Manager::Apply(const Program* program, - const ast::transform::DataMap& inputs, - ast::transform::DataMap& outputs) const { +Program Manager::Run(const Program* program, + const transform::DataMap& inputs, + transform::DataMap& outputs) const { #if TINT_PRINT_PROGRAM_FOR_EACH_TRANSFORM auto print_program = [&](const char* msg, const Transform* transform) { auto wgsl = Program::printer(program); @@ -56,25 +57,38 @@ ast::transform::Transform::ApplyResult Manager::Apply(const Program* program, 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(); + if (auto* ast_transform = transform->As()) { + if (auto result = ast_transform->Apply(program, inputs, outputs)) { + output.emplace(std::move(result.value())); + program = &output.value(); - if (!program->IsValid()) { - TINT_IF_PRINT_PROGRAM(print_program("Invalid output of", transform.get())); - break; + if (!program->IsValid()) { + TINT_IF_PRINT_PROGRAM(print_program("Invalid output of", transform.get())); + break; + } + + 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("Output of", transform.get())); } else { - TINT_IF_PRINT_PROGRAM(std::cout << "Skipped " << transform->TypeInfo().name - << std::endl); + ProgramBuilder b; + TINT_ICE(Transform, b.Diagnostics()) << "unhandled transform type"; + return Program(std::move(b)); } } TINT_IF_PRINT_PROGRAM(print_program("Final output of", this)); - return output; + if (!output) { + ProgramBuilder b; + CloneContext ctx{&b, program, /* auto_clone_symbols */ true}; + ctx.Clone(); + output = Program(std::move(b)); + } + + return std::move(output.value()); } } // namespace tint::transform diff --git a/src/tint/transform/manager.h b/src/tint/transform/manager.h index c7b9286d46..2df5785305 100644 --- a/src/tint/transform/manager.h +++ b/src/tint/transform/manager.h @@ -19,7 +19,7 @@ #include #include -#include "src/tint/ast/transform/transform.h" +#include "src/tint/transform/transform.h" namespace tint::transform { @@ -27,11 +27,11 @@ namespace tint::transform { /// The inner transforms will execute in the appended order. /// If any inner transform fails the manager will return immediately and /// the error can be retrieved with the Output's diagnostics. -class Manager final : public tint::utils::Castable { +class Manager { public: /// Constructor Manager(); - ~Manager() override; + ~Manager(); /// Add pass to the manager /// @param transform the transform to append @@ -47,10 +47,12 @@ class Manager final : public tint::utils::Castable(std::forward(args)...)); } - /// @copydoc ast::transform::Transform::Apply - ApplyResult Apply(const Program* program, - const ast::transform::DataMap& inputs, - ast::transform::DataMap& outputs) const override; + /// Runs the transforms on @p program, returning the transformed clone of @p program. + /// @param program the source program to transform + /// @param inputs optional extra transform-specific input data + /// @param outputs optional extra transform-specific output data + /// @returns the transformed program + Program Run(const Program* program, const DataMap& inputs, DataMap& outputs) const; private: std::vector> transforms_; diff --git a/src/tint/transform/transform.cc b/src/tint/transform/transform.cc new file mode 100644 index 0000000000..657f9be66e --- /dev/null +++ b/src/tint/transform/transform.cc @@ -0,0 +1,37 @@ +// Copyright 2023 The Tint Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "src/tint/transform/transform.h" + +#include "src/tint/program_builder.h" + +TINT_INSTANTIATE_TYPEINFO(tint::transform::Transform); +TINT_INSTANTIATE_TYPEINFO(tint::transform::Data); + +namespace tint::transform { + +Data::Data() = default; +Data::Data(const Data&) = default; +Data::~Data() = default; +Data& Data::operator=(const Data&) = default; + +DataMap::DataMap() = default; +DataMap::DataMap(DataMap&&) = default; +DataMap::~DataMap() = default; +DataMap& DataMap::operator=(DataMap&&) = default; + +Transform::Transform() = default; +Transform::~Transform() = default; + +} // namespace tint::transform diff --git a/src/tint/transform/transform.h b/src/tint/transform/transform.h new file mode 100644 index 0000000000..1f8a3f5b10 --- /dev/null +++ b/src/tint/transform/transform.h @@ -0,0 +1,141 @@ +// Copyright 2023 The Tint Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef SRC_TINT_TRANSFORM_TRANSFORM_H_ +#define SRC_TINT_TRANSFORM_TRANSFORM_H_ + +#include +#include +#include + +#include "src/tint/program.h" +#include "src/tint/utils/castable.h" + +namespace tint::transform { + +/// Data is the base class for transforms that accept extra input or emit extra output information. +class Data : public utils::Castable { + public: + /// Constructor + Data(); + + /// Copy constructor + Data(const Data&); + + /// Destructor + ~Data() override; + + /// Assignment operator + /// @returns this Data + Data& operator=(const Data&); +}; + +/// DataMap is a map of Data unique pointers keyed by the Data's ClassID. +class DataMap { + public: + /// Constructor + DataMap(); + + /// Move constructor + DataMap(DataMap&&); + + /// Constructor + /// @param data_unique_ptrs a variadic list of additional data unique_ptrs produced by the + /// transform + template + explicit DataMap(DATA... data_unique_ptrs) { + PutAll(std::forward(data_unique_ptrs)...); + } + + /// Destructor + ~DataMap(); + + /// Move assignment operator + /// @param rhs the DataMap to move into this DataMap + /// @return this DataMap + DataMap& operator=(DataMap&& rhs); + + /// Adds the data into DataMap keyed by the ClassID of type T. + /// @param data the data to add to the DataMap + template + void Put(std::unique_ptr&& data) { + static_assert(std::is_base_of::value, "T does not derive from Data"); + map_[&utils::TypeInfo::Of()] = std::move(data); + } + + /// Creates the data of type `T` with the provided arguments and adds it into DataMap keyed by + /// the ClassID of type T. + /// @param args the arguments forwarded to the initializer for type T + template + void Add(ARGS&&... args) { + Put(std::make_unique(std::forward(args)...)); + } + + /// @returns a pointer to the Data placed into the DataMap with a call to Put() + template + T const* Get() const { + return const_cast(this)->Get(); + } + + /// @returns a pointer to the Data placed into the DataMap with a call to Put() + template + T* Get() { + auto it = map_.find(&utils::TypeInfo::Of()); + if (it == map_.end()) { + return nullptr; + } + return static_cast(it->second.get()); + } + + /// Add moves all the data from other into this DataMap + /// @param other the DataMap to move into this DataMap + void Add(DataMap&& other) { + for (auto& it : other.map_) { + map_.emplace(it.first, std::move(it.second)); + } + other.map_.clear(); + } + + private: + template + void PutAll(T0&& first) { + Put(std::forward(first)); + } + + template + void PutAll(T0&& first, Tn&&... remainder) { + Put(std::forward(first)); + PutAll(std::forward(remainder)...); + } + + std::unordered_map> map_; +}; + +/// Interface for transforms. +class Transform : public utils::Castable { + public: + /// @copydoc tint::transform::Data + using Data = tint::transform::Data; + /// @copydoc tint::transform::DataMap + using DataMap = tint::transform::DataMap; + + /// Constructor + Transform(); + /// Destructor + ~Transform() override; +}; + +} // namespace tint::transform + +#endif // SRC_TINT_TRANSFORM_TRANSFORM_H_ diff --git a/src/tint/writer/flatten_bindings.cc b/src/tint/writer/flatten_bindings.cc index 3aa659db59..fe262d60e9 100644 --- a/src/tint/writer/flatten_bindings.cc +++ b/src/tint/writer/flatten_bindings.cc @@ -63,16 +63,15 @@ std::optional FlattenBindings(const Program* program) { } // Run the binding remapper transform. - tint::ast::transform::Output transform_output; if (!binding_points.empty()) { tint::transform::Manager manager; - tint::ast::transform::DataMap inputs; + tint::transform::DataMap inputs; + tint::transform::DataMap outputs; inputs.Add( std::move(binding_points), tint::ast::transform::BindingRemapper::AccessControls{}, /* mayCollide */ true); manager.Add(); - transform_output = manager.Run(program, inputs); - return std::move(transform_output.program); + return manager.Run(program, inputs, outputs); } return {}; diff --git a/src/tint/writer/glsl/generator_impl.cc b/src/tint/writer/glsl/generator_impl.cc index d3d813007e..a15f6a96b7 100644 --- a/src/tint/writer/glsl/generator_impl.cc +++ b/src/tint/writer/glsl/generator_impl.cc @@ -152,7 +152,7 @@ SanitizedResult Sanitize(const Program* in, const Options& options, const std::string& entry_point) { transform::Manager manager; - ast::transform::DataMap data; + transform::DataMap data; manager.Add(); @@ -246,10 +246,9 @@ SanitizedResult Sanitize(const Program* in, data.Add( ast::transform::CanonicalizeEntryPointIO::ShaderStyle::kGlsl); - auto out = manager.Run(in, data); - SanitizedResult result; - result.program = std::move(out.program); + transform::DataMap outputs; + result.program = manager.Run(in, data, outputs); return result; } diff --git a/src/tint/writer/hlsl/generator_impl.cc b/src/tint/writer/hlsl/generator_impl.cc index c9ebddd855..95d2022589 100644 --- a/src/tint/writer/hlsl/generator_impl.cc +++ b/src/tint/writer/hlsl/generator_impl.cc @@ -167,7 +167,7 @@ SanitizedResult::SanitizedResult(SanitizedResult&&) = default; SanitizedResult Sanitize(const Program* in, const Options& options) { transform::Manager manager; - ast::transform::DataMap data; + transform::DataMap data; manager.Add(); @@ -305,11 +305,10 @@ SanitizedResult Sanitize(const Program* in, const Options& options) { ast::transform::CanonicalizeEntryPointIO::ShaderStyle::kHlsl); data.Add(options.root_constant_binding_point); - auto out = manager.Run(in, data); - SanitizedResult result; - result.program = std::move(out.program); - if (auto* res = out.data.Get()) { + transform::DataMap outputs; + result.program = manager.Run(in, data, outputs); + if (auto* res = outputs.Get()) { result.used_array_length_from_uniform_indices = std::move(res->used_size_indices); } return result; diff --git a/src/tint/writer/hlsl/test_helper.h b/src/tint/writer/hlsl/test_helper.h index e6453469a2..2f8e886759 100644 --- a/src/tint/writer/hlsl/test_helper.h +++ b/src/tint/writer/hlsl/test_helper.h @@ -87,16 +87,15 @@ class TestHelperBase : public BODY, public ProgramBuilder { }(); transform::Manager transform_manager; - ast::transform::DataMap transform_data; + transform::DataMap transform_data; + transform::DataMap outputs; transform_data.Add( ast::transform::Renamer::Target::kHlslKeywords, /* preserve_unicode */ true); transform_manager.Add(); - auto result = transform_manager.Run(&sanitized_result.program, transform_data); - [&]() { - ASSERT_TRUE(result.program.IsValid()) << formatter.format(result.program.Diagnostics()); - }(); - *program = std::move(result.program); + auto result = transform_manager.Run(&sanitized_result.program, transform_data, outputs); + [&]() { ASSERT_TRUE(result.IsValid()) << formatter.format(result.Diagnostics()); }(); + *program = std::move(result); gen_ = std::make_unique(program.get()); return *gen_; } diff --git a/src/tint/writer/msl/generator_impl.cc b/src/tint/writer/msl/generator_impl.cc index 23c39f3e13..55b9f8d88c 100644 --- a/src/tint/writer/msl/generator_impl.cc +++ b/src/tint/writer/msl/generator_impl.cc @@ -167,7 +167,7 @@ SanitizedResult::SanitizedResult(SanitizedResult&&) = default; SanitizedResult Sanitize(const Program* in, const Options& options) { transform::Manager manager; - ast::transform::DataMap data; + transform::DataMap data; manager.Add(); @@ -257,14 +257,13 @@ SanitizedResult Sanitize(const Program* in, const Options& options) { manager.Add(); manager.Add(); - auto out = manager.Run(in, data); - SanitizedResult result; - result.program = std::move(out.program); + transform::DataMap outputs; + result.program = manager.Run(in, data, outputs); if (!result.program.IsValid()) { return result; } - if (auto* res = out.data.Get()) { + if (auto* res = outputs.Get()) { result.used_array_length_from_uniform_indices = std::move(res->used_size_indices); } result.needs_storage_buffer_sizes = !result.used_array_length_from_uniform_indices.empty(); diff --git a/src/tint/writer/spirv/generator_impl.cc b/src/tint/writer/spirv/generator_impl.cc index 9df66efd03..1b227105e9 100644 --- a/src/tint/writer/spirv/generator_impl.cc +++ b/src/tint/writer/spirv/generator_impl.cc @@ -49,7 +49,7 @@ namespace tint::writer::spirv { SanitizedResult Sanitize(const Program* in, const Options& options) { transform::Manager manager; - ast::transform::DataMap data; + transform::DataMap data; if (options.clamp_frag_depth) { manager.Add(); @@ -166,7 +166,8 @@ SanitizedResult Sanitize(const Program* in, const Options& options) { options.emit_vertex_point_size)); SanitizedResult result; - result.program = std::move(manager.Run(in, data).program); + transform::DataMap outputs; + result.program = manager.Run(in, data, outputs); return result; }