-
Notifications
You must be signed in to change notification settings - Fork 546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pipeline cache serialization/deserialization investigation #3716
Comments
Thank you for filing this! |
Okay, disregard basically everything that I wrote in the Metal section above, because on macOS 11.0 we can use the poorly-named poorly-documented |
I've made a start on this at this branch: master...expenses:metal-pipeline-cache |
I actually did a small bit of research into the dx12 docs for #2877 last night since it seems to be free now, so I could keep looking into it and see if I get anywhere...I'm not too familiar with gfx-rs though and I've never done anything with dx12 so I wouldn't rely on me, but I will try 😄 |
Okay, I've been doing some testing of #3719 using a hacky fork of https://github.com/repi/shadertoy-browser. Basically it loads 8866 spir-v fragment shaders and creates a pipeline for each one using a basic vertex shader, then exits. macOS has a system shader cache at Here are some timings with and without caches:
So it looks like using Binary Archives as a pipeline cache does have an improvement over no cache, but not nearly to the degree that you'd expect! It could be that the Binary Archive isn't set up correctly, but I've tested this with I'm going to look into a second cache to store SPIR-V -> MSL transformations to see how much that improves things. |
Goal
It would be neat and useful to have an implementation of
get_pipeline_cache_data
on all modern platforms (Vulkan, DX12, Metal). Along with the corresponding code increate_pipeline_cache
, this would allow for being able to cache the pipelines to disk on all backends, giving a good performance boost when a lot of pipelines are used.Status
Vulkan
The Vulkan API has this
get_pipeline_cache_data
function built in.Metal
Edit: disregard this whole section, see #3716 (comment).
The Metal backend has a pipeline cache:
gfx/src/backend/metal/src/native.rs
Lines 207 to 211 in 2a93d52
However there is no way to serialize or deserialize it at present.
The key blocker for this is that the
ModuleInfo
struct stores ametal::Library
:gfx/src/backend/metal/src/native.rs
Lines 200 to 205 in 2a93d52
While there is no way in the Metal API to serialize a
MTLLibrary
(the underlying type), there is aserialize
function forMTLDynamicLibrary
which I believe we could convert into. It serializes directly into a file though, which is pretty gross. Presumably we'd then have to read back from this file.The other option would be to just store the metal source code for the shader that has been converted from spir-v. This would not give as big a performance improvement though.
MoltenVK
MoltenVK implements a pipeline cache with
MVKPipelineCache
. Similar to what we do with metal, this storesMVKShaderLibraryCache
s which in turn storeMVKShaderLibrary
s. When implementinggetPipelineCacheData
, it writes the metal source code, similar to what I suggest as an option above.As an example of this, here's some of the output of a pipeline cache I generated:
DX12
The DirectX 12 backend doesn't have a pipeline cache. However, there is an issue that lays out how one could be created: #2877, similar to what the Metal backend does.
The text was updated successfully, but these errors were encountered: