Skip to content
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

Streaming shader preprocessor cache #688

Open
Fletterio opened this issue Apr 30, 2024 · 1 comment
Open

Streaming shader preprocessor cache #688

Fletterio opened this issue Apr 30, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Fletterio
Copy link
Contributor

Description

The current cache holds all resources on memory at all times. This could be problematic if, for example, the cache is required to hold many shaders

A streaming shader preprocessor cache is proposed: stored as an LZMA CArchive that would hold:

  • An LZMA-compressed header IFile that holds the JSON describing each of the Cache's container entries
  • One LZMA-compressed virtual IFile per entry described above, holding that entry's shader code

And then load shaders on-demand when compilation is requested

Solution proposal

I think the best would be to load the whole JSON at cache creation time, and then load each shader's byte code onto memory on-demand (so only when compilation for that shader is requested and not earlier)

Additional context

Since each entry contains ALL of the plaintext for ALL its dependencies, that could also start to pile up, so an option is to also have each entry's dependencies stored in an LZMA-compressed file. We would then only load an entry's dependencies onto memory when those need to be compared when compilation is requested. This could additionally come with a Cache method to drop all loaded dependencies from memory if the cache starts taking up too much space in memory (not counting shader code). Or if it's fast enough we could simply make it more "pure-streaming": load dependencies, compare, immediately drop

As it stands right now, shared dependencies are repeated once for each shader. That could also be problematic, so an optimization would be to handle dependencies in another manner so they're unique and shared by entries. This also holds for the current Cache implementation

@Fletterio Fletterio added the enhancement New feature or request label Apr 30, 2024
@devshgraphicsprogramming
Copy link
Member

We need to dedup the contents of files, and keep the dependencies LZMA compressed before we approach on-demand streaming from a file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants