-
Notifications
You must be signed in to change notification settings - Fork 207
Pipeline caching! #524
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 caching! #524
Conversation
34ebdd2 to
22138de
Compare
22138de to
4bb38e8
Compare
4e90142 to
9d32238
Compare
|
Not a blocker for this PR, but |
| /// # Safety | ||
| /// | ||
| /// The directory should only have been written into by [`write_pipeline_cache`]. | ||
| /// | ||
| /// We recognise that this is an impossible standard, but that's because Vulkan | ||
| /// makes UB unavoidable around invalid pipeline caches, so just do your best. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's unfortunate. Can we at least embed a checksum in the cache file? If possible, one with a program-local salt so it's extra hard to get the wrong cache by accident?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I struggle to see the point. wgpu already does some sanity checks here, and it's still possible to do UB (if something decides to write to the wrong place with a forged cache with our hash in place).
I don't believe adding it here for this example to be a good use of my time.
If you think this would be a good use of your time, there is space reserved for a hash in the header wgpu writes. The place to contribute that hashing is: https://github.com/gfx-rs/wgpu/blob/trunk/wgpu-core/src/pipeline_cache.rs. The thing that you'd need to use as salt is probably instead (most of) the data in PipelineCacheHeader
|
I'll make it non-exhaustive here. There's little advantage to splitting it out. Edit: Actually, I forgot how bad non_exhaustive is (it doesn't let you use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. This is self contained, and errors therein are failsafe (apart from if JVM stuff explodes, but that will never be safe).
a2cbd96 to
0021ec1
Compare
Supercedes #459
This is the version of pipeline caching using gfx-rs/wgpu#5319
This leads to massive improvements in startup time, especially on Android.