[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 <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
James Price 2023-05-17 01:21:45 +00:00 committed by Dawn LUCI CQ
parent a6d8e81371
commit 0e6534e44d
54 changed files with 980 additions and 853 deletions

View File

@ -1012,21 +1012,21 @@ RequiredBufferSizes ComputeRequiredBufferSizesForLayout(const EntryPointMetadata
return bufferSizes;
}
ResultOrError<tint::Program> RunTransforms(tint::ast::transform::Transform* transform,
ResultOrError<tint::Program> 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,

View File

@ -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<Extent3D> ValidateComputeStageWorkgroupSize(
RequiredBufferSizes ComputeRequiredBufferSizesForLayout(const EntryPointMetadata& entryPoint,
const PipelineLayoutBase* layout);
ResultOrError<tint::Program> RunTransforms(tint::ast::transform::Transform* transform,
ResultOrError<tint::Program> 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

View File

@ -144,7 +144,7 @@ ResultOrError<std::string> 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<tint::ast::transform::SingleEntryPoint>();
@ -173,7 +173,7 @@ ResultOrError<std::string> TranslateToHLSL(
}
tint::Program transformedProgram;
tint::ast::transform::DataMap transformOutputs;
tint::transform::DataMap transformOutputs;
{
TRACE_EVENT0(tracePlatform.UnsafeGetValue(), General, "RunTransforms");
DAWN_TRY_ASSIGN(transformedProgram,

View File

@ -207,7 +207,7 @@ ResultOrError<CacheResult<MslCompilation>> TranslateToMSL(
mslCompilation, device, std::move(req), MslCompilation::FromBlob,
[](MslCompilationRequest r) -> ResultOrError<MslCompilation> {
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<CacheResult<MslCompilation>> TranslateToMSL(
}
tint::Program program;
tint::ast::transform::DataMap transformOutputs;
tint::transform::DataMap transformOutputs;
{
TRACE_EVENT0(r.tracePlatform.UnsafeGetValue(), General, "RunTransforms");
DAWN_TRY_ASSIGN(program,

View File

@ -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<tint::ast::transform::SingleEntryPoint>();

View File

@ -195,7 +195,7 @@ ResultOrError<GLuint> ShaderModule::CompileShader(const OpenGLFunctions& gl,
compilationResult, GetDevice(), std::move(req), GLSLCompilation::FromBlob,
[](GLSLCompilationRequest r) -> ResultOrError<GLSLCompilation> {
tint::transform::Manager transformManager;
tint::ast::transform::DataMap transformInputs;
tint::transform::DataMap transformInputs;
if (r.substituteOverrideConfig) {
transformManager.Add<tint::ast::transform::SingleEntryPoint>();

View File

@ -273,7 +273,7 @@ ResultOrError<ShaderModule::ModuleAndSpirv> ShaderModule::GetHandleAndSpirv(
compilation, GetDevice(), std::move(req), CompiledSpirv::FromBlob,
[](SpirvCompilationRequest r) -> ResultOrError<CompiledSpirv> {
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::ModuleAndSpirv> 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,

View File

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

View File

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

View File

@ -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<ArrayLengthFromUniform::Config>(std::move(cfg));
EXPECT_FALSE(ShouldRun<ArrayLengthFromUniform>(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<ArrayLengthFromUniform::Config>(std::move(cfg));
EXPECT_FALSE(ShouldRun<ArrayLengthFromUniform>(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<ArrayLengthFromUniform::Config>(std::move(cfg));
EXPECT_TRUE(ShouldRun<ArrayLengthFromUniform>(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<ArrayLengthFromUniform::Config>(std::move(cfg));
auto got = Run<Unshadow, SimplifyPointers, ArrayLengthFromUniform>(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<ArrayLengthFromUniform::Config>(std::move(cfg));
auto got = Run<Unshadow, SimplifyPointers, ArrayLengthFromUniform>(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<ArrayLengthFromUniform::Config>(std::move(cfg));
auto got = Run<Unshadow, SimplifyPointers, ArrayLengthFromUniform>(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<ArrayLengthFromUniform::Config>(std::move(cfg));
auto got = Run<Unshadow, SimplifyPointers, ArrayLengthFromUniform>(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<ArrayLengthFromUniform::Config>(std::move(cfg));
auto got = Run<Unshadow, SimplifyPointers, ArrayLengthFromUniform>(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<ArrayLengthFromUniform::Config>(std::move(cfg));
auto got = Run<Unshadow, SimplifyPointers, ArrayLengthFromUniform>(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<ArrayLengthFromUniform::Config>(std::move(cfg));
auto got = Run<Unshadow, SimplifyPointers, ArrayLengthFromUniform>(src, data);

View File

@ -26,7 +26,7 @@ using BindingRemapperTest = TransformTest;
TEST_F(BindingRemapperTest, ShouldRunEmptyRemappings) {
auto* src = R"()";
DataMap data;
Transform::DataMap data;
data.Add<BindingRemapper::Remappings>(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::Remappings>(
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::Remappings>(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::Remappings>(BindingRemapper::BindingPoints{},
BindingRemapper::AccessControls{});
auto got = Run<BindingRemapper>(src, data);
@ -112,7 +112,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<BindingRemapper::Remappings>(
BindingRemapper::BindingPoints{
{{2, 1}, {1, 2}}, // Remap
@ -158,7 +158,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<BindingRemapper::Remappings>(
BindingRemapper::BindingPoints{},
BindingRemapper::AccessControls{
@ -200,7 +200,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<BindingRemapper::Remappings>(
BindingRemapper::BindingPoints{
{{2, 1}, {4, 5}},
@ -254,7 +254,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<BindingRemapper::Remappings>(
BindingRemapper::BindingPoints{
{{2, 1}, {1, 1}},
@ -316,7 +316,7 @@ fn f2() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<BindingRemapper::Remappings>(
BindingRemapper::BindingPoints{
{{2, 1}, {1, 1}},

View File

@ -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<BuiltinPolyfill::Config>(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<BuiltinPolyfill::Config>(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<BuiltinPolyfill::Config>(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<BuiltinPolyfill::Config>(builtins);
return data;
}
@ -505,7 +505,7 @@ fn f(coords : vec2<i32>, value : vec4<f32>) {
BuiltinPolyfill::Builtins builtins;
builtins.atanh = BuiltinPolyfill::Level::kFull;
builtins.bgra8unorm = true;
DataMap data;
Transform::DataMap data;
data.Add<BuiltinPolyfill::Config>(builtins);
auto got = Run<BuiltinPolyfill>(src, std::move(data));
@ -516,10 +516,10 @@ fn f(coords : vec2<i32>, value : vec4<f32>) {
////////////////////////////////////////////////////////////////////////////////
// bitshiftModulo
////////////////////////////////////////////////////////////////////////////////
DataMap polyfillBitshiftModulo() {
Transform::DataMap polyfillBitshiftModulo() {
BuiltinPolyfill::Builtins builtins;
builtins.bitshift_modulo = true;
DataMap data;
Transform::DataMap data;
data.Add<BuiltinPolyfill::Config>(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<BuiltinPolyfill::Config>(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<BuiltinPolyfill::Config>(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<BuiltinPolyfill::Config>(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<BuiltinPolyfill::Config>(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<BuiltinPolyfill::Config>(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<BuiltinPolyfill::Config>(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<BuiltinPolyfill::Config>(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<BuiltinPolyfill::Config>(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<BuiltinPolyfill::Config>(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<BuiltinPolyfill::Config>(builtins);
return data;
}
@ -3199,10 +3199,10 @@ fn f() {
////////////////////////////////////////////////////////////////////////////////
// reflect for vec2<f32>
////////////////////////////////////////////////////////////////////////////////
DataMap polyfillReflectVec2F32() {
Transform::DataMap polyfillReflectVec2F32() {
BuiltinPolyfill::Builtins builtins;
builtins.reflect_vec2_f32 = true;
DataMap data;
Transform::DataMap data;
data.Add<BuiltinPolyfill::Config>(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<BuiltinPolyfill::Config>(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<BuiltinPolyfill::Config>(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<BuiltinPolyfill::Config>(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<BuiltinPolyfill::Config>(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<BuiltinPolyfill::Config>(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<BuiltinPolyfill::Config>(builtins);
auto got = Run<BuiltinPolyfill>(src, std::move(data));

View File

@ -48,7 +48,7 @@ fn comp_main() {
auto* expect = src;
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -82,7 +82,7 @@ fn frag_main() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kSpirv);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -117,7 +117,7 @@ fn frag_main(@builtin(position) coord : vec4<f32>, tint_symbol : tint_symbol_1)
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -154,7 +154,7 @@ fn frag_main(tint_symbol : tint_symbol_1) {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -189,7 +189,7 @@ fn frag_main(tint_symbol : tint_symbol_1) {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(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::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -277,7 +277,7 @@ fn frag_main() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kSpirv);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -330,7 +330,7 @@ struct FragLocations {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kSpirv);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -384,7 +384,7 @@ fn frag_main(@builtin(position) coord : vec4<f32>, tint_symbol : tint_symbol_1)
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -438,7 +438,7 @@ struct FragLocations {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -494,7 +494,7 @@ fn frag_main(tint_symbol : tint_symbol_1) {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -550,7 +550,7 @@ struct FragLocations {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -579,7 +579,7 @@ fn frag_main() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kSpirv);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -613,7 +613,7 @@ fn frag_main() -> tint_symbol {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -647,7 +647,7 @@ fn frag_main() -> tint_symbol {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -702,7 +702,7 @@ fn frag_main() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kSpirv);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -757,7 +757,7 @@ struct FragOutput {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kSpirv);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -817,7 +817,7 @@ fn frag_main() -> tint_symbol {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -877,7 +877,7 @@ struct FragOutput {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -937,7 +937,7 @@ fn frag_main() -> tint_symbol {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -997,7 +997,7 @@ struct FragOutput {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -1063,7 +1063,7 @@ fn frag_main2() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kSpirv);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -1129,7 +1129,7 @@ struct FragmentInput {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kSpirv);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -1201,7 +1201,7 @@ fn frag_main2(tint_symbol_2 : tint_symbol_3) {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -1273,7 +1273,7 @@ struct FragmentInput {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -1345,7 +1345,7 @@ fn frag_main2(tint_symbol_2 : tint_symbol_3) {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -1417,7 +1417,7 @@ struct FragmentInput {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -1484,7 +1484,7 @@ fn frag_main1(tint_symbol : tint_symbol_1) {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -1551,7 +1551,7 @@ struct FragmentInput {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(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::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -1723,7 +1723,7 @@ struct FragmentOutput {
alias myf32 = f32;
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -1814,7 +1814,7 @@ fn frag_main(tint_symbol_1 : tint_symbol_2) {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -1905,7 +1905,7 @@ struct FragmentIn {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -2035,7 +2035,7 @@ fn frag_main() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kSpirv);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -2165,7 +2165,7 @@ struct FragmentInterface {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kSpirv);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -2229,7 +2229,7 @@ fn main2() -> tint_symbol_1 {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -2293,7 +2293,7 @@ struct VertexOut {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(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::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -2427,7 +2427,7 @@ struct FragmentOutput {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -2531,7 +2531,7 @@ fn frag_main(tint_symbol_1 : tint_symbol_2) {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -2635,7 +2635,7 @@ struct FragmentInputExtra {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -2664,7 +2664,7 @@ fn tint_symbol_1(tint_symbol : tint_symbol_2) {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -2696,7 +2696,7 @@ fn frag_main() -> tint_symbol {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0x03u);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -2730,7 +2730,7 @@ fn frag_main() -> tint_symbol {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0x03u);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -2764,7 +2764,7 @@ fn frag_main() -> tint_symbol {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0x03u);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -2801,7 +2801,7 @@ fn frag_main() -> tint_symbol {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0x03u);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -2853,7 +2853,7 @@ fn frag_main() -> tint_symbol {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0x03u);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -2905,7 +2905,7 @@ struct Output {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0x03u);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -2955,7 +2955,7 @@ fn frag_main() -> tint_symbol {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0x03u);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -3005,7 +3005,7 @@ struct Output {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0x03u);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -3094,7 +3094,7 @@ fn comp_main1() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0x03u);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -3144,7 +3144,7 @@ fn frag_main() -> tint_symbol {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl, 0x03);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -3176,7 +3176,7 @@ fn vert_main() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kSpirv,
0xFFFFFFFF, true);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -3214,7 +3214,7 @@ fn vert_main() -> tint_symbol {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl,
0xFFFFFFFF, true);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -3255,7 +3255,7 @@ fn vert_main() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kSpirv,
0xFFFFFFFF, true);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -3296,7 +3296,7 @@ struct VertOut {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kSpirv,
0xFFFFFFFF, true);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -3342,7 +3342,7 @@ fn vert_main() -> tint_symbol {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl,
0xFFFFFFFF, true);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -3388,7 +3388,7 @@ struct VertOut {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl,
0xFFFFFFFF, true);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -3466,7 +3466,7 @@ fn vert_main() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kSpirv,
0xFFFFFFFF, true);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -3544,7 +3544,7 @@ struct VertOut {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kSpirv,
0xFFFFFFFF, true);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(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::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl,
0xFFFFFFFF, true);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -3696,7 +3696,7 @@ struct VertOut {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kMsl,
0xFFFFFFFF, true);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(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::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl,
0xFFFFFFFF, true);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -3848,7 +3848,7 @@ struct VertOut {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl,
0xFFFFFFFF, true);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -3884,7 +3884,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kSpirv);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -3919,7 +3919,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kGlsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);
@ -3956,7 +3956,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kGlsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO>(src, data);

View File

@ -28,7 +28,7 @@ TEST_F(CombineSamplersTest, EmptyModule) {
auto* src = "";
auto* expect = "";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(CombineSamplers::BindingMap(), sem::BindingPoint());
auto got = Run<CombineSamplers>(src, data);
@ -55,7 +55,7 @@ fn main() -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(CombineSamplers::BindingMap(), sem::BindingPoint());
auto got = Run<CombineSamplers>(src, data);
@ -82,7 +82,7 @@ fn main() -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(CombineSamplers::BindingMap(), sem::BindingPoint());
auto got = Run<CombineSamplers>(src, data);
@ -117,7 +117,7 @@ fn main() -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(CombineSamplers::BindingMap(), sem::BindingPoint());
auto got = Run<CombineSamplers>(src, data);
@ -152,7 +152,7 @@ fn sample(t_s_1 : texture_2d<f32>, coords : vec2<f32>) -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(CombineSamplers::BindingMap(), sem::BindingPoint());
auto got = Run<CombineSamplers>(src, data);
@ -179,7 +179,7 @@ fn main() -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
CombineSamplers::BindingMap map;
sem::SamplerTexturePair pair;
pair.texture_binding_point.group = 0;
@ -214,7 +214,7 @@ fn main() -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
CombineSamplers::BindingMap map;
sem::SamplerTexturePair pair;
pair.texture_binding_point.group = 3;
@ -262,7 +262,7 @@ fn main() -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(CombineSamplers::BindingMap(), sem::BindingPoint());
auto got = Run<CombineSamplers>(src, data);
@ -300,7 +300,7 @@ fn sample(t_s_1 : texture_2d<f32>, coords : vec2<f32>) -> vec4<f32> {
alias Tex2d = texture_2d<f32>;
)";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(CombineSamplers::BindingMap(), sem::BindingPoint());
auto got = Run<CombineSamplers>(src, data);
@ -343,7 +343,7 @@ fn main() -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(CombineSamplers::BindingMap(), sem::BindingPoint());
auto got = Run<CombineSamplers>(src, data);
@ -385,7 +385,7 @@ fn g(t_s_2 : texture_2d<f32>, coords : vec2<f32>) -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(CombineSamplers::BindingMap(), sem::BindingPoint());
auto got = Run<CombineSamplers>(src, data);
@ -428,7 +428,7 @@ fn main() -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(CombineSamplers::BindingMap(), sem::BindingPoint());
auto got = Run<CombineSamplers>(src, data);
@ -491,7 +491,7 @@ fn main() -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(CombineSamplers::BindingMap(), sem::BindingPoint());
auto got = Run<CombineSamplers>(src, data);
@ -538,7 +538,7 @@ fn main() -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(CombineSamplers::BindingMap(), sem::BindingPoint());
auto got = Run<CombineSamplers>(src, data);
@ -585,7 +585,7 @@ fn main() -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(CombineSamplers::BindingMap(), sem::BindingPoint());
auto got = Run<CombineSamplers>(src, data);
@ -624,7 +624,7 @@ fn main() -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(CombineSamplers::BindingMap(), sem::BindingPoint());
auto got = Run<CombineSamplers>(src, data);
@ -661,7 +661,7 @@ fn f(tex_s1 : texture_2d<f32>, tex_s2 : texture_2d<f32>, coords : vec2<f32>) ->
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(CombineSamplers::BindingMap(), sem::BindingPoint());
auto got = Run<CombineSamplers>(src, data);
@ -700,7 +700,7 @@ fn main() -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(CombineSamplers::BindingMap(), sem::BindingPoint());
auto got = Run<CombineSamplers>(src, data);
@ -737,7 +737,7 @@ fn f(t1_samp : texture_2d<f32>, t2_samp : texture_2d<f32>, coords : vec2<f32>) -
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(CombineSamplers::BindingMap(), sem::BindingPoint());
auto got = Run<CombineSamplers>(src, data);
@ -776,7 +776,7 @@ fn main() -> vec4<f32> {
pair.sampler_binding_point.binding = placeholder.binding;
CombineSamplers::BindingMap map;
map[pair] = "fred";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(map, placeholder);
auto got = Run<CombineSamplers>(src, data);
@ -820,7 +820,7 @@ fn main() -> vec4<f32> {
CombineSamplers::BindingMap map;
map[pair] = "barney";
map[placeholder_pair] = "fred";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(map, placeholder);
auto got = Run<CombineSamplers>(src, data);
@ -847,7 +847,7 @@ fn main() -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(CombineSamplers::BindingMap(), sem::BindingPoint());
auto got = Run<CombineSamplers>(src, data);
@ -882,7 +882,7 @@ fn main() -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(CombineSamplers::BindingMap(), sem::BindingPoint());
auto got = Run<CombineSamplers>(src, data);
@ -916,7 +916,7 @@ fn f(t_s : texture_depth_2d, coords : vec2<f32>) -> f32 {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(CombineSamplers::BindingMap(), sem::BindingPoint());
auto got = Run<CombineSamplers>(src, data);
@ -947,7 +947,7 @@ fn main() -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(CombineSamplers::BindingMap(), sem::BindingPoint());
auto got = Run<CombineSamplers>(src, data);
@ -977,7 +977,7 @@ fn main() -> vec4<f32> {
@internal(disable_validation__binding_point_collision) @group(0) @binding(0) var<uniform> gcoords : vec2<f32>;
)";
DataMap data;
Transform::DataMap data;
data.Add<CombineSamplers::BindingInfo>(CombineSamplers::BindingMap(), sem::BindingPoint());
auto got = Run<CombineSamplers>(src, data);

View File

@ -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<DirectVariableAccess::Config>(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<DirectVariableAccess::Config>(opts);
return inputs;
}

View File

@ -62,7 +62,7 @@ class FirstIndexOffset final : public utils::Castable<FirstIndexOffset, Transfor
/// BindingPoint is consumed by the FirstIndexOffset transform.
/// BindingPoint specifies the binding point of the first index uniform
/// buffer.
struct BindingPoint final : public utils::Castable<BindingPoint, transform::Data> {
struct BindingPoint final : public utils::Castable<BindingPoint, Transform::Data> {
/// Constructor
BindingPoint();
@ -82,7 +82,7 @@ class FirstIndexOffset final : public utils::Castable<FirstIndexOffset, Transfor
/// Data is outputted by the FirstIndexOffset transform.
/// Data holds information about shader usage and constant buffer offsets.
struct Data final : public utils::Castable<Data, transform::Data> {
struct Data final : public utils::Castable<Data, Transform::Data> {
/// Constructor
/// @param has_vtx_or_inst_index True if the shader uses vertex_index or
/// instance_index

View File

@ -57,7 +57,7 @@ TEST_F(FirstIndexOffsetTest, EmptyModule) {
auto* src = "";
auto* expect = "";
DataMap config;
Transform::DataMap config;
config.Add<FirstIndexOffset::BindingPoint>(0, 0);
auto got = Run<FirstIndexOffset>(src, std::move(config));
@ -77,7 +77,7 @@ fn entry() -> @builtin(position) vec4<f32> {
)";
auto* expect = src;
DataMap config;
Transform::DataMap config;
config.Add<FirstIndexOffset::BindingPoint>(0, 0);
auto got = Run<FirstIndexOffset>(src, std::move(config));
@ -121,7 +121,7 @@ fn entry(@builtin(vertex_index) vert_idx : u32) -> @builtin(position) vec4<f32>
}
)";
DataMap config;
Transform::DataMap config;
config.Add<FirstIndexOffset::BindingPoint>(1, 2);
auto got = Run<FirstIndexOffset>(src, std::move(config));
@ -165,7 +165,7 @@ fn test(vert_idx : u32) -> u32 {
}
)";
DataMap config;
Transform::DataMap config;
config.Add<FirstIndexOffset::BindingPoint>(1, 2);
auto got = Run<FirstIndexOffset>(src, std::move(config));
@ -209,7 +209,7 @@ fn entry(@builtin(instance_index) inst_idx : u32) -> @builtin(position) vec4<f32
}
)";
DataMap config;
Transform::DataMap config;
config.Add<FirstIndexOffset::BindingPoint>(1, 7);
auto got = Run<FirstIndexOffset>(src, std::move(config));
@ -253,7 +253,7 @@ fn test(inst_idx : u32) -> u32 {
}
)";
DataMap config;
Transform::DataMap config;
config.Add<FirstIndexOffset::BindingPoint>(1, 7);
auto got = Run<FirstIndexOffset>(src, std::move(config));
@ -309,7 +309,7 @@ fn entry(inputs : Inputs) -> @builtin(position) vec4<f32> {
}
)";
DataMap config;
Transform::DataMap config;
config.Add<FirstIndexOffset::BindingPoint>(1, 2);
auto got = Run<FirstIndexOffset>(src, std::move(config));
@ -365,7 +365,7 @@ fn test(instance_idx : u32, vert_idx : u32) -> u32 {
}
)";
DataMap config;
Transform::DataMap config;
config.Add<FirstIndexOffset::BindingPoint>(1, 2);
auto got = Run<FirstIndexOffset>(src, std::move(config));
@ -417,7 +417,7 @@ fn entry(@builtin(vertex_index) vert_idx : u32) -> @builtin(position) vec4<f32>
}
)";
DataMap config;
Transform::DataMap config;
config.Add<FirstIndexOffset::BindingPoint>(1, 2);
auto got = Run<FirstIndexOffset>(src, std::move(config));
@ -469,7 +469,7 @@ fn func1(vert_idx : u32) -> u32 {
}
)";
DataMap config;
Transform::DataMap config;
config.Add<FirstIndexOffset::BindingPoint>(1, 2);
auto got = Run<FirstIndexOffset>(src, std::move(config));
@ -537,7 +537,7 @@ fn entry_c(@builtin(instance_index) inst_idx : u32) -> @builtin(position) vec4<f
}
)";
DataMap config;
Transform::DataMap config;
config.Add<FirstIndexOffset::BindingPoint>(1, 2);
auto got = Run<FirstIndexOffset>(src, std::move(config));
@ -605,7 +605,7 @@ fn func(i : u32) -> u32 {
}
)";
DataMap config;
Transform::DataMap config;
config.Add<FirstIndexOffset::BindingPoint>(1, 2);
auto got = Run<FirstIndexOffset>(src, std::move(config));

View File

@ -23,7 +23,7 @@ using MultiplanarExternalTextureTest = TransformTest;
TEST_F(MultiplanarExternalTextureTest, ShouldRunEmptyModule) {
auto* src = R"()";
DataMap data;
Transform::DataMap data;
data.Add<MultiplanarExternalTexture::NewBindingPoints>(
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::NewBindingPoints>(
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::NewBindingPoints>(
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::NewBindingPoints>(
MultiplanarExternalTexture::BindingsMap{{{0, 0}, {{0, 1}, {0, 2}}}});
@ -98,7 +98,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
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<MultiplanarExternalTexture::NewBindingPoints>(
@ -156,7 +156,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<MultiplanarExternalTexture::NewBindingPoints>(
MultiplanarExternalTexture::BindingsMap{{{0, 0}, {{0, 1}, {0, 2}}}});
auto got = Run<MultiplanarExternalTexture>(src, data);
@ -212,7 +212,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
@group(0) @binding(0) var ext_tex : texture_2d<f32>;
)";
DataMap data;
Transform::DataMap data;
data.Add<MultiplanarExternalTexture::NewBindingPoints>(
MultiplanarExternalTexture::BindingsMap{{{0, 0}, {{0, 1}, {0, 2}}}});
auto got = Run<MultiplanarExternalTexture>(src, data);
@ -296,7 +296,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<MultiplanarExternalTexture::NewBindingPoints>(
MultiplanarExternalTexture::BindingsMap{{{0, 1}, {{0, 2}, {0, 3}}}});
auto got = Run<MultiplanarExternalTexture>(src, data);
@ -380,7 +380,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
@group(0) @binding(0) var s : sampler;
)";
DataMap data;
Transform::DataMap data;
data.Add<MultiplanarExternalTexture::NewBindingPoints>(
MultiplanarExternalTexture::BindingsMap{{{0, 1}, {{0, 2}, {0, 3}}}});
auto got = Run<MultiplanarExternalTexture>(src, data);
@ -475,7 +475,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<MultiplanarExternalTexture::NewBindingPoints>(
MultiplanarExternalTexture::BindingsMap{{{0, 0}, {{0, 1}, {0, 2}}}});
auto got = Run<MultiplanarExternalTexture>(src, data);
@ -570,7 +570,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
@group(0) @binding(0) var ext_tex : texture_2d<f32>;
)";
DataMap data;
Transform::DataMap data;
data.Add<MultiplanarExternalTexture::NewBindingPoints>(
MultiplanarExternalTexture::BindingsMap{{{0, 0}, {{0, 1}, {0, 2}}}});
auto got = Run<MultiplanarExternalTexture>(src, data);
@ -670,7 +670,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<MultiplanarExternalTexture::NewBindingPoints>(
MultiplanarExternalTexture::BindingsMap{{{0, 1}, {{0, 2}, {0, 3}}}});
auto got = Run<MultiplanarExternalTexture>(src, data);
@ -770,7 +770,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
@group(0) @binding(1) var ext_tex : texture_2d<f32>;
)";
DataMap data;
Transform::DataMap data;
data.Add<MultiplanarExternalTexture::NewBindingPoints>(
MultiplanarExternalTexture::BindingsMap{{{0, 1}, {{0, 2}, {0, 3}}}});
auto got = Run<MultiplanarExternalTexture>(src, data);
@ -878,7 +878,7 @@ fn main(@builtin(position) coord : vec4<f32>) -> @location(0) vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<MultiplanarExternalTexture::NewBindingPoints>(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::NewBindingPoints>(MultiplanarExternalTexture::BindingsMap{
{{0, 0}, {{0, 2}, {0, 3}}},
});
@ -1067,7 +1067,7 @@ fn f(t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1
@group(0) @binding(1) var smp : sampler;
)";
DataMap data;
Transform::DataMap data;
data.Add<MultiplanarExternalTexture::NewBindingPoints>(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::NewBindingPoints>(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::NewBindingPoints>(MultiplanarExternalTexture::BindingsMap{
{{0, 0}, {{0, 3}, {0, 4}}},
{{0, 2}, {{0, 5}, {0, 6}}},
@ -1366,7 +1366,7 @@ fn f(t : texture_2d<f32>, ext_tex_plane_1_2 : texture_2d<f32>, ext_tex_params_2
@group(0) @binding(2) var ext_tex2 : texture_2d<f32>;
)";
DataMap data;
Transform::DataMap data;
data.Add<MultiplanarExternalTexture::NewBindingPoints>(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::NewBindingPoints>(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::NewBindingPoints>(MultiplanarExternalTexture::BindingsMap{
{{0, 0}, {{0, 2}, {0, 3}}},
});
@ -1613,7 +1613,7 @@ fn f(ext_tex : texture_2d<f32>, ext_tex_plane_1 : texture_2d<f32>, ext_tex_param
}
)";
DataMap data;
Transform::DataMap data;
data.Add<MultiplanarExternalTexture::NewBindingPoints>(
MultiplanarExternalTexture::BindingsMap{{{0, 0}, {{0, 1}, {0, 2}}}});
auto got = Run<MultiplanarExternalTexture>(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::NewBindingPoints>(MultiplanarExternalTexture::BindingsMap{
{{0, 0}, {{0, 2}, {0, 3}}},
});
@ -1804,7 +1804,7 @@ fn f(t : texture_2d<f32>, ext_tex_plane_1_1 : texture_2d<f32>, ext_tex_params_1
alias ET = texture_external;
)";
DataMap data;
Transform::DataMap data;
data.Add<MultiplanarExternalTexture::NewBindingPoints>(MultiplanarExternalTexture::BindingsMap{
{{0, 0}, {{0, 2}, {0, 3}}},
});

View File

@ -28,7 +28,7 @@ using NumWorkgroupsFromUniformTest = TransformTest;
TEST_F(NumWorkgroupsFromUniformTest, ShouldRunEmptyModule) {
auto* src = R"()";
DataMap data;
Transform::DataMap data;
data.Add<NumWorkgroupsFromUniform::Config>(sem::BindingPoint{0, 30u});
EXPECT_FALSE(ShouldRun<NumWorkgroupsFromUniform>(src, data));
}
@ -40,7 +40,7 @@ fn main(@builtin(num_workgroups) num_wgs : vec3<u32>) {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<NumWorkgroupsFromUniform::Config>(sem::BindingPoint{0, 30u});
EXPECT_TRUE(ShouldRun<NumWorkgroupsFromUniform>(src, data));
}
@ -55,7 +55,7 @@ fn main(@builtin(num_workgroups) num_wgs : vec3<u32>) {
auto* expect =
"error: missing transform data for tint::ast::transform::NumWorkgroupsFromUniform";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
auto got = Run<Unshadow, CanonicalizeEntryPointIO, NumWorkgroupsFromUniform>(src, data);
EXPECT_EQ(expect, str(got));
@ -90,7 +90,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
data.Add<NumWorkgroupsFromUniform::Config>(sem::BindingPoint{0, 30u});
auto got = Run<Unshadow, CanonicalizeEntryPointIO, NumWorkgroupsFromUniform>(src, data);
@ -134,7 +134,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
data.Add<NumWorkgroupsFromUniform::Config>(sem::BindingPoint{0, 30u});
auto got = Run<Unshadow, CanonicalizeEntryPointIO, NumWorkgroupsFromUniform>(src, data);
@ -178,7 +178,7 @@ struct Builtins {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
data.Add<NumWorkgroupsFromUniform::Config>(sem::BindingPoint{0, 30u});
auto got = Run<Unshadow, CanonicalizeEntryPointIO, NumWorkgroupsFromUniform>(src, data);
@ -233,7 +233,7 @@ fn main(tint_symbol : tint_symbol_1) {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
data.Add<NumWorkgroupsFromUniform::Config>(sem::BindingPoint{0, 30u});
auto got = Run<Unshadow, CanonicalizeEntryPointIO, NumWorkgroupsFromUniform>(src, data);
@ -289,7 +289,7 @@ struct Builtins {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
data.Add<NumWorkgroupsFromUniform::Config>(sem::BindingPoint{0, 30u});
auto got = Run<Unshadow, CanonicalizeEntryPointIO, NumWorkgroupsFromUniform>(src, data);
@ -388,7 +388,7 @@ fn main3() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
data.Add<NumWorkgroupsFromUniform::Config>(sem::BindingPoint{0, 30u});
auto got = Run<Unshadow, CanonicalizeEntryPointIO, NumWorkgroupsFromUniform>(src, data);
@ -429,7 +429,7 @@ fn main(tint_symbol : tint_symbol_1) {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
data.Add<NumWorkgroupsFromUniform::Config>(sem::BindingPoint{0, 30u});
auto got = Run<Unshadow, CanonicalizeEntryPointIO, NumWorkgroupsFromUniform>(src, data);
@ -530,7 +530,7 @@ fn main3() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
// Make binding point unspecified.
data.Add<NumWorkgroupsFromUniform::Config>(std::nullopt);
@ -684,7 +684,7 @@ fn main3() {
}
)";
DataMap data;
Transform::DataMap data;
data.Add<CanonicalizeEntryPointIO::Config>(CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
// Make binding point unspecified.
data.Add<NumWorkgroupsFromUniform::Config>(std::nullopt);

File diff suppressed because it is too large Load Diff

View File

@ -28,7 +28,7 @@ TEST_F(PadStructsTest, EmptyModule) {
auto* src = "";
auto* expect = src;
DataMap data;
Transform::DataMap data;
auto got = Run<PadStructs>(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<PadStructs>(src, data);
EXPECT_EQ(expect, str(got));
@ -97,7 +97,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PadStructs>(src, data);
EXPECT_EQ(expect, str(got));
@ -137,7 +137,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PadStructs>(src, data);
EXPECT_EQ(expect, str(got));
@ -179,7 +179,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PadStructs>(src, data);
EXPECT_EQ(expect, str(got));
@ -219,7 +219,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PadStructs>(src, data);
EXPECT_EQ(expect, str(got));
@ -254,7 +254,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PadStructs>(src, data);
EXPECT_EQ(expect, str(got));
@ -300,7 +300,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PadStructs>(src, data);
EXPECT_EQ(expect, str(got));
@ -350,7 +350,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PadStructs>(src, data);
EXPECT_EQ(expect, str(got));
@ -396,7 +396,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PadStructs>(src, data);
EXPECT_EQ(expect, str(got));
@ -433,7 +433,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PadStructs>(src, data);
EXPECT_EQ(expect, str(got));
@ -477,7 +477,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PadStructs>(src, data);
EXPECT_EQ(expect, str(got));
@ -524,7 +524,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PadStructs>(src, data);
EXPECT_EQ(expect, str(got));
@ -561,7 +561,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PadStructs>(src, data);
EXPECT_EQ(expect, str(got));
@ -598,7 +598,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PadStructs>(src, data);
EXPECT_EQ(expect, str(got));

View File

@ -672,7 +672,7 @@ Transform::ApplyResult PromoteSideEffectsToDecl::Apply(const Program* src,
tint::transform::Manager manager;
manager.Add<SimplifySideEffectStatements>();
manager.Add<DecomposeSideEffects>();
return manager.Apply(src, inputs, outputs);
return manager.Run(src, inputs, outputs);
}
} // namespace tint::ast::transform

View File

@ -25,7 +25,7 @@ TEST_F(PromoteSideEffectsToDeclTest, EmptyModule) {
auto* src = "";
auto* expect = "";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -44,7 +44,7 @@ fn f() {
auto* expect = src;
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -81,7 +81,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -111,7 +111,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -142,7 +142,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -176,7 +176,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -211,7 +211,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -248,7 +248,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -278,7 +278,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -306,7 +306,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -338,7 +338,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -370,7 +370,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -401,7 +401,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -433,7 +433,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -467,7 +467,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -489,7 +489,7 @@ fn f() {
auto* expect = src;
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -532,7 +532,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -566,7 +566,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -608,7 +608,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -645,7 +645,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -679,7 +679,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -716,7 +716,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -757,7 +757,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -789,7 +789,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -820,7 +820,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -861,7 +861,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -900,7 +900,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -944,7 +944,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -998,7 +998,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1037,7 +1037,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1077,7 +1077,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1137,7 +1137,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1168,7 +1168,7 @@ fn f() -> i32 {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1205,7 +1205,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1238,7 +1238,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1271,7 +1271,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1302,7 +1302,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1347,7 +1347,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1384,7 +1384,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1429,7 +1429,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1468,7 +1468,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1509,7 +1509,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1548,7 +1548,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1585,7 +1585,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1628,7 +1628,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1685,7 +1685,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1732,7 +1732,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1779,7 +1779,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1818,7 +1818,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1859,7 +1859,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1906,7 +1906,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1946,7 +1946,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -1984,7 +1984,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2031,7 +2031,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2079,7 +2079,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2113,7 +2113,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2146,7 +2146,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2190,7 +2190,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2232,7 +2232,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2279,7 +2279,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2342,7 +2342,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2384,7 +2384,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2427,7 +2427,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2492,7 +2492,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2517,7 +2517,7 @@ fn f() {
auto* expect = src;
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2555,7 +2555,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2593,7 +2593,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2634,7 +2634,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2680,7 +2680,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2712,7 +2712,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2747,7 +2747,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2778,7 +2778,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2805,7 +2805,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2835,7 +2835,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2866,7 +2866,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2898,7 +2898,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2933,7 +2933,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2963,7 +2963,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -2995,7 +2995,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3027,7 +3027,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3069,7 +3069,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3099,7 +3099,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3132,7 +3132,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3161,7 +3161,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3200,7 +3200,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3264,7 +3264,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3295,7 +3295,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3325,7 +3325,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3355,7 +3355,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3385,7 +3385,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3417,7 +3417,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3450,7 +3450,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3484,7 +3484,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3515,7 +3515,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3547,7 +3547,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3580,7 +3580,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3614,7 +3614,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3651,7 +3651,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3688,7 +3688,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3724,7 +3724,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3760,7 +3760,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3806,7 +3806,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3824,7 +3824,7 @@ fn f() {
auto* expect = src;
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3873,7 +3873,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3922,7 +3922,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -3970,7 +3970,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -4018,7 +4018,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -4079,7 +4079,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));
@ -4127,7 +4127,7 @@ fn m() -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<PromoteSideEffectsToDecl>(src, data);
EXPECT_EQ(expect, str(got));

View File

@ -101,7 +101,7 @@ TEST_F(RemoveContinueInSwitchTest, EmptyModule) {
auto* src = "";
auto* expect = src;
DataMap data;
Transform::DataMap data;
auto got = Run<RemoveContinueInSwitch>(src, data);
EXPECT_EQ(expect, str(got));
@ -163,7 +163,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<RemoveContinueInSwitch>(src, data);
EXPECT_EQ(expect, str(got));
@ -247,7 +247,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<RemoveContinueInSwitch>(src, data);
EXPECT_EQ(expect, str(got));
@ -332,7 +332,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<RemoveContinueInSwitch>(src, data);
EXPECT_EQ(expect, str(got));
@ -423,7 +423,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<RemoveContinueInSwitch>(src, data);
EXPECT_EQ(expect, str(got));
@ -501,7 +501,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<RemoveContinueInSwitch>(src, data);
EXPECT_EQ(expect, str(got));
@ -553,7 +553,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<RemoveContinueInSwitch>(src, data);
EXPECT_EQ(expect, str(got));
@ -607,7 +607,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<RemoveContinueInSwitch>(src, data);
EXPECT_EQ(expect, str(got));

View File

@ -27,7 +27,7 @@ class Renamer final : public utils::Castable<Renamer, Transform> {
public:
/// Data is outputted by the Renamer transform.
/// Data holds information about shader usage and constant buffer offsets.
struct Data final : public utils::Castable<Data, transform::Data> {
struct Data final : public utils::Castable<Data, tint::transform::Data> {
/// Remappings is a map of old symbol name to new symbol name
using Remappings = std::unordered_map<std::string, std::string>;
@ -59,7 +59,7 @@ class Renamer final : public utils::Castable<Renamer, Transform> {
/// Optional configuration options for the transform.
/// If omitted, then the renamer will use Target::kAll.
struct Config final : public utils::Castable<Config, transform::Data> {
struct Config final : public utils::Castable<Config, tint::transform::Data> {
/// Constructor
/// @param tgt the targets to rename
/// @param keep_unicode if false, symbols with non-ascii code-points are

View File

@ -245,7 +245,7 @@ fn frag_main() {
auto expect = src;
DataMap inputs;
Transform::DataMap inputs;
inputs.Add<Renamer::Config>(Renamer::Target::kMslKeywords,
/* preserve_unicode */ true);
auto got = Run<Renamer>(src, inputs);
@ -269,7 +269,7 @@ fn tint_symbol() {
}
)";
DataMap inputs;
Transform::DataMap inputs;
inputs.Add<Renamer::Config>(Renamer::Target::kAll,
/* preserve_unicode */ true);
auto got = Run<Renamer>(src, inputs);
@ -379,7 +379,7 @@ fn frag_main() {
}
)";
DataMap inputs;
Transform::DataMap inputs;
inputs.Add<Renamer::Config>(Renamer::Target::kGlslKeywords,
/* preserve_unicode */ false);
auto got = Run<Renamer>(src, inputs);
@ -405,7 +405,7 @@ fn frag_main() {
}
)";
DataMap inputs;
Transform::DataMap inputs;
inputs.Add<Renamer::Config>(Renamer::Target::kHlslKeywords,
/* preserve_unicode */ false);
auto got = Run<Renamer>(src, inputs);
@ -431,7 +431,7 @@ fn frag_main() {
}
)";
DataMap inputs;
Transform::DataMap inputs;
inputs.Add<Renamer::Config>(Renamer::Target::kMslKeywords,
/* preserve_unicode */ false);
auto got = Run<Renamer>(src, inputs);

View File

@ -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<Robustness::Config>(cfg);
return data;
}

View File

@ -38,7 +38,7 @@ TEST_F(SingleEntryPointTest, Error_NoEntryPoints) {
auto* expect = "error: entry point 'main' not found";
DataMap data;
Transform::DataMap data;
data.Add<SingleEntryPoint::Config>("main");
auto got = Run<SingleEntryPoint>(src, data);
@ -57,7 +57,7 @@ fn main() -> @builtin(position) vec4<f32> {
SingleEntryPoint::Config cfg("_");
DataMap data;
Transform::DataMap data;
data.Add<SingleEntryPoint::Config>(cfg);
auto got = Run<SingleEntryPoint>(src, data);
@ -76,7 +76,7 @@ fn main() {}
SingleEntryPoint::Config cfg("foo");
DataMap data;
Transform::DataMap data;
data.Add<SingleEntryPoint::Config>(cfg);
auto got = Run<SingleEntryPoint>(src, data);
@ -92,7 +92,7 @@ fn main() {
SingleEntryPoint::Config cfg("main");
DataMap data;
Transform::DataMap data;
data.Add<SingleEntryPoint::Config>(cfg);
auto got = Run<SingleEntryPoint>(src, data);
@ -127,7 +127,7 @@ fn comp_main1() {
SingleEntryPoint::Config cfg("comp_main1");
DataMap data;
Transform::DataMap data;
data.Add<SingleEntryPoint::Config>(cfg);
auto got = Run<SingleEntryPoint>(src, data);
@ -177,7 +177,7 @@ fn comp_main1() {
SingleEntryPoint::Config cfg("comp_main1");
DataMap data;
Transform::DataMap data;
data.Add<SingleEntryPoint::Config>(cfg);
auto got = Run<SingleEntryPoint>(src, data);
@ -233,7 +233,7 @@ fn comp_main1() {
SingleEntryPoint::Config cfg("comp_main1");
DataMap data;
Transform::DataMap data;
data.Add<SingleEntryPoint::Config>(cfg);
auto got = Run<SingleEntryPoint>(src, data);
@ -253,7 +253,7 @@ fn main() {
SingleEntryPoint::Config cfg("main");
DataMap data;
Transform::DataMap data;
data.Add<SingleEntryPoint::Config>(cfg);
auto got = Run<SingleEntryPoint>(src, data);
@ -303,7 +303,7 @@ fn comp_main1() {
let local_d = c1;
}
)";
DataMap data;
Transform::DataMap data;
data.Add<SingleEntryPoint::Config>(cfg);
auto got = Run<SingleEntryPoint>(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<SingleEntryPoint::Config>(cfg);
auto got = Run<SingleEntryPoint>(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<SingleEntryPoint::Config>(cfg);
auto got = Run<SingleEntryPoint>(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<SingleEntryPoint::Config>(cfg);
auto got = Run<SingleEntryPoint>(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<SingleEntryPoint::Config>(cfg);
auto got = Run<SingleEntryPoint>(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<SingleEntryPoint::Config>(cfg);
auto got = Run<SingleEntryPoint>(src, data);
EXPECT_EQ(expect, str(got));
@ -440,7 +440,7 @@ fn main() {
)";
SingleEntryPoint::Config cfg("main");
DataMap data;
Transform::DataMap data;
data.Add<SingleEntryPoint::Config>(cfg);
auto got = Run<SingleEntryPoint>(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<SingleEntryPoint::Config>(cfg);
auto got = Run<SingleEntryPoint>(src, data);
@ -581,7 +581,7 @@ fn comp_main1() {
SingleEntryPoint::Config cfg("comp_main1");
DataMap data;
Transform::DataMap data;
data.Add<SingleEntryPoint::Config>(cfg);
auto got = Run<SingleEntryPoint>(src, data);
@ -604,7 +604,7 @@ fn main() {
SingleEntryPoint::Config cfg("main");
DataMap data;
Transform::DataMap data;
data.Add<SingleEntryPoint::Config>(cfg);
auto got = Run<SingleEntryPoint>(src, data);
@ -624,7 +624,7 @@ fn main() {
SingleEntryPoint::Config cfg("main");
DataMap data;
Transform::DataMap data;
data.Add<SingleEntryPoint::Config>(cfg);
auto got = Run<SingleEntryPoint>(src, data);

View File

@ -32,7 +32,7 @@ fn main() -> @builtin(position) vec4<f32> {
auto* expect = "error: Missing override substitution data";
DataMap data;
Transform::DataMap data;
auto got = Run<SubstituteOverride>(src, data);
EXPECT_EQ(expect, str(got));
@ -50,7 +50,7 @@ fn main() -> @builtin(position) vec4<f32> {
auto* expect = "error: Initializer not provided for override, and override not overridden.";
SubstituteOverride::Config cfg;
DataMap data;
Transform::DataMap data;
data.Add<SubstituteOverride::Config>(cfg);
auto got = Run<SubstituteOverride>(src, data);
@ -75,7 +75,7 @@ fn main() -> @builtin(position) vec4<f32> {
SubstituteOverride::Config cfg;
DataMap data;
Transform::DataMap data;
data.Add<SubstituteOverride::Config>(cfg);
auto got = Run<SubstituteOverride>(src, data);
@ -143,7 +143,7 @@ fn main() -> @builtin(position) vec4<f32> {
cfg.map.insert({OverrideId{6}, 1.0});
cfg.map.insert({OverrideId{7}, 0.0});
DataMap data;
Transform::DataMap data;
data.Add<SubstituteOverride::Config>(cfg);
auto got = Run<SubstituteOverride>(src, data);
@ -212,7 +212,7 @@ fn main() -> @builtin(position) vec4<f32> {
cfg.map.insert({OverrideId{7}, 0.0});
cfg.map.insert({OverrideId{5}, 13});
DataMap data;
Transform::DataMap data;
data.Add<SubstituteOverride::Config>(cfg);
auto got = Run<SubstituteOverride>(src, data);
@ -241,7 +241,7 @@ fn main() -> @builtin(position) vec4<f32> {
SubstituteOverride::Config cfg;
cfg.map.insert({OverrideId{0}, 11.0});
DataMap data;
Transform::DataMap data;
data.Add<SubstituteOverride::Config>(cfg);
auto got = Run<SubstituteOverride>(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<SubstituteOverride::Config>(cfg);
auto got = Run<SubstituteOverride>(src, data);

View File

@ -21,6 +21,7 @@
#include <vector>
#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::Transform> transform,
const DataMap& data = {}) {
const tint::transform::DataMap& data = {}) {
std::vector<std::unique_ptr<transform::Transform>> 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 <typename... TRANSFORMS>
Output Run(std::string in, const DataMap& data = {}) {
Output Run(std::string in, const tint::transform::DataMap& data = {}) {
auto file = std::make_unique<Source::File>("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 <typename... TRANSFORMS>
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<Transform*>{new TRANSFORMS()...}) {
manager.append(std::unique_ptr<Transform>(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 <typename TRANSFORM>
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 <typename TRANSFORM>
bool ShouldRun(std::string in, const DataMap& data = {}) {
bool ShouldRun(std::string in, const tint::transform::DataMap& data = {}) {
auto file = std::make_unique<Source::File>("test", in);
auto program = reader::wgsl::Parse(file.get());
return ShouldRun<TRANSFORM>(std::move(program), data);

View File

@ -23,7 +23,7 @@ using Texture1DTo2DTest = TransformTest;
TEST_F(Texture1DTo2DTest, EmptyModule) {
auto* src = "";
DataMap data;
Transform::DataMap data;
EXPECT_FALSE(ShouldRun<Texture1DTo2D>(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<Texture1DTo2D>(src, data);
EXPECT_EQ(expect, str(got));
@ -65,7 +65,7 @@ fn main() -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<Texture1DTo2D>(src, data);
EXPECT_EQ(expect, str(got));
@ -87,7 +87,7 @@ fn main() -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<Texture1DTo2D>(src, data);
EXPECT_EQ(expect, str(got));
@ -109,7 +109,7 @@ fn main() -> u32 {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<Texture1DTo2D>(src, data);
EXPECT_EQ(expect, str(got));
@ -131,7 +131,7 @@ fn main() -> u32 {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<Texture1DTo2D>(src, data);
EXPECT_EQ(expect, str(got));
@ -153,7 +153,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<Texture1DTo2D>(src, data);
EXPECT_EQ(expect, str(got));
@ -167,7 +167,7 @@ TEST_F(Texture1DTo2DTest, GlobalStorage1DDecl) {
@group(0) @binding(0) var t : texture_storage_2d<r32float, write>;
)";
DataMap data;
Transform::DataMap data;
auto got = Run<Texture1DTo2D>(src, data);
EXPECT_EQ(expect, str(got));
@ -184,7 +184,7 @@ fn main() -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
EXPECT_FALSE(ShouldRun<Texture1DTo2D>(src, data));
}
@ -193,7 +193,7 @@ TEST_F(Texture1DTo2DTest, PrivateIntNoop) {
var<private> i : i32;
)";
DataMap data;
Transform::DataMap data;
EXPECT_FALSE(ShouldRun<Texture1DTo2D>(src, data));
}
@ -202,7 +202,7 @@ TEST_F(Texture1DTo2DTest, GlobalMatrixNoop) {
@group(0) @binding(0) var<uniform> m : mat2x2<f32>;
)";
DataMap data;
Transform::DataMap data;
EXPECT_FALSE(ShouldRun<Texture1DTo2D>(src, data));
}
@ -234,7 +234,7 @@ fn main() -> vec4<f32> {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<Texture1DTo2D>(src, data);
EXPECT_EQ(expect, str(got));
@ -265,7 +265,7 @@ fn main() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<Texture1DTo2D>(src, data);
EXPECT_EQ(expect, str(got));
@ -290,7 +290,7 @@ fn d() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<Texture1DTo2D>(src, data);
EXPECT_EQ(expect, str(got));

View File

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

View File

@ -15,8 +15,8 @@
#ifndef SRC_TINT_AST_TRANSFORM_TRANSFORM_H_
#define SRC_TINT_AST_TRANSFORM_TRANSFORM_H_
#include <memory>
#include <unordered_map>
#include "src/tint/transform/transform.h"
#include <utility>
#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<Data> {
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 <typename... DATA>
explicit DataMap(DATA... data_unique_ptrs) {
PutAll(std::forward<DATA>(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 <typename T>
void Put(std::unique_ptr<T>&& data) {
static_assert(std::is_base_of<Data, T>::value, "T does not derive from Data");
map_[&utils::TypeInfo::Of<T>()] = 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 <typename T, typename... ARGS>
void Add(ARGS&&... args) {
Put(std::make_unique<T>(std::forward<ARGS>(args)...));
}
/// @returns a pointer to the Data placed into the DataMap with a call to
/// Put()
template <typename T>
T const* Get() const {
return const_cast<DataMap*>(this)->Get<T>();
}
/// @returns a pointer to the Data placed into the DataMap with a call to
/// Put()
template <typename T>
T* Get() {
auto it = map_.find(&utils::TypeInfo::Of<T>());
if (it == map_.end()) {
return nullptr;
}
return static_cast<T*>(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 <typename T0>
void PutAll(T0&& first) {
Put(std::forward<T0>(first));
}
template <typename T0, typename... Tn>
void PutAll(T0&& first, Tn&&... remainder) {
Put(std::forward<T0>(first));
PutAll(std::forward<Tn>(remainder)...);
}
std::unordered_map<const utils::TypeInfo*, std::unique_ptr<Data>> 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<Transform> {
class Transform : public utils::Castable<Transform, tint::transform::Transform> {
public:
/// Constructor
Transform();

View File

@ -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<TruncateInterstageVariables::Config>(cfg);
EXPECT_TRUE(ShouldRun<TruncateInterstageVariables>(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<TruncateInterstageVariables::Config>(cfg);
EXPECT_FALSE(ShouldRun<TruncateInterstageVariables>(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<TruncateInterstageVariables::Config>(cfg);
EXPECT_TRUE(ShouldRun<TruncateInterstageVariables>(src, data));
}
@ -91,7 +91,7 @@ fn f(io: ShaderIO) -> @location(1) vec4<f32> {
TruncateInterstageVariables::Config cfg;
cfg.interstage_locations[2] = true;
DataMap data;
Transform::DataMap data;
data.Add<TruncateInterstageVariables::Config>(cfg);
EXPECT_FALSE(ShouldRun<TruncateInterstageVariables>(src, data));
@ -109,7 +109,7 @@ fn f() -> @builtin(position) vec4<f32> {
TruncateInterstageVariables::Config cfg;
cfg.interstage_locations[0] = true;
DataMap data;
Transform::DataMap data;
data.Add<TruncateInterstageVariables::Config>(cfg);
data.Add<CanonicalizeEntryPointIO::Config>(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<TruncateInterstageVariables::Config>(cfg);
auto got = Run<TruncateInterstageVariables>(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<TruncateInterstageVariables::Config>(cfg);
auto got = Run<TruncateInterstageVariables>(src, data);
@ -279,7 +279,7 @@ fn f() -> tint_symbol {
)";
TruncateInterstageVariables::Config cfg;
DataMap data;
Transform::DataMap data;
data.Add<TruncateInterstageVariables::Config>(cfg);
auto got = Run<TruncateInterstageVariables>(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<TruncateInterstageVariables::Config>(cfg);
auto got = Run<TruncateInterstageVariables>(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<TruncateInterstageVariables::Config>(cfg);
auto got = Run<TruncateInterstageVariables>(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<TruncateInterstageVariables::Config>(cfg);
auto got = Run<TruncateInterstageVariables>(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<TruncateInterstageVariables::Config>(cfg);
auto got = Run<TruncateInterstageVariables>(src, data);

View File

@ -49,7 +49,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<VarForDynamicIndex>(src, data);
EXPECT_EQ(expect, str(got));
@ -73,7 +73,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<VarForDynamicIndex>(src, data);
EXPECT_EQ(expect, str(got));
@ -105,7 +105,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<VarForDynamicIndex>(src, data);
EXPECT_EQ(expect, str(got));
@ -138,7 +138,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<VarForDynamicIndex>(src, data);
EXPECT_EQ(expect, str(got));
@ -171,7 +171,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<VarForDynamicIndex>(src, data);
EXPECT_EQ(expect, str(got));
@ -204,7 +204,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<VarForDynamicIndex>(src, data);
EXPECT_EQ(expect, str(got));
@ -237,7 +237,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<VarForDynamicIndex>(src, data);
EXPECT_EQ(expect, str(got));
@ -277,7 +277,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<VarForDynamicIndex>(src, data);
EXPECT_EQ(expect, str(got));
@ -311,7 +311,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<VarForDynamicIndex>(src, data);
EXPECT_EQ(expect, str(got));
@ -364,7 +364,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<VarForDynamicIndex>(src, data);
EXPECT_EQ(expect, str(got));
@ -398,7 +398,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<VarForDynamicIndex>(src, data);
EXPECT_EQ(expect, str(got));
@ -451,7 +451,7 @@ fn f() {
}
)";
DataMap data;
Transform::DataMap data;
auto got = Run<VarForDynamicIndex>(src, data);
EXPECT_EQ(expect, str(got));
@ -467,7 +467,7 @@ fn f() {
auto* expect = src;
DataMap data;
Transform::DataMap data;
auto got = Run<VarForDynamicIndex>(src, data);
EXPECT_EQ(expect, str(got));
@ -483,7 +483,7 @@ fn f() {
auto* expect = src;
DataMap data;
Transform::DataMap data;
auto got = Run<VarForDynamicIndex>(src, data);
EXPECT_EQ(expect, str(got));
@ -501,7 +501,7 @@ fn f() {
auto* expect = src;
DataMap data;
Transform::DataMap data;
auto got = Run<VarForDynamicIndex>(src, data);
EXPECT_EQ(expect, str(got));
@ -519,7 +519,7 @@ fn f() {
auto* expect = src;
DataMap data;
Transform::DataMap data;
auto got = Run<VarForDynamicIndex>(src, data);
EXPECT_EQ(expect, str(got));
@ -537,7 +537,7 @@ fn f() {
auto* expect = src;
DataMap data;
Transform::DataMap data;
auto got = Run<VarForDynamicIndex>(src, data);
EXPECT_EQ(expect, str(got));
@ -553,7 +553,7 @@ fn f() {
auto* expect = src;
DataMap data;
Transform::DataMap data;
auto got = Run<VarForDynamicIndex>(src, data);
EXPECT_EQ(expect, str(got));

View File

@ -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<VertexPulling::Config>();
auto got = Run<VertexPulling>(src, data);
@ -51,7 +51,7 @@ fn main2() -> @builtin(position) vec4<f32> {
VertexPulling::Config cfg;
DataMap data;
Transform::DataMap data;
data.Add<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(src, data);
@ -68,7 +68,7 @@ fn main() {}
VertexPulling::Config cfg;
DataMap data;
Transform::DataMap data;
data.Add<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(src, data);
@ -90,7 +90,7 @@ fn main(@location(0) var_a : f32) -> @builtin(position) vec4<f32> {
VertexPulling::Config cfg;
cfg.vertex_state = {{{15, VertexStepMode::kVertex, {{VertexFormat::kFloat32, 0, 0}}}}};
DataMap data;
Transform::DataMap data;
data.Add<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(src, data);
@ -118,7 +118,7 @@ fn main() -> @builtin(position) vec4<f32> {
VertexPulling::Config cfg;
DataMap data;
Transform::DataMap data;
data.Add<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(src, data);
@ -407,7 +407,7 @@ fn main(tint_symbol_1 : tint_symbol) -> @builtin(position) vec4<f32> {
},
}};
DataMap data;
Transform::DataMap data;
data.Add<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(src, data);
@ -485,7 +485,7 @@ struct Inputs {
},
}};
DataMap data;
Transform::DataMap data;
data.Add<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(src, data);
@ -560,7 +560,7 @@ fn main(indices : Indices) -> @builtin(position) vec4<f32> {
},
}};
DataMap data;
Transform::DataMap data;
data.Add<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(src, data);
@ -635,7 +635,7 @@ struct Indices {
},
}};
DataMap data;
Transform::DataMap data;
data.Add<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(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<VertexPulling::Config>(cfg);
auto got = Run<VertexPulling>(src, data);

View File

@ -947,32 +947,30 @@ int main(int argc, const char** argv) {
/// Returns true on success, false on error (program will immediately exit)
std::function<bool(tint::inspector::Inspector& inspector,
tint::transform::Manager& manager,
tint::ast::transform::DataMap& inputs)>
tint::transform::DataMap& inputs)>
make;
};
std::vector<TransformFactory> 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<tint::ast::transform::FirstIndexOffset::BindingPoint>(0, 0);
m.Add<tint::ast::transform::FirstIndexOffset>();
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<tint::ast::transform::Renamer>();
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<tint::OverrideId, double> 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<tint::ast::transform::SingleEntryPoint::Config>(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) {

View File

@ -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};

View File

@ -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_;

View File

@ -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<ast::transform::SubstituteOverride::Config>(cfg);
transform::Manager mgr;
mgr.append(std::make_unique<ast::transform::SubstituteOverride>());
auto out = mgr.Run(&program, override_data);
transform::DataMap outputs;
auto out = mgr.Run(&program, override_data, outputs);
if (!validate_program(out)) {
return 0;
}

View File

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

View File

@ -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);
}

View File

@ -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_; }

View File

@ -57,13 +57,14 @@ Program Parse(const std::vector<uint32_t>& input, const Options& options) {
}
transform::Manager manager;
transform::DataMap outputs;
manager.Add<ast::transform::Unshadow>();
manager.Add<ast::transform::SimplifyPointers>();
manager.Add<ast::transform::DecomposeStridedMatrix>();
manager.Add<ast::transform::DecomposeStridedArray>();
manager.Add<ast::transform::RemoveUnreachableStatements>();
manager.Add<ast::transform::SpirvAtomic>();
return manager.Run(&program).program;
return manager.Run(&program, {}, outputs);
}
} // namespace tint::reader::spirv

View File

@ -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<ast::transform::Transform>()) {
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

View File

@ -19,7 +19,7 @@
#include <utility>
#include <vector>
#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<Manager, ast::transform::Transform> {
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<Manager, ast::transform::Tran
transforms_.emplace_back(std::make_unique<T>(std::forward<ARGS>(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<std::unique_ptr<Transform>> transforms_;

View File

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

View File

@ -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 <memory>
#include <unordered_map>
#include <utility>
#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<Data> {
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 <typename... DATA>
explicit DataMap(DATA... data_unique_ptrs) {
PutAll(std::forward<DATA>(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 <typename T>
void Put(std::unique_ptr<T>&& data) {
static_assert(std::is_base_of<Data, T>::value, "T does not derive from Data");
map_[&utils::TypeInfo::Of<T>()] = 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 <typename T, typename... ARGS>
void Add(ARGS&&... args) {
Put(std::make_unique<T>(std::forward<ARGS>(args)...));
}
/// @returns a pointer to the Data placed into the DataMap with a call to Put()
template <typename T>
T const* Get() const {
return const_cast<DataMap*>(this)->Get<T>();
}
/// @returns a pointer to the Data placed into the DataMap with a call to Put()
template <typename T>
T* Get() {
auto it = map_.find(&utils::TypeInfo::Of<T>());
if (it == map_.end()) {
return nullptr;
}
return static_cast<T*>(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 <typename T0>
void PutAll(T0&& first) {
Put(std::forward<T0>(first));
}
template <typename T0, typename... Tn>
void PutAll(T0&& first, Tn&&... remainder) {
Put(std::forward<T0>(first));
PutAll(std::forward<Tn>(remainder)...);
}
std::unordered_map<const utils::TypeInfo*, std::unique_ptr<Data>> map_;
};
/// Interface for transforms.
class Transform : public utils::Castable<Transform> {
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_

View File

@ -63,16 +63,15 @@ std::optional<Program> 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<tint::ast::transform::BindingRemapper::Remappings>(
std::move(binding_points), tint::ast::transform::BindingRemapper::AccessControls{},
/* mayCollide */ true);
manager.Add<tint::ast::transform::BindingRemapper>();
transform_output = manager.Run(program, inputs);
return std::move(transform_output.program);
return manager.Run(program, inputs, outputs);
}
return {};

View File

@ -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<ast::transform::DisableUniformityAnalysis>();
@ -246,10 +246,9 @@ SanitizedResult Sanitize(const Program* in,
data.Add<ast::transform::CanonicalizeEntryPointIO::Config>(
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;
}

View File

@ -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<ast::transform::DisableUniformityAnalysis>();
@ -305,11 +305,10 @@ SanitizedResult Sanitize(const Program* in, const Options& options) {
ast::transform::CanonicalizeEntryPointIO::ShaderStyle::kHlsl);
data.Add<ast::transform::NumWorkgroupsFromUniform::Config>(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<ast::transform::ArrayLengthFromUniform::Result>()) {
transform::DataMap outputs;
result.program = manager.Run(in, data, outputs);
if (auto* res = outputs.Get<ast::transform::ArrayLengthFromUniform::Result>()) {
result.used_array_length_from_uniform_indices = std::move(res->used_size_indices);
}
return result;

View File

@ -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::Config>(
ast::transform::Renamer::Target::kHlslKeywords,
/* preserve_unicode */ true);
transform_manager.Add<tint::ast::transform::Renamer>();
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<GeneratorImpl>(program.get());
return *gen_;
}

View File

@ -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<ast::transform::DisableUniformityAnalysis>();
@ -257,14 +257,13 @@ SanitizedResult Sanitize(const Program* in, const Options& options) {
manager.Add<ast::transform::PackedVec3>();
manager.Add<ast::transform::ModuleScopeVarToEntryPointParam>();
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<ast::transform::ArrayLengthFromUniform::Result>()) {
if (auto* res = outputs.Get<ast::transform::ArrayLengthFromUniform::Result>()) {
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();

View File

@ -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<tint::ast::transform::ClampFragDepth>();
@ -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;
}