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:
parent
329c1c98fe
commit
4d9f2ca07d
|
@ -952,14 +952,6 @@ namespace dawn_native {
|
||||||
ResultOrError<tint::Program> RunTransforms(tint::transform::Transform* transform,
|
ResultOrError<tint::Program> RunTransforms(tint::transform::Transform* transform,
|
||||||
tint::Program* program) {
|
tint::Program* program) {
|
||||||
tint::transform::Transform::Output output = transform->Run(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()) {
|
if (!output.program.IsValid()) {
|
||||||
std::string err = "Tint program failure: " +
|
std::string err = "Tint program failure: " +
|
||||||
tint::diag::Formatter{}.format(output.program.Diagnostics());
|
tint::diag::Formatter{}.format(output.program.Diagnostics());
|
||||||
|
@ -972,8 +964,9 @@ namespace dawn_native {
|
||||||
const VertexStateDescriptor& vertexState,
|
const VertexStateDescriptor& vertexState,
|
||||||
const std::string& entryPoint,
|
const std::string& entryPoint,
|
||||||
BindGroupIndex pullingBufferBindingSet) {
|
BindGroupIndex pullingBufferBindingSet) {
|
||||||
auto transform = std::make_unique<tint::transform::VertexPulling>();
|
tint::transform::VertexPulling::Config cfg;
|
||||||
tint::transform::VertexStateDescriptor state;
|
cfg.entry_point_name = entryPoint;
|
||||||
|
cfg.pulling_group = static_cast<uint32_t>(pullingBufferBindingSet);
|
||||||
for (uint32_t i = 0; i < vertexState.vertexBufferCount; ++i) {
|
for (uint32_t i = 0; i < vertexState.vertexBufferCount; ++i) {
|
||||||
const auto& vertexBuffer = vertexState.vertexBuffers[i];
|
const auto& vertexBuffer = vertexState.vertexBuffers[i];
|
||||||
tint::transform::VertexBufferLayoutDescriptor layout;
|
tint::transform::VertexBufferLayoutDescriptor layout;
|
||||||
|
@ -990,12 +983,9 @@ namespace dawn_native {
|
||||||
layout.attributes.push_back(std::move(attr));
|
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));
|
return std::make_unique<tint::transform::VertexPulling>(cfg);
|
||||||
transform->SetEntryPoint(entryPoint);
|
|
||||||
transform->SetPullingBufferBindingSet(static_cast<uint32_t>(pullingBufferBindingSet));
|
|
||||||
return transform;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -208,29 +208,29 @@ namespace dawn_native { namespace d3d12 {
|
||||||
tint::transform::Manager transformManager;
|
tint::transform::Manager transformManager;
|
||||||
transformManager.append(std::make_unique<tint::transform::BoundArrayAccessors>());
|
transformManager.append(std::make_unique<tint::transform::BoundArrayAccessors>());
|
||||||
|
|
||||||
tint::transform::FirstIndexOffset* firstOffsetTransform = nullptr;
|
|
||||||
if (stage == SingleShaderStage::Vertex) {
|
if (stage == SingleShaderStage::Vertex) {
|
||||||
auto transformer = std::make_unique<tint::transform::FirstIndexOffset>(
|
transformManager.append(std::make_unique<tint::transform::FirstIndexOffset>(
|
||||||
layout->GetFirstIndexOffsetShaderRegister(),
|
layout->GetFirstIndexOffsetShaderRegister(),
|
||||||
layout->GetFirstIndexOffsetRegisterSpace());
|
layout->GetFirstIndexOffsetRegisterSpace()));
|
||||||
firstOffsetTransform = transformer.get();
|
|
||||||
transformManager.append(std::move(transformer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tint::Program program;
|
tint::transform::Transform::Output output = transformManager.Run(mTintProgram.get());
|
||||||
DAWN_TRY_ASSIGN(program, RunTransforms(&transformManager, mTintProgram.get()));
|
|
||||||
|
|
||||||
if (firstOffsetTransform != nullptr) {
|
tint::Program& program = output.program;
|
||||||
// Functions are only available after transform has been performed
|
if (!program.IsValid()) {
|
||||||
firstOffsetInfo->usesVertexIndex = firstOffsetTransform->HasVertexIndex();
|
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) {
|
if (firstOffsetInfo->usesVertexIndex) {
|
||||||
firstOffsetInfo->vertexIndexOffset = firstOffsetTransform->GetFirstVertexOffset();
|
firstOffsetInfo->vertexIndexOffset = data->first_vertex_offset;
|
||||||
}
|
}
|
||||||
|
firstOffsetInfo->usesInstanceIndex = data->has_instance_index;
|
||||||
firstOffsetInfo->usesInstanceIndex = firstOffsetTransform->HasInstanceIndex();
|
|
||||||
if (firstOffsetInfo->usesInstanceIndex) {
|
if (firstOffsetInfo->usesInstanceIndex) {
|
||||||
firstOffsetInfo->instanceIndexOffset =
|
firstOffsetInfo->instanceIndexOffset = data->first_instance_offset;
|
||||||
firstOffsetTransform->GetFirstInstanceOffset();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue