filament
filament copied to clipboard
use metal DynamicLibrary to reduce loading time
Is your feature request related to a problem? Please describe.
Power up your shader pipeline with enhancements to the Metal shader compilation model — all leading to a dramatic reduction in Pipeline State Object (PSO) loading time, especially upon first launch. https://developer.apple.com/videos/play/wwdc2020/10615/
Describe the solution you'd like Cache compiled PSO to memory/files inside filament automatically.
Describe alternatives you've considered None.
OS and backend Apple only.
Filament never does IO on its own, for something like that to happen it would require adding an interface on Engine
that the app could implement to trigger the load/save of PSOs. We thought about it a few times but it hasn't been a priority since Android caches compiled GL shaders on behalf of the apps.
Thanks for the suggestion. Closing this for now as these techniques are only available with newer iOS versions.
I'm experiencing hideous (~10s) shader compilation times on first app launch on iOS (subsequent launches are fine, so I assume these have been cached).
I've seen similar reports on the Apple forum, and it seems Metal dynamic libraries are the official solution. While I'm exploring ways to address this, is it possible to extract Metal shader source from the ubershader archive to pass to a Metal dynamic library?
We have clients that need to support older iOS versions, so it's unlikely we'll support Metal dynamic libraries. However, we recently added a Material::compile
API which will asynchronously pre-compile shaders, which can help hide first app launch shader compilation times. We are working on supporting this API for Metal.
Thanks - that sounds like a good compromise solution. In the meantime, I'm just working round the compilation time by minimizing the number of material variants in the assets. I'll keep an eye open for future PRs for the Metal implementation for Material::compile
.