Add codepaths for new tint::transform API

These are guarded by `#if DAWN_USE_NEW_TINT_TRANSFORM_API` preprocessor conditionals, this define will be added to the tint `transform.h` file, atomically switching code paths when the new API lands.

See https://dawn-review.googlesource.com/c/tint/+/34800 for the tint change.

Bug: tint:390
Bug: tint:389
Change-Id: I0f397550f921a46c5bb29b1e71aacfee19ec5dd3
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/34880
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2020-12-03 21:25:59 +00:00 committed by Commit Bot service account
parent 715f427d0c
commit 80baa39ffc
2 changed files with 32 additions and 0 deletions

View File

@ -271,8 +271,14 @@ namespace dawn_native {
tint::transform::Manager transformManager;
{
# if DAWN_USE_NEW_TINT_TRANSFORM_API // TODO(bclayton) - Remove once API migration is complete
auto transform = std::make_unique<tint::transform::VertexPulling>();
tint::transform::VertexStateDescriptor state;
# else // DAWN_USE_NEW_TINT_TRANSFORM_API
auto transform = std::make_unique<tint::transform::VertexPullingTransform>(&module);
auto state = std::make_unique<tint::transform::VertexStateDescriptor>();
# endif // DAWN_USE_NEW_TINT_TRANSFORM_API
for (uint32_t i = 0; i < vertexState.vertexBufferCount; ++i) {
auto& vertexBuffer = vertexState.vertexBuffers[i];
tint::transform::VertexBufferLayoutDescriptor layout;
@ -289,7 +295,11 @@ namespace dawn_native {
layout.attributes.push_back(std::move(attr));
}
# if DAWN_USE_NEW_TINT_TRANSFORM_API // TODO(bclayton) - Remove once API migration is complete
state.push_back(std::move(layout));
# else // DAWN_USE_NEW_TINT_TRANSFORM_API
state->vertex_buffers.push_back(std::move(layout));
# endif // DAWN_USE_NEW_TINT_TRANSFORM_API
}
transform->SetVertexState(std::move(state));
transform->SetEntryPoint(entryPoint);
@ -297,10 +307,20 @@ namespace dawn_native {
transformManager.append(std::move(transform));
}
# if DAWN_USE_NEW_TINT_TRANSFORM_API // TODO(bclayton) - Remove once API migration is complete
auto result = transformManager.Run(&module);
if (result.diagnostics.contains_errors()) {
errorStream << "Vertex pulling transform: "
<< tint::diag::Formatter{}.format(result.diagnostics);
return DAWN_VALIDATION_ERROR(errorStream.str().c_str());
}
module = std::move(result.module);
# else // DAWN_USE_NEW_TINT_TRANSFORM_API
if (!transformManager.Run(&module)) {
errorStream << "Vertex pulling transform: " << transformManager.error();
return DAWN_VALIDATION_ERROR(errorStream.str().c_str());
}
# endif // DAWN_USE_NEW_TINT_TRANSFORM_API
tint::TypeDeterminer type_determiner(&module);
if (!type_determiner.Determine()) {

View File

@ -221,6 +221,17 @@ namespace dawn_native { namespace d3d12 {
return DAWN_VALIDATION_ERROR(errorStream.str().c_str());
}
# if DAWN_USE_NEW_TINT_TRANSFORM_API // TODO(bclayton) - Remove once API migration is complete
tint::transform::Manager transformManager;
transformManager.append(std::make_unique<tint::transform::BoundArrayAccessors>());
auto result = transformManager.Run(&module);
if (result.diagnostics.contains_errors()) {
errorStream << "Bound Array Accessors Transform: "
<< tint::diag::Formatter{}.format(result.diagnostics);
return DAWN_VALIDATION_ERROR(errorStream.str().c_str());
}
module = std::move(result.module);
# else // DAWN_USE_NEW_TINT_TRANSFORM_API
tint::transform::Manager transformManager;
transformManager.append(
std::make_unique<tint::transform::BoundArrayAccessorsTransform>(&module));
@ -229,6 +240,7 @@ namespace dawn_native { namespace d3d12 {
<< std::endl;
return DAWN_VALIDATION_ERROR(errorStream.str().c_str());
}
# endif // DAWN_USE_NEW_TINT_TRANSFORM_API
ASSERT(remappedEntryPointName != nullptr);
tint::inspector::Inspector inspector(module);