Migrate to new SPIR-V reader for WebGPU
jrprice opened this issue · 0 comments
Tint has a new SPIR-V frontend that has been completely rewritten to make use of its new intermediate representation. We are planning to remove the old path in the not-too-distant future, so we recommend migrating over to the new path to make sure that everything works for your use cases.
The new flow can be accessed like this:
tint::wgsl::writer::ProgramOptions wgslOptions = {
.allow_non_uniform_derivatives = true,
};
auto result = tint::SpirvToWgsl(spirv, wgslOptions);
if (result != tint::Success) {
// Adjust for your error handling as needed.
std::cerr << result.Failure().reason << std::endl;
return false;
}
// The WGSL shader string is now in result->wgsl
This requires requires an up-to-date Dawn. I tried to look into updating Filament's version of Dawn so that I could make the Tint changes myself but hit some issues, so probably better if someone from the Filament team takes a look instead.
One notable change is that there's no longer a situation where we generate any WGSL when there are failures in the SPIR-V frontend. This means the FILAMENT_WEBGPU_IGNORE_TNT_READ_ERRORS option doesn't make sense any more, and you also shouldn't need to strip out the temporary annotations that you saw (@stride(), etc).
Let us know if you hit any issues with the new flow.