ShaderModule: Use transform::Renamer

For sanitizing symbols.
Replaces use of Inspector::GetRemappedNameForEntryPoint()

Change-Id: I1e20f719e0e80c04c5c4e4ae52bdb47f8d0572f6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/43884
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Ben Clayton 2021-03-09 13:58:07 +00:00 committed by Commit Bot service account
parent 7c3b5740db
commit 7fe018c065
2 changed files with 32 additions and 11 deletions

View File

@ -207,19 +207,20 @@ namespace dawn_native { namespace d3d12 {
tint::transform::Manager transformManager;
transformManager.append(std::make_unique<tint::transform::BoundArrayAccessors>());
if (stage == SingleShaderStage::Vertex) {
transformManager.append(std::make_unique<tint::transform::FirstIndexOffset>(
layout->GetFirstIndexOffsetShaderRegister(),
layout->GetFirstIndexOffsetRegisterSpace()));
}
transformManager.append(std::make_unique<tint::transform::Renamer>());
transformManager.append(std::make_unique<tint::transform::Hlsl>());
tint::transform::Transform::Output output = transformManager.Run(mTintProgram.get());
tint::Program& program = output.program;
if (!program.IsValid()) {
auto err = tint::diag::Formatter{}.format(program.Diagnostics());
errorStream << "Tint program transform error: " << err << std::endl;
errorStream << "Tint program transform error: " << program.Diagnostics().str()
<< std::endl;
return DAWN_VALIDATION_ERROR(errorStream.str().c_str());
}
@ -234,9 +235,15 @@ namespace dawn_native { namespace d3d12 {
}
}
ASSERT(remappedEntryPointName != nullptr);
tint::inspector::Inspector inspector(&program);
*remappedEntryPointName = inspector.GetRemappedNameForEntryPoint(entryPointName);
if (auto* data = output.data.Get<tint::transform::Renamer::Data>()) {
auto it = data->remappings.find(entryPointName);
if (it == data->remappings.end()) {
return DAWN_VALIDATION_ERROR("Could not find remapped name for entry point.");
}
*remappedEntryPointName = it->second;
} else {
return DAWN_VALIDATION_ERROR("Transform output missing renamer data.");
}
tint::writer::hlsl::Generator generator(&program);
// TODO: Switch to GenerateEntryPoint once HLSL writer supports it.

View File

@ -87,13 +87,27 @@ namespace dawn_native { namespace metal {
}
}
transformManager.append(std::make_unique<tint::transform::BoundArrayAccessors>());
transformManager.append(std::make_unique<tint::transform::Renamer>());
transformManager.append(std::make_unique<tint::transform::Msl>());
tint::Program program;
DAWN_TRY_ASSIGN(program, RunTransforms(&transformManager, mTintProgram.get()));
tint::transform::Transform::Output output = transformManager.Run(mTintProgram.get());
ASSERT(remappedEntryPointName != nullptr);
tint::inspector::Inspector inspector(&program);
*remappedEntryPointName = inspector.GetRemappedNameForEntryPoint(entryPointName);
tint::Program& program = output.program;
if (!program.IsValid()) {
errorStream << "Tint program transform error: " << program.Diagnostics().str()
<< std::endl;
return DAWN_VALIDATION_ERROR(errorStream.str().c_str());
}
if (auto* data = output.data.Get<tint::transform::Renamer::Data>()) {
auto it = data->remappings.find(entryPointName);
if (it == data->remappings.end()) {
return DAWN_VALIDATION_ERROR("Could not find remapped name for entry point.");
}
*remappedEntryPointName = it->second;
} else {
return DAWN_VALIDATION_ERROR("Transform output missing renamer data.");
}
tint::writer::msl::Generator generator(&program);
if (!generator.Generate()) {