ShaderVariantCollection在warmup的时候第一次会有一个CreateGPU的进程在rendering pipeline里面。
但是这个进程第二次启动就没有发生了。
原因是Metal和Vulkan这类API引入了PSO(Pipeline State Objects),Shader在编译的时候会生成管线对象缓存在机器里。当第二次启动的时候直接读取机器的缓存对象,就不用再编译了。
关于PSO可以参考一下这个文章:https://zhuanlan.zhihu.com/p/55304721
https://blog.unity.com/engine-platform/games-focus-multiplatform-form-factor-player-reach
To improve runtime shader performance and memory management across all platforms, we started by improving shader warmup using asynchronous PSO creation. Using modern graphics APIs, shader runtime compilation is performed as part of the pipeline object creation, which can contribute to stutters and slowdowns when warming shaders. This optimization accelerates shader warmup on modern graphics APIs via multithreaded creation of pipeline objects in order to reduce runtime stutters and slowdowns.
文章评论