Pipeline compilation performance in MoltenVK #1789
Replies: 1 comment 1 reply
-
Currently, pipeline caching in MoltenVK is limited to archiving/reloading the shader MSL source, after conversion from SPIR-V. It does not cache either the compiled MSL or the Metal pipeline state in binary form. When pipeline caching was introduced to MoltenVK, this was then only option, as Metal did not yet support binary pipeline archives, or shader caching. Metal has since moved on, and now provides both, at some level. Issue #1765 identifies the requirement to incorporate the newer Metal capabilities, and is where we are tracking this development.
Yes. Shader compilation in MoltenVK supports this. |
Beta Was this translation helpful? Give feedback.
-
Hey,
I'm a developer on the Ryujinx project (nintendo switch emulator) and worked on the recent port to MacOS which used MoltenVK, though it's still being upstreamed. I've got a few questions surrounding pipeline compilation, in case there's some way I could improve the performance.
As an emulator, we pretty much have to compile shaders constantly at runtime. We use a dispatch queue for draws with the special ability to collect multiple shader programs ahead of where the backend is currently drawing for multithreaded compilation, and we also have a disk shader cache.
The Ryujinx shader cache works by storing a single pipeline state for each guest shader (and optionally cached spirv), and batch creating pipelines from that on launch to preload them all into memory, keeping the shader modules in memory. This is done to optimize the possible creation of similar pipelines using the same shader collection in future, as on other drivers this costs a fraction of a millisecond (0.01ms). Games do this a lot at runtime as there's a lot of pipeline state we don't upload as dynamic, or can't.
I have a few questions:
Regardless, I was majorly impressed with how well MoltenVK handled our Vulkan backend, after the portability subset limitations were dealt with. Thanks for working on this project!
Beta Was this translation helpful? Give feedback.
All reactions