tint: Move to new transform API

tint::transform::Transform::Output::diagnostics is deprecated.
Diagnostics are now all in the Output::program.

Use the VertexPulling(const Config&) constructor instead of the setters. These are deprecated.

Change-Id: Icefb84719d4915550c1e554e6d0c6e06ebb05f5c
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/42266
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Ben Clayton 2021-02-26 20:25:38 +00:00 committed by Commit Bot service account
parent 329c1c98fe
commit 4d9f2ca07d
2 changed files with 20 additions and 30 deletions

View File

@ -952,14 +952,6 @@ namespace dawn_native {
ResultOrError<tint::Program> RunTransforms(tint::transform::Transform* transform,
tint::Program* program) {
tint::transform::Transform::Output output = transform->Run(program);
if (output.diagnostics.contains_errors()) {
// TODO(bclayton): Remove Transform::Output::diagnostics - just put diagnostics into
// output.program.
std::string err =
"Tint transform failure: " + tint::diag::Formatter{}.format(output.diagnostics);
return DAWN_VALIDATION_ERROR(err.c_str());
}
if (!output.program.IsValid()) {
std::string err = "Tint program failure: " +
tint::diag::Formatter{}.format(output.program.Diagnostics());
@ -972,8 +964,9 @@ namespace dawn_native {
const VertexStateDescriptor& vertexState,
const std::string& entryPoint,
BindGroupIndex pullingBufferBindingSet) {
auto transform = std::make_unique<tint::transform::VertexPulling>();
tint::transform::VertexStateDescriptor state;
tint::transform::VertexPulling::Config cfg;
cfg.entry_point_name = entryPoint;
cfg.pulling_group = static_cast<uint32_t>(pullingBufferBindingSet);
for (uint32_t i = 0; i < vertexState.vertexBufferCount; ++i) {
const auto& vertexBuffer = vertexState.vertexBuffers[i];
tint::transform::VertexBufferLayoutDescriptor layout;
@ -990,12 +983,9 @@ namespace dawn_native {
layout.attributes.push_back(std::move(attr));
}
state.push_back(std::move(layout));
cfg.vertex_state.push_back(std::move(layout));
}
transform->SetVertexState(std::move(state));
transform->SetEntryPoint(entryPoint);
transform->SetPullingBufferBindingSet(static_cast<uint32_t>(pullingBufferBindingSet));
return transform;
return std::make_unique<tint::transform::VertexPulling>(cfg);
}
#endif

View File

@ -208,29 +208,29 @@ namespace dawn_native { namespace d3d12 {
tint::transform::Manager transformManager;
transformManager.append(std::make_unique<tint::transform::BoundArrayAccessors>());
tint::transform::FirstIndexOffset* firstOffsetTransform = nullptr;
if (stage == SingleShaderStage::Vertex) {
auto transformer = std::make_unique<tint::transform::FirstIndexOffset>(
transformManager.append(std::make_unique<tint::transform::FirstIndexOffset>(
layout->GetFirstIndexOffsetShaderRegister(),
layout->GetFirstIndexOffsetRegisterSpace());
firstOffsetTransform = transformer.get();
transformManager.append(std::move(transformer));
layout->GetFirstIndexOffsetRegisterSpace()));
}
tint::Program program;
DAWN_TRY_ASSIGN(program, RunTransforms(&transformManager, mTintProgram.get()));
tint::transform::Transform::Output output = transformManager.Run(mTintProgram.get());
if (firstOffsetTransform != nullptr) {
// Functions are only available after transform has been performed
firstOffsetInfo->usesVertexIndex = firstOffsetTransform->HasVertexIndex();
tint::Program& program = output.program;
if (!program.IsValid()) {
auto err = tint::diag::Formatter{}.format(program.Diagnostics());
errorStream << "Tint program transform error: " << err << std::endl;
return DAWN_VALIDATION_ERROR(errorStream.str().c_str());
}
if (auto* data = output.data.Get<tint::transform::FirstIndexOffset::Data>()) {
firstOffsetInfo->usesVertexIndex = data->has_vertex_index;
if (firstOffsetInfo->usesVertexIndex) {
firstOffsetInfo->vertexIndexOffset = firstOffsetTransform->GetFirstVertexOffset();
firstOffsetInfo->vertexIndexOffset = data->first_vertex_offset;
}
firstOffsetInfo->usesInstanceIndex = firstOffsetTransform->HasInstanceIndex();
firstOffsetInfo->usesInstanceIndex = data->has_instance_index;
if (firstOffsetInfo->usesInstanceIndex) {
firstOffsetInfo->instanceIndexOffset =
firstOffsetTransform->GetFirstInstanceOffset();
firstOffsetInfo->instanceIndexOffset = data->first_instance_offset;
}
}