-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[GPU] Pipeline caches #11629
base: main
Are you sure you want to change the base?
[GPU] Pipeline caches #11629
Conversation
fbe8b8a
to
fd618e3
Compare
This is on the right track. We'll definitely want a D3D12 implementation before merging this. We might just have to leave this as a no-op on Metal until Apple gets their act together and lets us grab the cache data in memory. One thing that's slightly concerning is that it seems like the application will have to be aware of the backend and provide the correct cache file manually, which might be irritating. I'm not really sure of how to make that future-proof though. |
I thought the principle of pipeline caching is to compile at first startup of the app, and only then reuse the cache once it was created ? Shipping a pipeline cache for each combination of drivers/device/ is not possible in general (some platforms like steam-deck can do that but only because the hardware is always the same). Here is an article from a roblox engineer that goes in depth about how pipeline caching works in the wild maybe some of the concepts can be applied to our needs ? Reading the article, it looks like mobile drivers aren't always compliant even though the functionality is implemented. SDL provides hashing algorithm inside it's stdlib: crc32 and crc16 could be used to ensure the file has not be corrupted ? |
I've implemented a draft for a possible pipeline caching system.
The user can call
SDL_CreateGPUPipelineCache
to create aSDL_GPUPipelineCache
object, which can then be used to accelerate pipeline compilations by passing it as a SDL_PropertiesID toSDL_CreateGPUGraphicsPipeline
andSDL_CreateGPUGraphicsPipeline
.SDL_CreateGPUPipelineCache
takes aSDL_GPUPipelineCacheCreateInfo
struct, which supplies both a checksum binary blob (opaque to the user), a normal pipeline cache blob, and their respective sizes, or NULL/zero if no data is yet present.On application exit, the user can call
SDL_FetchGPUPipelineCacheData
to fill a newSDL_GPUPipelineCacheCreateInfo
with new/update pipeline data, which can then be written to disk and loaded on the next run.Currently the Vulkan implementation is functional except the checksum control part, as I don't know which hash algorithm would be more suitable or preferred for SDL, the DirectX 12 implementation is in the process of being written.
Regarding Metal, I've left a commented implementation for all the necessary function, problem being that Apple wants me to write the entire
MTLBinaryArchive
object to disk, and doesn't provide neither a binary blob which I can use, nor a definition for whatMTLBinaryArchive
actually is internally